summaryrefslogtreecommitdiff
path: root/cogl/cogl-pipeline-opengl.c
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2011-01-14 11:11:44 +0000
committerNeil Roberts <neil@linux.intel.com>2011-01-24 12:09:11 +0000
commit4bb08ba00b4d572b3201a833377304b88f66e3c3 (patch)
tree600d9b320abe3f9b32a13f75e1f6d276524e2310 /cogl/cogl-pipeline-opengl.c
parent242d9a5002be4ffd35873e84c3cd01e82b1fe114 (diff)
downloadcogl-4bb08ba00b4d572b3201a833377304b88f66e3c3.tar.gz
cogl-pipeline: Flush the lighting params in common code not vertend
The lighting parameters such as the diffuse and ambient colors were previously only flushed in the fixed vertend. This meant that if a vertex shader was used then they would not be set. The lighting parameters are uniforms which are just as useful in a fragment shader so it doesn't really make sense to set them in the vertend. They are now flushed in the common cogl-pipeline-opengl code but the code is #ifdef'd for GLES2 because they need to be part of the progend in that case.
Diffstat (limited to 'cogl/cogl-pipeline-opengl.c')
-rw-r--r--cogl/cogl-pipeline-opengl.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/cogl/cogl-pipeline-opengl.c b/cogl/cogl-pipeline-opengl.c
index d556705a..8f42a81b 100644
--- a/cogl/cogl-pipeline-opengl.c
+++ b/cogl/cogl-pipeline-opengl.c
@@ -565,9 +565,10 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state (
blend_state->blend_dst_factor_rgb));
}
+#ifndef HAVE_COGL_GLES2
+
/* Under GLES2 the alpha function is implemented as part of the
fragment shader */
-#ifndef HAVE_COGL_GLES2
if (pipelines_difference & (COGL_PIPELINE_STATE_ALPHA_FUNC |
COGL_PIPELINE_STATE_ALPHA_FUNC_REFERENCE))
{
@@ -580,6 +581,28 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state (
GE (glAlphaFunc (alpha_state->alpha_func,
alpha_state->alpha_func_reference));
}
+
+ /* Under GLES2 the lighting parameters are implemented as uniforms
+ in the progend */
+ if (pipelines_difference & COGL_PIPELINE_STATE_LIGHTING)
+ {
+ CoglPipeline *authority =
+ _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LIGHTING);
+ CoglPipelineLightingState *lighting_state =
+ &authority->big_state->lighting_state;
+
+ GE (glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT,
+ lighting_state->ambient));
+ GE (glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE,
+ lighting_state->diffuse));
+ GE (glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR,
+ lighting_state->specular));
+ GE (glMaterialfv (GL_FRONT_AND_BACK, GL_EMISSION,
+ lighting_state->emission));
+ GE (glMaterialfv (GL_FRONT_AND_BACK, GL_SHININESS,
+ &lighting_state->shininess));
+ }
+
#endif /* HAVE_COGL_GLES2 */
if (pipelines_difference & COGL_PIPELINE_STATE_DEPTH)