View Full Version : Smooth Shading + glColor4f + Alpha blending = impossible?

11-11-2000, 11:03 AM

I started to create a puzzle-bobble like in OpenGL and I want to draw some little sphere in one color, transparent and without any texture (to win some frame per sec). I have no problem to draw any mesh with 32 bits texture but I can not draw a sphere with smooth shading, a 4 channels color and no texture.
I use glColor(); before sending vertices to my 3d card via glBegin. I tried to change the ambient value of my light but it doesn't resolve my problem. I checked many tutorials but there isn't a tutorial on alpha blending w/o texture and lighting ....

if someone did it in the past or have an iD ...


11-11-2000, 07:42 PM
Try to use glMaterialfv.

11-13-2000, 02:40 AM



glColorMaterial(GL_FRONT, GL_DIFFUSE);

once after you init OpenGL and then you can use Color* to specify the color and alpha for your polys.

glMaterial* will also work but is a more expensive operation.

11-13-2000, 08:46 AM
thanks RandyU and BK,

I tried first the glMaterial method but as BK said it's expensive so I gonna implement the second.

cheers, Arath

11-14-2000, 12:19 PM
Try using glColor4x() after glBegin(). I have been able to do stuff like that with no problems! Perhaps you have an old video driver?

11-14-2000, 08:44 PM
If you're using lighting, the alpha value that results from lighting is the alpha of your diffuse material.

Don't use color material unless you have to.

It is preferable to set the color outside a Begin/End. (Setting Material inside a Begin/End is also allowed but is very bad practice. Use ColorMaterial if you really, really, really have to change your material per-vertex.)

- Matt

11-15-2000, 10:03 PM
So Matt, are you saying that glMaterial is preferable to Using ColorMaterial for per object colour changes? (as opposed to per polygon, or per vertex).