void RenderScene(void)
{
static GLfloat yRot = 0.5f; // Rotation angle for animation
GLfloat specref[] = { 1.0f, 1.0f, 1.0f, 1.0f };
GLfloat lightPos[] = { 0.0f, 0.0f, 0.0f, 1.0f };
yRot += 0.1f;
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
//glTranslatef(-3.0f, 0.0f, -10.0f);
gluLookAt(-12.0f,0.0f,2.0f, 0.0f, 0.0f, 2.0f, 0.0f, 0.0f, 1.0f);
glRotatef(yRot,0.0f,0.0f,1.0f);
glColorMaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE);
glMaterialfv(GL_FRONT, GL_SPECULAR,specref);
glMateriali(GL_FRONT,GL_SHININESS,128);
glPushMatrix();
pObj = gluNewQuadric();
gluQuadricNormals(pObj, GLU_SMOOTH);
glTranslatef(3.0f, 3.0f, 1.0f);
glColor3f(0.0f,1.0f,1.0f);
gluSphere(pObj, 0.2f,20,20);
glLightfv(GL_LIGHT0,GL_POSITION,lightPos);
glPopMatrix();
glBegin(GL_QUADS);
//Table Top
glColor3f(0.0f, 0.5f, 0.0f);
for (int i=-100; i<100; i++)
{
for(int j=-50; j<50; j++)
{
//glNormal3f((float)(rand()%10)/900, (float)(rand()%10)/900, 0.95f);
glNormal3f(0.0f, 0.0f, 1.0f);
glVertex3f(((float)i)/10,((float)j)/10+0.1,0.0f);
glVertex3f(((float)i)/10,((float)j)/10,0.0f);
glVertex3f(((float)i)/10+0.1,((float)j)/10,0.0f);
glVertex3f(((float)i)/10+0.1,((float)j)/10+0.1,0.0f);
}
}
glEnd();
glPopMatrix();
//Do the buffer Swap
glutSwapBuffers();
}
specular lighting
Hi all!!
I am learning opengl and I have a problem with specular lighting. I have a light above what will be a pool table, and I turned specular lighting on to see what happened. I assume the specular highlights should appear below the light source but instead they appear to go off to one side. Any help would be appreciated. Here is part of my source -
Thanks
How tessalated is the surface of the pool table? OpenGL's built in specular highlights won't give you a big round highlight I the middle of the polygon. The highlights are interpolated between vertices, so the shiny spots are going to be near the vertices.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement