PDA

View Full Version : Glass effect: cube vs. quad



04-10-2003, 04:31 PM
I'm trying to set up a pane of glass for an airplane cockpit. It should be mostly transparent, with a bright specular reflection. I had something decent working, but it was using a glutSolidCube() for the pane of glass. I changed it to use GL_QUADS instead (since ultimately, I want to use GL_POLYGON and I thought I'd change as little as possible at first), and the specular reflection disappeared. Anyone know why?

If it matters, the code looks like...
[CODE]
glDepthMask(0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_LIGHT0);

glColor4f(1.0, 1.0, 1.0, 0.05);

drawPane();

glDepthFunc(GL_EQUAL);
glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);

GLfloat Black[4] = {0.0f, 0.0f, 0.0f, 1.0f};
GLfloat Specular[4] = {1.00f, 1.00f, 1.00f, 1.0f};
GLfloat BackSpecular[4] = {0.80f, 0.70f, 0.10f, 1.0f};
GLfloat Shine[] = {50.0f};

glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Black);
glMaterialfv(GL_FRONT, GL_SPECULAR, Specular);
glMaterialfv(GL_BACK, GL_SPECULAR, BackSpecular);
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, Shine);

glColor4f(0.0, 0.0, 0.0, 1.0);

drawPane();

resetMaterials();
glDisable(GL_BLEND);
glDepthFunc(GL_LESS);
glDepthMask(1);
[\code]

Thanks for any help you can give.

Zengar
04-11-2003, 04:40 AM
OpenGL interpolates specular color around the polygon. If you want to have specular highlits you should provide a latge number of small polygons(specular is computed only for vertices).

04-11-2003, 09:05 AM
Thanks for the tip. It turned out I'm actually just an idiot and didn't assign normals for the polygons.