From f23f2a0ea77a52d40c914a261f69160517f7de5a Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 28 Jul 2013 22:01:36 +0000 Subject: [PATCH] Add gl-separate-specular-color, enabled by default --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 15 +++++++++------ panda/src/glstuff/glmisc_src.cxx | 8 ++++++++ panda/src/glstuff/glmisc_src.h | 1 + 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 06bb63dad8..8f7fde52ee 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -4965,11 +4965,7 @@ do_issue_material() { } #endif // NDEBUG -#ifndef OPENGLES GLenum face = material->get_twoside() ? GL_FRONT_AND_BACK : GL_FRONT; -#else - static const GLenum face = GL_FRONT_AND_BACK; -#endif // OPENGLES call_glMaterialfv(face, GL_SPECULAR, material->get_specular()); call_glMaterialfv(face, GL_EMISSION, material->get_emission()); @@ -5025,10 +5021,17 @@ do_issue_material() { } } -#ifndef OPENGLES GLP(LightModeli)(GL_LIGHT_MODEL_LOCAL_VIEWER, material->get_local()); GLP(LightModeli)(GL_LIGHT_MODEL_TWO_SIDE, material->get_twoside()); -#endif // OPENGLES + +#ifndef OPENGLES + if (CLP(separate_specular_color)) { + GLP(LightModeli)(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); + } else { + GLP(LightModeli)(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); + } +#endif + report_my_gl_errors(); #endif // OPENGLES_2 } diff --git a/panda/src/glstuff/glmisc_src.cxx b/panda/src/glstuff/glmisc_src.cxx index d8a202a04d..8cf477f54b 100644 --- a/panda/src/glstuff/glmisc_src.cxx +++ b/panda/src/glstuff/glmisc_src.cxx @@ -156,6 +156,14 @@ ConfigVariableBool CLP(force_no_flush) ("gl-force-no-flush", false, PRC_DESC("Avoid calling glFlush(), for a potential performance benefit. This may be a little dangerous.")); +ConfigVariableBool CLP(separate_specular_color) + ("gl-separate-specular-color", true, + PRC_DESC("When separate specular mode is on, the specular component " + "will be written to the secondary instead of the primary " + "color, which is added after the texturing stage. In other " + "words, the specular highlight will be unmodulated by the " + "color of the texture.")); + extern ConfigVariableBool CLP(parallel_arrays); void CLP(init_classes)() { diff --git a/panda/src/glstuff/glmisc_src.h b/panda/src/glstuff/glmisc_src.h index 748564647a..f2f71e4772 100644 --- a/panda/src/glstuff/glmisc_src.h +++ b/panda/src/glstuff/glmisc_src.h @@ -61,6 +61,7 @@ extern ConfigVariableBool CLP(force_depth_stencil); extern ConfigVariableBool CLP(matrix_palette); extern ConfigVariableBool CLP(force_no_error); extern ConfigVariableBool CLP(force_no_flush); +extern ConfigVariableBool CLP(separate_specular_color); extern EXPCL_GL void CLP(init_classes)();