PDA

View Full Version : drawing glass



curmudgeon42
12-05-2003, 06:42 PM
i am trying to do a fish tank as a final project for my intro to OpenGL class. however, we have not covered alpha transparency in class at all, let alone glass. how would i draw a glass fish tank (obviously with a blue color so it looks to be filled with water) and have it so that things drawn inside the box (fish, etc.) can be seen?

thanks,

justin

Mighty
12-05-2003, 07:41 PM
Well if I were you I'd look into openGL's blending. Well to start off
glColor4f(r,g,b,a)
The a stands for alpha so something with set to 0.0 for that parameter would give you transparency, but that's probably not what you want. You probably want translucency out of your fish tank walls, so you can see through to the other side. I'd start off by enabling GL_BLEND. Then you're going to have to figure out how to use glBlendFunc(source, destination) to properly blend it.
Also if the viewpoint is going to be moving you should also look into drawing the sides in the correct order. I'd find a good tutorial, try nehe.gamedev.net

sebh
12-06-2003, 01:16 AM
Yes,

call glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA), then if you want your glass half transparent put 0.5 in alpha component.
As Mighty said, don't forget to draw the face in correct order(first the fish then the transparent faces from background to foreground to avoid z problems).

[This message has been edited by sebh (edited 12-06-2003).]

curmudgeon42
12-06-2003, 07:26 AM
okay, thanks. i just have to fool around, there is no "standard" for how to draw good looking glass? (i.e. with lighting highlights and what-not)

thanks,

justin