Results 1 to 3 of 3

Thread: Why does SetupRC( ) come before RenderScene?

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2000
    Location
    Hanmer
    Posts
    25

    Why does SetupRC( ) come before RenderScene?

    Why does SetupRC( ) come before RenderScene?
    Shouldn't SetupRC( ) come before since it sets the glClearColor? How does glClear(GL_COLOR_BUFFER_BIT); know what color to clear with if it goes before SetupRC( )?

    #include <windows.h>
    #include <gl/glut.h>

    // Called to draw scene
    void RenderScene(void)
    {
    // Clear the window with current clearing color
    glClear(GL_COLOR_BUFFER_BIT);


    // Flush drawing commands
    glFlush();
    }

    // Setup the rendering state
    void SetupRC(void)
    {
    glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
    }


    // Main program entry point
    void main(void)
    {
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutCreateWindow("Simple");
    glutDisplayFunc(RenderScene);

    SetupRC();

    glutMainLoop();
    }
    I'd appreciate any response to this message.
    Thanx,
    Y-T

  2. #2
    Junior Member Newbie
    Join Date
    Jun 2000
    Posts
    21

    Re: Why does SetupRC( ) come before RenderScene?

    Well, you set the display function (RenderScene) using glutDisplayFunc()

    But this will not call RenderScene, it only tells GLUT to call RenderScene when the window should be redrawn.

    Then you call SetupRC(), which sets the clear color.

    Finally you call glutMainLoop(). NOW GLUT creates the window, and RenderScene will be called.

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2000
    Location
    Hanmer
    Posts
    25

    Re: Why does SetupRC( ) come before RenderScene?

    Alright now i understand! Thanx alot for replying =)!!!

    Y-T

Similar Threads

  1. Passing class reference to renderscene() MainLoop
    By RobertEd in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 05-23-2010, 02:27 AM
  2. sending referance parameters to RenderScene()?
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-17-2001, 02:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean