Skip to content

Commit 97933dd

Browse files
committed
nehe examples: get per-vertex colors working
1 parent f3f3ac3 commit 97933dd

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

examples/nehe/lesson03/lesson3.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@ void init(GLvoid) // Create Some Everyday Functions
2323
glClearDepth(1.0f); // Depth Buffer Setup
2424
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2525
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
26-
//glEnable(GL_COLOR_MATERIAL);
2726
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
27+
28+
// ps2gl needs lighting + color_material for per-vertex colors
29+
glEnable(GL_COLOR_MATERIAL);
30+
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
31+
glEnable(GL_LIGHTING);
32+
glEnable(GL_LIGHT0);
2833
}
2934

3035
void display(void) // Create The Display Function

examples/nehe/lesson04/lesson4.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ void init(GLvoid) // Create Some Everyday Functions
2626
glClearDepth(1.0f); // Depth Buffer Setup
2727
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2828
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
29-
//glEnable(GL_COLOR_MATERIAL);
3029
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
30+
31+
// ps2gl needs lighting + color_material for per-vertex colors
32+
glEnable(GL_COLOR_MATERIAL);
33+
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
34+
glEnable(GL_LIGHTING);
35+
glEnable(GL_LIGHT0);
3136
}
3237

3338
void display(void) // Create The Display Function

examples/nehe/lesson05/lesson5.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ void InitGL(GLvoid) // Create Some Everyday Functions
2626
glClearDepth(1.0f); // Depth Buffer Setup
2727
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2828
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
29-
//glEnable(GL_COLOR_MATERIAL);
3029
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
30+
31+
// ps2gl needs lighting + color_material for per-vertex colors
32+
glEnable(GL_COLOR_MATERIAL);
33+
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
34+
glEnable(GL_LIGHTING);
35+
glEnable(GL_LIGHT0);
3136
}
3237

3338
void display(void) // Create The Display Function

0 commit comments

Comments
 (0)