PDA

View Full Version : Question about transparency



zhanghe
03-18-2003, 03:51 PM
If you have seen NeHe'book about OpenGL,in the Lesson eight,it said that add the following two lines somewhere in the InitGL() section of code.
glColor4f(1.0f,1.0f,1.0f,0.5f); // Full Brightness, 50% Alpha
glBlendFunc(GL_SRC_ALPHA,GL_ONE); // Blending Function For Translucency Based On Source Alpha Value

My question is why put it in the InitGL() .
If I have two objects in the scene,one is transparency and another is opaque.How should I do?

03-18-2003, 06:47 PM
OpenGL is a state machine. The rendering is done according to the current settings until they are changed. If you want to render the whole scene with the same setting could the code be in the init function.

To mix objects should you first render the scene with the non transparent objects. After that is the transparent object rendered. Remember that transparent object has to be sorted.