From edc309b6b8181a4227547f2077fa05fad5643ca5 Mon Sep 17 00:00:00 2001 From: Francisco Javier Trujillo Mata Date: Mon, 9 Sep 2024 22:59:13 +0200 Subject: [PATCH] Avoid running display twice in idle function --- examples/nehe/lesson04/lesson4.cpp | 5 ++++- examples/nehe/lesson05/lesson5.cpp | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/nehe/lesson04/lesson4.cpp b/examples/nehe/lesson04/lesson4.cpp index 7923db9..2b44825 100644 --- a/examples/nehe/lesson04/lesson4.cpp +++ b/examples/nehe/lesson04/lesson4.cpp @@ -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 @@ -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; diff --git a/examples/nehe/lesson05/lesson5.cpp b/examples/nehe/lesson05/lesson5.cpp index 17e0e59..7edaa08 100644 --- a/examples/nehe/lesson05/lesson5.cpp +++ b/examples/nehe/lesson05/lesson5.cpp @@ -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 @@ -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;