diff --git a/scgl/GLStateManager.cpp b/scgl/GLStateManager.cpp index b7fcc73..0cb321e 100644 --- a/scgl/GLStateManager.cpp +++ b/scgl/GLStateManager.cpp @@ -52,8 +52,8 @@ GLStateManager::GLStateManager() : alphaFunc(7), // GL_ALWAYS alphaRef(0.0f), shadeModel(1), // GL_SMOOTH, - ambientLightEnabled(true), - diffuseLightEnabled(true), + ambientLightEnabled(false), + diffuseLightEnabled(false), ambientLightParams{ 0.2f, 0.2f, 0.2f, 1.0f }, diffuseLightParams{ 0.0f, 0.0f, 0.0f, 1.0f }, isIdentityMatrix{ true, true, true }, @@ -271,13 +271,13 @@ void GLStateManager::AlphaMultiplier(float a) { } void GLStateManager::EnableVertexColors(bool ambient, bool diffuse) { - //if (ambientLightEnabled != ambient || diffuseLightEnabled != diffuse) { - ambientLightEnabled = ambient; - diffuseLightEnabled = diffuse; - + if (ambientLightEnabled != ambient || diffuseLightEnabled != diffuse) { uint8_t oldFlags = (ambientLightEnabled ? 1 : 0) | (diffuseLightEnabled ? 2 : 0); uint8_t newFlags = (ambient ? 1 : 0) | (diffuse ? 2 : 0); + ambientLightEnabled = ambient; + diffuseLightEnabled = diffuse; + switch (newFlags) { case 0: glDisable(GL_COLOR_MATERIAL); @@ -300,11 +300,11 @@ void GLStateManager::EnableVertexColors(bool ambient, bool diffuse) { break; } - glEnable(GL_COLOR_MATERIAL); if (!oldFlags) { + glEnable(GL_COLOR_MATERIAL); glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuseLightParams); } - //} + } } void GLStateManager::MatrixMode(GLenum mode) { diff --git a/scgl/cGDriver_Viewport.cpp b/scgl/cGDriver_Viewport.cpp index b0ec4a0..8f3861c 100644 --- a/scgl/cGDriver_Viewport.cpp +++ b/scgl/cGDriver_Viewport.cpp @@ -282,10 +282,17 @@ namespace nSCGL glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_POSITION, lightPos); - GLfloat ambientLightParams[] = { 1.0f, 0.0f, 0.0f, 1.0f }; + GLfloat ambientLightParams[] = { 0.0f, 0.0f, 0.0f, 1.0f }; + glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLightParams); + + GLfloat diffuseLightParams[] = { 1.0f, 1.0f, 1.0f, 1.0f }; + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLightParams); + glLightfv(GL_LIGHT0, GL_SPECULAR, diffuseLightParams); + + GLfloat ambientMaterialParams[] = { 1.0f, 0.0f, 0.0f, 1.0f }; glMaterialfv(GL_FRONT, GL_AMBIENT, ambientLightParams); - GLfloat diffuseLightParams[] = { 0.0f, 0.0f, 0.0f, 0.0f }; + GLfloat diffuseMaterialParams[] = { 0.0f, 0.0f, 0.0f, 0.0f }; glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuseLightParams); SetViewport();