PDA

View Full Version : Using textures and flat colour.



tracer.bullet
05-07-2001, 09:28 AM
Hi I've had a good look round, I know what I want to do it simple but I can't find a straight answer anywhere.

I've been playing with NeHe's texture mapped cube examples.
I want to be able to texture map one side of the cube, and just flat shade the others.

I can do one or the other, but when I texture map one side of the cube the bitmap is blended with the color (ie a greyscale bitmap is tinted red)

Is my mistake obvious, can someone correct me, or point me at some example code?

Thanks for reading.
Paul.

tracer.bullet
05-07-2001, 09:49 AM
thanks got it.
I just set the texture maped poly to white.
don't know why this was so hard to find.

Deiussum
05-08-2001, 05:58 AM
By default OpenGL's texture mode is set to GL_MODULATE. You can change that with glTexEnv. Typically, I'm using lighting and want that mode anyway so that the lighting differences show through, so I usually just do what you did and make the material white. If you don't want that, you can also try to set the mode to GL_DECAL or GL_REPLACE.

tracer.bullet
05-08-2001, 06:39 AM
Thanks, good to know that there are other benefits to just making the surface white, rather than just a quick and easy solution. The next problem I'm struggling with is how to unbind the texture from the polys I want to be just shaded, there are lots of simple examples out there, but all seem to deal with or with out texture maps, not a combination.

much thanks, as always, for any help, pointers, or advice.

Paul.

Deiussum
05-08-2001, 07:05 AM
To turn off the textures on the other faces you can do one of the following things...

glBindTexture(GL_TEXTURE_2D, 0);
DrawUnTexturedStuff();

glBindTexture(GL_TEXTURE_2D, texID);
DrawTexturedStuff();

or...

glDisable(GL_TEXTURE_2D);
DrawUnTexturedStuff();

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texID);
DrawTexturedStuff();