Skip to content

Commit

Permalink
Avoid running display twice in idle function
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtrujy committed Sep 9, 2024
1 parent d5ea6e2 commit edc309b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion examples/nehe/lesson04/lesson4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ void init(GLvoid) // Create Some Everyday Functions
glEnable(GL_LIGHT0);
}

void idle(void) {
}

void display(void) // Create The Display Function
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
Expand Down Expand Up @@ -92,7 +95,7 @@ int main(int argc, char **argv) // Create Main Function For Bri
glutCreateWindow("NeHe's OpenGL Framework"); // Window Title (argv[0] for current directory as title)
glutDisplayFunc(display); // Matching Earlier Functions To Their Counterparts
glutReshapeFunc(reshape);
glutIdleFunc(display);
glutIdleFunc(idle);
glutMainLoop(); // Initialize The Main Loop

return 0;
Expand Down
6 changes: 5 additions & 1 deletion examples/nehe/lesson05/lesson5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ void InitGL(GLvoid) // Create Some Everyday Functions
glEnable(GL_LIGHT0);
}

void idle(void) {

}

void display(void) // Create The Display Function
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
Expand Down Expand Up @@ -143,7 +147,7 @@ int main(int argc, char **argv) // Create Main Function For Br
InitGL();
glutDisplayFunc(display); // Matching Earlier Functions To Their Counterparts
glutReshapeFunc(reshape);
glutIdleFunc(display);
glutIdleFunc(idle);
glutMainLoop(); // Initialize The Main Loop

return 0;
Expand Down

0 comments on commit edc309b

Please sign in to comment.