Advertisement

Blending one face of a cube

Started by March 09, 2001 05:55 AM
4 comments, last by Rabbit14 23 years, 8 months ago
Hi all. I''ve work on tutorial 7 and 8 of Nehe''s tutorial collection to make just one face of a cube transparent. But all faces become transparent when blending is activate. Why ? Anyone has a solution ?? U could mail me at : jbuyck@club-internet.fr Thanks
Hi,

I''m not sure that we can put a "glEnable" after a glBegin() but if we can, do :

glBegin(QUADS);
glEnable(GL_BLEND);
// Face 1
glDisable(GL_BLEND);
// Face 2
// Face 3
// Face 4
// Face 5
// Face 6
glEnd();

Or do :

glEnable(GL_BLEND);
glBegin(QUADS);
// Face 1
glEnd();
glDisable(GL_BLEND);
glBegin(QUADS);
// Face 2
...
glEnd();

========================
Leyder Dylan
Site : http://slug-production.ibelgique.com
E-Mail : dylan.leyder@ibelgique.com

========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
Advertisement
I don''t thing calling glEnable/glDisable is allowed within a glBegin/glEnd pair.
Make sure that you draw your blended objects last, so the blending is right regardless of your depth culling.

here''s some psuedo code

glBegin(GL_QUADS); //I''d recommend triangles or tri-fans though
glDrawQuadsOneThroughFive();
glEnd();
glEnable(GL_BLEND);
glBegin(GL_QUADS);
glDrawQuadSix();
glEnd();
glDisable(GL_BLEND); // because if we don''t blending will be on forever.

Remember : OpenGL is a state driven API. This means that once something is set, OpenGL remembers that until it is changed.
So a call to glColor sets the color for EVERYTHING drawn after it. email me.
[email=JValentine_13@hotmail.com]contact[/email]
Oops screwy signature on last post, eh?

Feel free to email me.
[email=JValentine_13@hotmail.com]contact[/email]
Or another approach would be;

glColor3f(r,g,b,a=0.5);
glBegin()
Face 1
glEnd()
glColor3f(r,g,b,a=1.0);
Face 2
Face 3
Face 4
....

this might be less processor intensive but i''m not sure
T.J Birand
Or another approach would be;

glColor3f(r,g,b,a=0.5);
glBegin()
Face 1
glEnd()
glColor3f(r,g,b,a=1.0);
glBegin()
Face 2
Face 3
Face 4
....
glEnd()
this might be less processor intensive but i''m not sure
T.J Birand

This topic is closed to new replies.

Advertisement