texture mapping once again

Started by
12 comments, last by Enigma 18 years, 7 months ago
Do you disable texturing while rendering non-textured objects?

Enigma
Advertisement
nope not that i know of...i think the color values with the bitmap are mixing with the scene or something.
Add the following to your texture setup code:

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE)


The default value for TEXTURE_ENV_MODE is GL_MODULATE, which would create the stripes that you are seeing. Read the glTexEnv man page
Quote:Original post by lack the hack
nope not that i know of...i think the color values with the bitmap are mixing with the scene or something.

Well that's your problem then. OpenGL is a state machine. Once you enable texturing it remains enabled until you explicitly disable it. Once you specify a texture coordinate it applies to all subsequent vertices until you explicitly change it. So the code:
glEnable(GL_TEXTURE_2D);glBegin(GL_QUADS);	glTexCoord2f(0, 0);	glVertex2f(0, 0);	glTexCoord2f(1, 0);	glVertex2f(1, 0);	glTexCoord2f(1, 1);	glVertex2f(1, 1);	glTexCoord2f(0, 1);	glVertex2f(0, 1);glEnd();glBegin(GL_QUADS);	glVertex2f(0, 0);	glVertex2f(1, 0);	glVertex2f(1, 1);	glVertex2f(0, 1);glEnd();

is actually functionally identical to:
glEnable(GL_TEXTURE_2D);glBegin(GL_QUADS);	glTexCoord2f(0, 0);	glVertex2f(0, 0);	glTexCoord2f(1, 0);	glVertex2f(1, 0);	glTexCoord2f(1, 1);	glVertex2f(1, 1);	glTexCoord2f(0, 1);	glVertex2f(0, 1);glEnd();glBegin(GL_QUADS);	glTexCoord2f(0, 1);	glVertex2f(0, 0);	glTexCoord2f(0, 1);	glVertex2f(1, 0);	glTexCoord2f(0, 1);	glVertex2f(1, 1);	glTexCoord2f(0, 1);	glVertex2f(0, 1);glEnd();

and your second quad will be textured with a single texel from your texture map (the top right corner texel).

If you want to render an untextured object you must disable texturing.

Enigma

This topic is closed to new replies.

Advertisement