PDA

View Full Version : cant change background color from white



technologist
11-06-2017, 11:23 AM
Just trying to give my background an all black color, i'm getting white:



void renderScene() // Here's Where We Do All The Drawing
{
// Clear Screen And Depth Buffer
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Reset The Current Modelview Matrix
glLoadIdentity();
glClearColor(0.0, 0.0, 0.0, 0.0);
}




int main(int argc, char ** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glClearColor(1.0, 1.0, 0.0, 0.0);
glutCreateWindow("cube - GLUT Tutorial");

//reg callbacks
glutDisplayFunc(renderScene);
glutIdleFunc(renderScene);

glEnable(GL_DEPTH_TEST);

glutMainLoop();

return 1;
}

mhagain
11-06-2017, 12:25 PM
You have a double-buffered context - very good! - but you don't seem to be calling glutSwapBuffers anywhere (at the end of your render func would be an appropriate place).

technologist
11-06-2017, 12:48 PM
bam! ALL BLACK SCREEN!

Thank you!