Ok, as I stated before, I’m very new to openGL but not to programming.
I’m trying to add a polygon to the window that already contains a sphere and the teapot.
I know the poly is there because I placed it over the sphere, but the poly is completely dark.
The code for the poly works ok from previous code I did.
But adding it to the new project is not as easy as I thought it would be.
Why is no color coming through?
Here is some code…
void paint () {
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//glClear (GL_COLOR_BUFFER_BIT);
glPushMatrix();
glTranslatef (0, 0, -5);
//glRotatef (degree, 0, 1, 0);
brass();
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
glBindTexture (GL_TEXTURE_2D, check_id);
//glBindTexture (GL_TEXTURE_2D, static_id);
glutSolidTeapot (1.0);
//glDisable(GL_DEPTH_TEST);
glPushMatrix();
silver();
glDisable(GL_TEXTURE_2D); // no textures
//glDisable(GL_DEPTH_TEST); // visible through walls
//glBindTexture (GL_TEXTURE_2D, static_id);
GLUquadricObj *ball;
glColor3f(0.0f,0.0f,1.0f); // Set Ballhack Color
glTranslatef(4.5,0.0,-2.0);
ball=gluNewQuadric();
gluQuadricNormals(ball, GLU_SMOOTH);
gluSphere(ball,1.0f,30,30);
gluDeleteQuadric(ball);
glDisable(GL_DEPTH_TEST);
glPushMatrix();
//glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//glClear(GL_COLOR_BUFFER_BIT);
//glEnable(GL_DEPTH_TEST);
//glEnable(GL_TEXTURE_2D);
//glBindTexture (GL_TEXTURE_2D, check_id);
glBegin(GL_POLYGON);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex2f(-0.5, -0.5);
glColor3f(1.0f, 0.0f, 1.0f);
glVertex2f(-0.5, 0.5);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex2f(0.5, 0.5);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex2f(0.5, -0.5);
glEnd( );
glPopMatrix();
glPopMatrix();
glPopMatrix();
glFlush();
glutSwapBuffers();
degree += 0.1f;
glutPostRedisplay();
}
int main(int argc, char** argv){
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
glutCreateWindow ("Assignment 2");
setupTextures();
//glEnable(GL_TEXTURE_2D);
//glEnable (GL_DEPTH_TEST);
doLights();
doCamera();
glutDisplayFunc (paint);
glutMainLoop();
}
I didn’t post some code because I know it works.
Suggestions?
Thanks all,
Zath