Sign in to follow this  
supercoollee

OPENGL lesson 3

Recommended Posts

supercoollee    100
i have just started learning OPENGL, i use MASM for programming. in lesson 3, if there isn't a lightsource in the scene, how can the color be shown? and i tried to put up a scene with a lightsource and a triangle, the glColor3x (b or f) function doesn't change the color of the triangle , it always appear gray, i don't know why.

Share this post


Link to post
Share on other sites
Katie    2244
If you don't enable lighting, the "flat" colours specified by the glColour() will be used.

If you turn on lighting, then the glColor() is ignored -- the default material colour will be used instead. Hence your triangle will be drawn in white; which will end up gray after lighting.


You probably want to enable glColorMaterial which will copy colours out of the glColor() calls into the ambient/diffuse/both material colours.

Share this post


Link to post
Share on other sites
supercoollee    100
the problem has been solved. in order to specify color at each vertex,

glEnable(GL_COLOR_MATERIAL)

must be called.

and if no light is specified, GL uses the default lighting, that's why in NEHE's lesson3 the colors can be shown without calling lighting functions.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this