Transparency

Hi all,
I have a 3 sided cube (GL_QUADS with bottom, left, back sides). When i rotate the object, id like the opposite side (of each side) to be transparent. How can i accomplish this?
Thanks in advance.

Just draw the front three faces as normal, with transparency turned off. When you want to draw the back three faces, enable transparency. If your question is how to enable transparency, then I suggest you check out the red book. It is online somewhere, although I don’t know the address offhand. I am sure somebody on this board does. Hope this helps.

Tone

The Red book can be found at http://helios.scripps.edu/library/SGI_bookshelves/SGIindex/SGI_Developer_OpenGL_PG.html

Got it with a search for OpenGL Programming Guide on www.northernlight.com

Okay. I did some research into this but still dont know if its possible. Ill make myself clearer. I dont have a six sided cube…i only have the 3 sides mentioned above. Id like these surfaces to be opaque from one side, but transparent from the other. So that if i rotate the object from the front to the back…all i can see is the outline of each side (cuz its transparent.)
Thanx again.

This is pretty simple to do actually … Call glEnable(GL_CULL_FACE) for a one sided {transparent on one side} face and glDisable(GL_CULL_FACE) for a two sided face. If you use GL_QUADS to draw the faces and apply a texture to the facees then the one-sided version will be transparent on one side and opaque on the other. The two sided version will be opaque on both sides.

Lemme see if I can write a little pseudo-code for ya with a single face

bool doTwoSided;
double xLength,yLength;
MTexture faceTexture(“CubeFace.bmp”); // C++ Texture class

glPushAttrib(GL_ENABLE_BIT);

glPushMatrix(); // Prepare for rotation

glRotatef(180.0,1,0,0); // flip face backwards

if (doTwoSided)
{
glDisable(GL_CULL_FACE);
}
else
{
glEnable(GL_CULL_FACE);
}

faceTexture.bind();

glBegin(GL_QUADS);
glTexCoord2f(0.0f,0.0f);
glVertex2f(0.0f,0.0f);
glTexCoord2f(xLength,0.0f);
glVertex2f(xLength,0.0f);
glTexCoord2f(xLength,yLength);
glVertex2f(xLength,yLength);
glTexCoord2f(0.0f,yLength);
glVertex2f(0.0f,yLength);
glEnd();

glPopMatrix();

glPopAttrib();

[This message has been edited by pleopard (edited 03-08-2001).]

[This message has been edited by pleopard (edited 03-08-2001).]

Thx pleopard, that worked like a charm!!
Except…its the wrong side thats transparent. I have to rotate to see the side-i want it the other way…so how do i switch which side is transparent?

I edited the code above, notice the glRotate command…

Of course . Thanx again!

ofcourse you can also use glCullFace(GL_FRONT) or glCullFace(GL_BACK) to set the face you want to cull. in that case you wont need to rotate the cudbe

oops, it is actually glFrontFace(GL_CW)

i.e. you specify front face as GL_CW = clockwise or GL_CCW = counter clockwise.