Skip to content

Commit edc309b

Browse files
committed
Avoid running display twice in idle function
1 parent d5ea6e2 commit edc309b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

examples/nehe/lesson04/lesson4.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ void init(GLvoid) // Create Some Everyday Functions
3535
glEnable(GL_LIGHT0);
3636
}
3737

38+
void idle(void) {
39+
}
40+
3841
void display(void) // Create The Display Function
3942
{
4043
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
9295
glutCreateWindow("NeHe's OpenGL Framework"); // Window Title (argv[0] for current directory as title)
9396
glutDisplayFunc(display); // Matching Earlier Functions To Their Counterparts
9497
glutReshapeFunc(reshape);
95-
glutIdleFunc(display);
98+
glutIdleFunc(idle);
9699
glutMainLoop(); // Initialize The Main Loop
97100

98101
return 0;

examples/nehe/lesson05/lesson5.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ void InitGL(GLvoid) // Create Some Everyday Functions
3535
glEnable(GL_LIGHT0);
3636
}
3737

38+
void idle(void) {
39+
40+
}
41+
3842
void display(void) // Create The Display Function
3943
{
4044
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
143147
InitGL();
144148
glutDisplayFunc(display); // Matching Earlier Functions To Their Counterparts
145149
glutReshapeFunc(reshape);
146-
glutIdleFunc(display);
150+
glutIdleFunc(idle);
147151
glutMainLoop(); // Initialize The Main Loop
148152

149153
return 0;

0 commit comments

Comments
 (0)