gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Problem: Textures affecting non-textured quads (not wanted).

#75754 - Dark Knight ez - Wed Mar 15, 2006 7:27 pm

Hello.

I've been adding textured and non-textured quads to a 3D environment on the NDS. For textured quads I'm using code similiar to this:
Code:
glBindTexture(GL_TEXTURE_2D, *texture);
glBegin(GL_QUADS);
      glColor3f(1.0f, 1.0f, 1.0f);
      glTexCoord2f(0.0f, 1.0f); glVertex3f(xstart,         tracksCenterY, zstart - depth);
      glTexCoord2f(1.0f, 1.0f); glVertex3f(xstart + width, tracksCenterY, zstart - depth);
      glTexCoord2f(1.0f, 0.0f); glVertex3f(xstart + width, tracksCenterY, zstart);
      glTexCoord2f(0.0f, 0.0f); glVertex3f(xstart,         tracksCenterY, zstart);
glEnd();

For untextured quads, I just leave out the glBindTexture call and the glTexCoord2f calls.
When using both in the same program, my untextured quads seem to use the colour of the texture which has been bound by the last executed glBindTexture call, even though I'm not attaching that texture with glTexCoord2f calls.
This is not at all what I want. I just want it to use the colour specified by glColor3f, not affected by textures I use.
Am I doing something wrong? Is there a call to unbind textures (temporarily)? Or is this a bug in libnds?


Thanks in advance.

Dark Knight ez.

#75755 - MrK - Wed Mar 15, 2006 7:38 pm

I think there's a bit (GL_TEXTURE_2D) in register GFX_CONTROL which controls the texture mapping

maybe using glDisable (GL_TEXTURE_2D) should work... but I can't assure it :)

#75757 - Dark Knight ez - Wed Mar 15, 2006 7:47 pm

Tried that --- glDisable(GL_TEXTURE_2D) --- just now, and it doesn't seem to have the desired effect unfortunately.

#75775 - Webez - Wed Mar 15, 2006 9:43 pm

glBindTexture(GL_TEXTURE_2D, 0);

#75836 - Dark Knight ez - Thu Mar 16, 2006 12:59 pm

Thank you, that did the trick.