[cogl/wip/neil/master-next: 4/9] Add cogl_pipeline_set_layer_default_texture()
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/wip/neil/master-next: 4/9] Add cogl_pipeline_set_layer_default_texture()
- Date: Thu, 9 Feb 2012 20:51:05 +0000 (UTC)
commit 3fae7031c11f304c4e44c3e78d59b037fde044ce
Author: Neil Roberts <neil linux intel com>
Date: Thu Feb 9 13:59:52 2012 +0000
Add cogl_pipeline_set_layer_default_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 existense 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.
cogl/cogl-pipeline-layer-state.c | 37 ++++++++++++++++++++
cogl/cogl-pipeline-layer-state.h | 33 +++++++++++++++++
.../cogl-2.0-experimental-sections.txt | 1 +
3 files changed, 71 insertions(+), 0 deletions(-)
---
diff --git a/cogl/cogl-pipeline-layer-state.c b/cogl/cogl-pipeline-layer-state.c
index 51f92be..8067d5d 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_default_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,
diff --git a/cogl/cogl-pipeline-layer-state.h b/cogl/cogl-pipeline-layer-state.h
index 7c6f7c2..87194a6 100644
--- a/cogl/cogl-pipeline-layer-state.h
+++ b/cogl/cogl-pipeline-layer-state.h
@@ -131,6 +131,13 @@ typedef enum {
* The index values of multiple layers do not have to be consecutive; it is
* only their relative order that is important.
*
+ * The @texture parameter can also be %NULL in which case the pipeline
+ * will use a default white texture. The type of the default texture
+ * will be the same as whatever texture was last used for the pipeline
+ * or %COGL_TEXTURE_TYPE_2D if none has been specified yet. To
+ * explicitly specify the type of default texture required, use
+ * cogl_pipeline_set_layer_default_texture() instead.
+ *
* <note>In the future, we may define other types of pipeline layers, such
* as purely GLSL based layers.</note>
*
@@ -143,6 +150,32 @@ cogl_pipeline_set_layer_texture (CoglPipeline *pipeline,
CoglTexture *texture);
/**
+ * cogl_pipeline_set_layer_default_texture:
+ * @pipeline: A #CoglPipeline
+ * @layer_index: The layer number to modify
+ * @texture_type: The type of the default texture to use
+ *
+ * Sets the texture for this layer to be the default texture for the
+ * given type. This is equivalent to calling
+ * cogl_pipeline_set_layer_texture() with %NULL for the texture
+ * argument except that you can also specify the type of default
+ * texture to use. The default texture is a 1x1 pixel white texture.
+ *
+ * This function is mostly useful if you want to create a base
+ * pipeline that you want to create multiple copies from using
+ * cogl_pipeline_copy(). In that case this function can be used to
+ * specify the texture type so that any pipeline copies can share the
+ * internal texture type state for efficiency.
+ *
+ * Since: 1.10
+ * Stability: unstable
+ */
+void
+cogl_pipeline_set_layer_default_texture (CoglPipeline *pipeline,
+ int layer_index,
+ CoglTextureType texure_type);
+
+/**
* cogl_pipeline_get_layer_texture:
* @pipeline: A #CoglPipeline object
* @layer_index: the index of the layer
diff --git a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
index 74924f6..495b28f 100644
--- a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
+++ b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
@@ -613,6 +613,7 @@ CoglWinding
cogl_pipeline_set_front_face_winding
cogl_pipeline_set_layer_texture
+cogl_pipeline_set_layer_default_texture
cogl_pipeline_get_layer_texture
CoglMaterialFilter
cogl_pipeline_set_layer_filters
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]