diff options
author | Neil Roberts <neil@linux.intel.com> | 2012-02-09 13:59:52 +0000 |
---|---|---|
committer | Neil Roberts <neil@linux.intel.com> | 2012-02-13 17:15:08 +0000 |
commit | fdc07c865f0c657ceac6db385efa128467fb7834 (patch) | |
tree | 07d5f289381fce82fad565d5ebf614d8140a603c /cogl/cogl-pipeline-layer-state.c | |
parent | d2a35a1e2227c27dde84610ffbad3d593c32d096 (diff) | |
download | cogl-fdc07c865f0c657ceac6db385efa128467fb7834.tar.gz |
Add cogl_pipeline_set_layer_null_texture()
This adds a public function to replace the texture for a layer with
the default white texture. It is equivalent to calling
cogl_pipeline_set_layer_texture with NULL for the texture object
except that it also lets you choose a type for the texture. The idea
is that applications using a base pipeline to make multiple copies
that can share the generated shaders can use this function to make the
layer come into existence with the right texture type. Previously the
idiom would be to create a 1x1 dummy texture of the right type but
this ends up creating lots of redundant little textures.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Diffstat (limited to 'cogl/cogl-pipeline-layer-state.c')
-rw-r--r-- | cogl/cogl-pipeline-layer-state.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/cogl/cogl-pipeline-layer-state.c b/cogl/cogl-pipeline-layer-state.c index e6506a8b..b9f51189 100644 --- a/cogl/cogl-pipeline-layer-state.c +++ b/cogl/cogl-pipeline-layer-state.c @@ -324,6 +324,43 @@ cogl_pipeline_set_layer_texture (CoglPipeline *pipeline, } void +cogl_pipeline_set_layer_null_texture (CoglPipeline *pipeline, + int layer_index, + CoglTextureType texture_type) +{ + CoglContext *ctx = _cogl_context_get_default (); + + /* Disallow setting texture types that aren't supported */ + switch (texture_type) + { + case COGL_TEXTURE_TYPE_2D: + break; + + case COGL_TEXTURE_TYPE_3D: + if (ctx->default_gl_texture_3d_tex == NULL) + { + g_warning ("The default 3D texture was set on a pipeline but " + "3D textures are not supported"); + texture_type = COGL_TEXTURE_TYPE_2D; + return; + } + break; + + case COGL_TEXTURE_TYPE_RECTANGLE: + if (ctx->default_gl_texture_rect_tex == NULL) + { + g_warning ("The default rectangle texture was set on a pipeline but " + "rectangle textures are not supported"); + texture_type = COGL_TEXTURE_TYPE_2D; + } + break; + } + + _cogl_pipeline_set_layer_texture_type (pipeline, layer_index, texture_type); + _cogl_pipeline_set_layer_texture_data (pipeline, layer_index, NULL); +} + +void _cogl_pipeline_set_layer_wrap_modes (CoglPipeline *pipeline, CoglPipelineLayer *layer, CoglPipelineLayer *authority, |