Commit 05ac2ef6 authored by hybrid's avatar hybrid

Separated specualr settings from other color settings. Made changes propagate...

Separated specualr settings from other color settings. Made changes propagate even when shininess is 0, which introduced some renderstate bugs previously.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1948 dfc29bdd-3216-0410-991c-e03cc46cb475
parent ad437627
...@@ -1931,9 +1931,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -1931,9 +1931,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
if (resetAllRenderStates || if (resetAllRenderStates ||
lastmaterial.AmbientColor != material.AmbientColor || lastmaterial.AmbientColor != material.AmbientColor ||
lastmaterial.DiffuseColor != material.DiffuseColor || lastmaterial.DiffuseColor != material.DiffuseColor ||
lastmaterial.SpecularColor != material.SpecularColor || lastmaterial.EmissiveColor != material.EmissiveColor)
lastmaterial.EmissiveColor != material.EmissiveColor ||
lastmaterial.Shininess != material.Shininess)
{ {
GLfloat color[4]; GLfloat color[4];
...@@ -1951,6 +1949,21 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -1951,6 +1949,21 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
color[3] = material.DiffuseColor.getAlpha() * inv; color[3] = material.DiffuseColor.getAlpha() * inv;
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color);
color[0] = material.EmissiveColor.getRed() * inv;
color[1] = material.EmissiveColor.getGreen() * inv;
color[2] = material.EmissiveColor.getBlue() * inv;
color[3] = material.EmissiveColor.getAlpha() * inv;
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color);
}
if (resetAllRenderStates ||
lastmaterial.SpecularColor != material.SpecularColor ||
lastmaterial.Shininess != material.Shininess)
{
GLfloat color[4]={0.f,0.f,0.f,1.f};
const f32 inv = 1.0f / 255.0f;
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material.Shininess);
// disable Specular colors if no shininess is set // disable Specular colors if no shininess is set
if (material.Shininess != 0.0f) if (material.Shininess != 0.0f)
{ {
...@@ -1958,24 +1971,16 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -1958,24 +1971,16 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
if (FeatureAvailable[IRR_EXT_separate_specular_color]) if (FeatureAvailable[IRR_EXT_separate_specular_color])
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
#endif #endif
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material.Shininess);
color[0] = material.SpecularColor.getRed() * inv; color[0] = material.SpecularColor.getRed() * inv;
color[1] = material.SpecularColor.getGreen() * inv; color[1] = material.SpecularColor.getGreen() * inv;
color[2] = material.SpecularColor.getBlue() * inv; color[2] = material.SpecularColor.getBlue() * inv;
color[3] = material.SpecularColor.getAlpha() * inv; color[3] = material.SpecularColor.getAlpha() * inv;
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color);
} }
#ifdef GL_EXT_separate_specular_color #ifdef GL_EXT_separate_specular_color
else else if (FeatureAvailable[IRR_EXT_separate_specular_color])
if (FeatureAvailable[IRR_EXT_separate_specular_color]) glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR);
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR);
#endif #endif
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color);
color[0] = material.EmissiveColor.getRed() * inv;
color[1] = material.EmissiveColor.getGreen() * inv;
color[2] = material.EmissiveColor.getBlue() * inv;
color[3] = material.EmissiveColor.getAlpha() * inv;
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color);
} }
// Texture filter // Texture filter
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment