Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: cant change background color from white

  1. #1
    Intern Contributor
    Join Date
    May 2017
    Posts
    65

    cant change background color from white

    Just trying to give my background an all black color, i'm getting white:

    Code :
    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);
    }

    Code :
    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;
    }

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,716
    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).

  3. #3
    Intern Contributor
    Join Date
    May 2017
    Posts
    65
    bam! ALL BLACK SCREEN!

    Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •