import pygame
from pygame.locals import *
from OpenGL.GL import *
from OpenGL.GLU import *
verticies = (
    (-2,0,0.75),
    (-0.75,0,-0.25),
    (-1.25,0,-2),
    (0,0,-1),
    (1.25,0,-2),
    (0.75,0,-0.25),
    (2,0,0.75),
    (0.5,0,0.75),
    (0,0,2.5),
    (-0.5,0,0.75),
    (0,-0.5,0),
    (0,0.5,0),
    )
edges = (
    (0, 1),
    (0,9),
    (0,10),
    (0,11),
    (1,10),
    (1,11),
    (2,1),
    (2,3),
    (2,10),
    (2,11),
    (3,10),
    (3,11),
    (4, 3),
    (4,5),
    (4,10),
    (4,11),
    (5,10),
    (5,11),
    (6, 5),
    (6,7),
    (6,10),
    (6,11),
    (7,10),
    (7,11),
    (8, 7),
    (8,9),
    (8,10),
    (8,11),
    (9,10),
    (9,11)
    )
def Cube():
    glBegin(GL_LINES)
    for edge in edges:
        for vertex in edge:
            glVertex3fv(verticies[vertex])
    glEnd()
def main():
    pygame.init()
    display = (1500,1000)
    pygame.display.set_mode(display, DOUBLEBUF|OPENGL)
    gluPerspective(45, (display[0]/display[1]), 0.1, 50.0)
    glTranslatef(0.0,0.0, -5)
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                quit()
        glRotatef(1, 3, 1, 1)
        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
        Cube()
        pygame.display.flip()
        pygame.time.wait(10)
main()
 
Comentarios
Publicar un comentario