Link to home
Start Free TrialLog in
Avatar of KeithTeo
KeithTeo

asked on

Translucent Sphere

Anybody can guide in how to draw a translucent sphere? Pls show my some code. Thanks.
Avatar of sunnycoder
sunnycoder
Flag of India image

Hi KeithTeo,

two things ... what platform/library?
is this your homework ?

Cheers!
Sunny:o)
Avatar of KeithTeo
KeithTeo

ASKER

I'm working on Win2K using standard opengl library.

I understand that GLUquadricObj allows me to draw a spherical object and glColor4f allows me to draw an alpha object. But I still landed up with an opaque object. Why? Whats wrong? Can show me some code?

No. Its not my homework. Its just an interest.
ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
well, I dont't have the code right now, but the problem is really simple. You first have to enable blending.


If that is all you need, please go ahead and skip the rest.

To understand this, you have to know just a couple of things.
1. Every geometric primitive that you draw, has finally to be represented on a raster - scan display, and thus all geometry is finally computed into pixels.

2. The entire 3D scene is projected onto a 2D plane, thus many objects end up overlapping each other.

3. When OpenGL is writing pixels to the frame buffer, it checks if a pixel is already there.
(Sorry, pressed a couple of wrong keys!)

        a. if no, then it simply writes to the buffer.
        b. If yes, then it checks if the pixel in the buffer has come from a primitive that is closer to the camera than the current one. If the new one is closer, the value is overwritten, if the previous one is closer, then the new value is discarded.

4. However, this is in case of opaque objects, now suppose that you have to make something look transparent. In such a case, logic says that a pixel coming from the transparent/translucent primitive will not overwrite the previous pixel but change its colour (lets say in case of coloured glass). This modification of the colour of the previous pixel by the new one is termed blending.

Thus, you first have to enable blending. Then you select one of the various blending modes available and finally you precisely specify how you want the 'modification' to be done.

Regards
Vin