Skip to content

Commit 611ee1b

Browse files
authored
Merge pull request #17 from rickgaiser/for-ps2dev
Improve defaults for lighting and per-vertex colors
2 parents bcbc325 + 97933dd commit 611ee1b

26 files changed

+2710
-2710
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

src/gmanager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ bool CGeomManager::DoNormalize = false;
4646

4747
CGeomManager::CGeomManager(CGLContext& context)
4848
: GLContext(context)
49-
, CurNormal(0.0f, 0.0f, 0.0f)
49+
, CurNormal(0.0f, 0.0f, 1.0f)
5050
, Prim(GL_INVALID_VALUE)
5151
, InsideBeginEnd(false)
5252
, LastArrayAccessWasIndexed(false)

src/lighting.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ CImmLight::CImmLight(CGLContext& context, int lightNum)
3333
, bIsEnabled(false)
3434
, Type(kDirectional)
3535
{
36+
if (lightNum == 0) {
37+
// Light0 has different initial values
38+
Diffuse = cpu_vec_xyzw(1.0f, 1.0f, 1.0f, 1.0f);
39+
Specular = cpu_vec_xyzw(1.0f, 1.0f, 1.0f, 1.0f);
40+
}
3641
}
3742

3843
void CImmLight::CheckTypeChange(tLightType oldType)

0 commit comments

Comments
 (0)