I have encountered a problem when simulation transparency in OpenGL. Here is the scenario:
I have a ship which is represented by a sphere. Now I though about adding a shield around the ship. I chose a sphere too, but with a larger radius and set the alpha factor 0.5 ( opacity ). However, the shield doesn't appear and the colors don't blend( as if it was not there ).
The camera is located in the center of the 1st sphere. I think the problem is that I'm inside the sphere, so opengl will just ignore it(not draw it).
The code looks like this:
//ship colors setup with alpha 1.0f
glutSolidSphere(1, 100, 100); original sphere ( ship )
//shield colors setup with alpha 0.5f
glutSolidSphere(3, 100, 100); //the shield whose colors should blend with the rest of the scene
I have though to simulate the shield with a parallelepiped in front of the ship. However this is not what I want...
EDIT: I have found the mistake. I was setting the near param of gluPerspective() too high, so even though i was setting the alpha value correctly, the camera was in front of the object all the time so there was no way of seeing it.