Note you have to have a alpha value set for blend to work correctly.
With glColor3f you only set the color values and the default is alpha of 1, which is non-transparent.
When you draw your cube you should set each sides color and alpha.
alpha = 1.0 non-transparent, 0.3 = simi-transparent (adjust until you get the amount of transparency)
This is how I setup stuff like that:
float cube_color[6][4] = { { 1, 1, 1, 1.0 }, { 1, 1, 1, 1.0 }, { 1, 1, 1, 1.0 }, { 1, 1, 1, 1.0 }, { 1, 1, 1, 1.0 }, { 1, 1, 1, 0.3 }};
inside you cube draw routine.
glColor4fv( cube_color[side] );
or with your example something like this:
Not sure the unsigned bit coverted right.
glColor4ub 255 255 255 40 white with a low alpha for simi-tranparency. I use white for transparent area’s, unless you want a color filter effect.
Originally posted by djavan:
[b]Hi
I am trying to draw a cube (each side with a different color) with one of its sides (i.e. the top) being transparent and the rest being solid (so that when I rotate it, I only see the inside when the transparent side comes to view)
my code (in VB) for the TOP-SIDE looks like this:
glPushMatrix
glColor3ub 160, 130, 50
glEnable GL_BLEND
glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
glBegin bmQuads
glVertex3f xMn, yMn, Z
glVertex3f xMx, yMn, Z
glVertex3f xMx, yMx, Z
glVertex3f xMn, yMx, Z
glEnd
glDisable GL_BLEND
glPopMatrix
But it doesn’t draw anything at all!?!?
Can you please tell me what am I missing?
Thanks a lot.[/b]
[This message has been edited by nexusone (edited 02-16-2003).]