RE: [PyOpenGL-Users] Lighting and texturing
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@ho...> - 2001-09-23 09:36:47
|
21.030 Why doesn't lighting work when I turn on texture mapping? There are many well-meaning texture map demos available on the Web that set the texture environment to GL_DECAL or GL_REPLACE. These environment modes effectively replace the primitive color with the texture color. Because lighting values are calculated before texture mapping (lighting is a per vertex operation, while texture mapping is a per fragment operation), the texture color replaces the colors calculated by lighting. The result is that lighting appears to stop working when texture mapping is enabled. The default texture environment is GL_MODULATE, which multiplies the texture color by the primitive (or lighting) color. Most applications that use both OpenGL lighting and texture mapping use the GL_MODULATE texture environment. Look for the following line in your code: glTexEnv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); /* or GL_REPLACE */ You should change GL_DECAL to GL_MODULATE, or simply delete the line entirely (since GL_MODULATE is the default). Might that be the problem in your code? I'll take a look at your code tomorrow if I can get some time and see if I can see anything. Also need to make sure none of my code is well meaning :o) , pretty sure I have a few of those hanging around... Mike -----Original Message----- From: pyo...@li... [mailto:pyo...@li...]On Behalf Of Richard Jones Sent: September 22, 2001 07:33 To: pyo...@li... Subject: Re: [PyOpenGL-Users] Lighting and texturing On Sat, 22 Sep 2001 20:15, Richard Jones wrote: > I can't seem to figure how to have a surface lit and textured. The demo > that comes with pyopengl (NeHe/lesson18.py) doesn't work, and my code looks > very similar to it... > > Ideas? ... glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL) ... |