tags:

views:

51

answers:

1

I'm trying to use the OpenGL module with Python.

Here is my source:

pygame.init()
screen = pygame.display.set_mode((800, 600), HWSURFACE|OPENGL|DOUBLEBUF)


def init():
        glEnable(GL_DEPTH_TEST)

        glShadeModel(GL_FLAT)
        glClearColor(1.0, 1.0, 1.0, 0.0)

        glEnable(GL_COLOR_MATERIAL)

        glEnable(GL_LIGHTING)
        glEnable(GL_LIGHT0)        
        glLight(GL_LIGHT0, GL_POSITION,  (0, 1, 1, 0)) 


def draw():
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glLoadIdentity()
    glColor3fv((25, 123, 180))
    glBegin(GL_TRIANGLES)       

    glVertex3f( 0.0, 10.0, 0.0) 
    glVertex3f(-10.0,-10.0, 0.0)
    glVertex3f( 10.0,-10.0, 0.0)
    glEnd()


def run():   
    init()    
    while True:
        draw()
        pygame.display.flip()

run()

Can anyone see what is wrong? I'm just trying to draw a simple 3 pointed vertex, yet nothing shows up on the screen. Occasionally I get a bright pink screen. I'm confident it's a basic error.

+2  A: 

You need to setup view and projection matrices.

http://www.opengl.org/resources/faq/technical/transformations.htm#tran0090

Victor Marzo