[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] PyOpenGL



Jason Ward wrote:

Hi I am having trouble with Lighting in pyopengl.
whenever I use
glEnable(GL_LIGHTING)
My objects look blue, my light color is (1,1,1,1)
Therefore my object should be its own color.
which is red,blue, and green. It is a triangle with each side a different color.

You'll want to glEnable(GL_COLOR_MATERIAL) if you want to use glColor(..) with lighting. Otherwise, you must set the "color" of a vertex with the glMaterial(..) functions.



I am using Pygame to handle events and the Window. Glut was too slow and only allowed one keypress at a time. Pygame works much better for PyOPENGL.

If I turn off the Lighting then My colors are fine but I don't have any lighting :(
My light is set up properly.
It seems to make a difference where I put my glEnable(GL_LIGHTING)
If my drawing code is not in a loop and I put
glEnable(GL_LIGHTING)
just above this
pygame.display.flip()

This obviously has no effect on what has already been drawn, so it's only affecting drawing in the next run through your render loop (which I'm assuming starts out by disabling lighting).



then it works fine. But if I put my program/drawing code in a loop then My lighting just makes my object appear blue.

Probably the result of some other material or light state changes elsewhere in your code.


Alex.