PDA

View Full Version : Texture and Color



Anish
08-13-2005, 02:00 AM
Hai,

In my quad i wnat to draw a texture in front and back faces and all other faces fill with different colors.
Is it possible

i wrote this way
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glBindTexture(GL_TEXTURE_2D, texBr[0]);
glBegin(GL_QUADS);
if( face==FRONT or face BACK)
{
//Draw the texture
}
else
{
glColor3f(0,1,0);
//Draw the face
}

But the faces didn't fill with the specified color. it always appears the texture color.

Anyone have any idea??
:rolleyes:

Thanks :)

Anish

T101
08-13-2005, 11:00 PM
OpenGL only makes a distinction between front faces and back faces.

A front face is a surface which faces in the general direction of the viewer.
A back face is a surface which faces away from the viewer.
The facing is determined by the surface normal (which is derived from the order in which you specify the vertices).

Think of surfaces in OpenGL as sheets of paper. You can only see one side at a time.

If you want something fancier, you'll have to code it yourself.

jide
08-14-2005, 01:25 AM
Do it like that:

glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glBindTexture(GL_TEXTURE_2D, texBr[0]);

glBegin(GL_QUADS);
//Draw front and back faces
glEnd();

glDisable (GL_TEXTURE_2D);
glColor3f(0,1,0);
glBegin(GL_QUADS);
//Draw other faces
glEnd();

The main issue that remains is how you calculate if a face is front/back or other. Common graphic applications only distinguish front and back faces. More only front faces are visible and other faces (back) will never.