From 36cfb6030784791a4420a1e52a8c18d56b1d0c69 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 12 May 2009 14:15:18 +0100 Subject: [PATCH] [cogl] Remove the COGL{enum,int,uint} typedefs COGLenum, COGLint and COGLuint which were simply typedefs for GL{enum,int,uint} have been removed from the API and replaced with specialised enum typedefs, int and unsigned int. These were causing problems for generating bindings and also considered poor style. The cogl texture filter defines CGL_NEAREST and CGL_LINEAR etc are now replaced by a namespaced typedef 'CoglTextureFilter' so they should be replaced with COGL_TEXTURE_FILTER_NEAREST and COGL_TEXTURE_FILTER_LINEAR etc. The shader type defines CGL_VERTEX_SHADER and CGL_FRAGMENT_SHADER are handled by a CoglShaderType typedef and should be replaced with COGL_SHADER_TYPE_VERTEX and COGL_SHADER_TYPE_FRAGMENT. cogl_shader_get_parameteriv has been replaced by cogl_shader_get_type and cogl_shader_is_compiled. More getters can be added later if desired. --- README | 16 +++++ clutter/clutter-shader-types.c | 10 +-- clutter/clutter-shader-types.h | 2 +- clutter/clutter-shader.c | 21 +++--- clutter/clutter-texture.c | 14 ++-- clutter/cogl/cogl-shader.h | 81 ++++++++++++--------- clutter/cogl/cogl-texture.h | 54 ++++++++++++-- clutter/cogl/gl/cogl-defines.h.in | 13 ---- clutter/cogl/gl/cogl-program.c | 14 ++-- clutter/cogl/gl/cogl-shader.c | 73 +++++++++++++++---- clutter/cogl/gl/cogl-texture-private.h | 4 +- clutter/cogl/gl/cogl-texture.c | 20 +++--- clutter/cogl/gles/cogl-defines.h.in | 16 ----- clutter/cogl/gles/cogl-program.c | 26 +++---- clutter/cogl/gles/cogl-shader.c | 88 +++++++++++++++++------ clutter/cogl/gles/cogl-texture-private.h | 4 +- clutter/cogl/gles/cogl-texture.c | 8 +-- clutter/glx/clutter-glx-texture-pixmap.c | 50 +++++++------ clutter/pango/cogl-pango-glyph-cache.c | 8 +-- doc/reference/cogl/cogl-sections.txt | 3 +- tests/interactive/test-cogl-tex-polygon.c | 44 ++++++------ tests/interactive/test-cogl-tex-tile.c | 49 ++++++------- 22 files changed, 375 insertions(+), 243 deletions(-) diff --git a/README b/README index 2bf2a039a..e28a467f3 100644 --- a/README +++ b/README @@ -317,6 +317,22 @@ Release Notes for Clutter 1.0 exposing color mask if anyone wants it later. It was assumed that no one was using this currently. +* COGLenum, COGLint and COGLuint which were simply typedefs for GL{enum,int,uint} + have been removed from the API and replaced with specialised enum typedefs, + int and unsigned int. These were causing problems for generating bindings and + also considered poor style. + +* The cogl texture filter defines CGL_NEAREST and CGL_LINEAR etc are now + replaced by a namespaced typedef 'CoglTextureFilter' so they should be + replaced with COGL_TEXTURE_FILTER_NEAREST and COGL_TEXTURE_FILTER_LINEAR etc. + +* The shader type defines CGL_VERTEX_SHADER and CGL_FRAGMENT_SHADER are handled + by a CoglShaderType typedef and should be replaced with + COGL_SHADER_TYPE_VERTEX and COGL_SHADER_TYPE_FRAGMENT. + +* cogl_shader_get_parameteriv has been replaced by cogl_shader_get_type and + cogl_shader_is_compiled. More getters can be added later if desired. + Release Notes for Clutter 0.8 ------------------------------- diff --git a/clutter/clutter-shader-types.c b/clutter/clutter-shader-types.c index 9b3c6b60f..e03d906b2 100644 --- a/clutter/clutter-shader-types.c +++ b/clutter/clutter-shader-types.c @@ -88,7 +88,7 @@ struct _ClutterShaderFloat struct _ClutterShaderInt { gint size; - COGLint value[4]; + int value[4]; }; struct _ClutterShaderMatrix @@ -223,7 +223,7 @@ clutter_value_collect_shader_int (GValue *value, guint collect_flags) { gint int_count = collect_values[0].v_int; - const COGLint *ints = collect_values[1].v_pointer; + const int *ints = collect_values[1].v_pointer; if (!ints) return g_strdup_printf ("value location for '%s' passed as NULL", @@ -242,7 +242,7 @@ clutter_value_lcopy_shader_int (const GValue *value, guint collect_flags) { gint *int_count = collect_values[0].v_pointer; - COGLint **ints = collect_values[1].v_pointer; + int **ints = collect_values[1].v_pointer; ClutterShaderInt *shader_int = value->data[0].v_pointer; if (!int_count || !ints) @@ -250,7 +250,7 @@ clutter_value_lcopy_shader_int (const GValue *value, G_VALUE_TYPE_NAME (value)); *int_count = shader_int->size; - *ints = g_memdup (shader_int->value, shader_int->size * sizeof (COGLint)); + *ints = g_memdup (shader_int->value, shader_int->size * sizeof (int)); return NULL; } @@ -514,7 +514,7 @@ clutter_value_get_shader_float (const GValue *value, * * Since: 0.8 */ -G_CONST_RETURN COGLint * +G_CONST_RETURN int * clutter_value_get_shader_int (const GValue *value, gsize *length) { diff --git a/clutter/clutter-shader-types.h b/clutter/clutter-shader-types.h index fd36fe1c6..1b4842645 100644 --- a/clutter/clutter-shader-types.h +++ b/clutter/clutter-shader-types.h @@ -86,7 +86,7 @@ void clutter_value_set_shader_matrix (GValue *value, const gfloat *matrix); G_CONST_RETURN gfloat * clutter_value_get_shader_float (const GValue *value, gsize *length); -G_CONST_RETURN COGLint *clutter_value_get_shader_int (const GValue *value, +G_CONST_RETURN gint * clutter_value_get_shader_int (const GValue *value, gsize *length); G_CONST_RETURN gfloat * clutter_value_get_shader_matrix (const GValue *value, gsize *length); diff --git a/clutter/clutter-shader.c b/clutter/clutter-shader.c index b23c70af3..e2ba66ce7 100644 --- a/clutter/clutter-shader.c +++ b/clutter/clutter-shader.c @@ -84,7 +84,7 @@ struct _ClutterShaderPrivate CoglHandle fragment_shader; }; -enum +enum { PROP_0, @@ -126,11 +126,11 @@ clutter_shader_set_property (GObject *object, switch (prop_id) { case PROP_VERTEX_SOURCE: - clutter_shader_set_vertex_source (shader, + clutter_shader_set_vertex_source (shader, g_value_get_string (value), -1); break; case PROP_FRAGMENT_SOURCE: - clutter_shader_set_fragment_source (shader, + clutter_shader_set_fragment_source (shader, g_value_get_string (value), -1); break; case PROP_ENABLED: @@ -427,20 +427,19 @@ clutter_shader_glsl_bind (ClutterShader *self, GError **error) { ClutterShaderPrivate *priv = self->priv; - GLint is_compiled = CGL_FALSE; CoglHandle shader = COGL_INVALID_HANDLE; switch (shader_type) { case CLUTTER_VERTEX_SHADER: - shader = cogl_create_shader (CGL_VERTEX_SHADER); + shader = cogl_create_shader (COGL_SHADER_TYPE_VERTEX); cogl_shader_source (shader, priv->vertex_source); priv->vertex_shader = shader; break; case CLUTTER_FRAGMENT_SHADER: - shader = cogl_create_shader (CGL_FRAGMENT_SHADER); + shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT); cogl_shader_source (shader, priv->fragment_source); priv->fragment_shader = shader; @@ -450,11 +449,7 @@ clutter_shader_glsl_bind (ClutterShader *self, g_assert (shader != COGL_INVALID_HANDLE); cogl_shader_compile (shader); - cogl_shader_get_parameteriv (shader, - CGL_OBJECT_COMPILE_STATUS, - &is_compiled); - - if (is_compiled != CGL_TRUE) + if (!cogl_shader_is_compiled (shader)) { gchar error_buf[512]; @@ -739,7 +734,7 @@ clutter_shader_set_uniform (ClutterShader *shader, } else if (CLUTTER_VALUE_HOLDS_SHADER_INT (value)) { - const COGLint *ints; + const int *ints; ints = clutter_value_get_shader_int (value, &size); cogl_program_uniform_int (location, size, 1, ints); @@ -759,7 +754,7 @@ clutter_shader_set_uniform (ClutterShader *shader, } else if (G_VALUE_HOLDS_INT (value)) { - COGLint int_val = g_value_get_int (value); + int int_val = g_value_get_int (value); cogl_program_uniform_int (location, 1, 1, &int_val); } diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index bb7a001f2..b44d57d8a 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -187,18 +187,18 @@ clutter_texture_quality_to_filters (ClutterTextureQuality quality, switch (quality) { case CLUTTER_TEXTURE_QUALITY_LOW: - min_filter = CGL_NEAREST; - mag_filter = CGL_NEAREST; + min_filter = COGL_TEXTURE_FILTER_NEAREST; + mag_filter = COGL_TEXTURE_FILTER_NEAREST; break; case CLUTTER_TEXTURE_QUALITY_MEDIUM: - min_filter = CGL_LINEAR; - mag_filter = CGL_LINEAR; + min_filter = COGL_TEXTURE_FILTER_LINEAR; + mag_filter = COGL_TEXTURE_FILTER_LINEAR; break; case CLUTTER_TEXTURE_QUALITY_HIGH: - min_filter = CGL_LINEAR_MIPMAP_LINEAR; - mag_filter = CGL_LINEAR; + min_filter = COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR; + mag_filter = COGL_TEXTURE_FILTER_LINEAR; break; } @@ -1891,7 +1891,7 @@ clutter_texture_async_load (ClutterTexture *self, * If #ClutterTexture:load-async is set to %TRUE, this function * will return as soon as possible, and the actual image loading * from disk will be performed asynchronously. #ClutterTexture::size-change - * will be emitten when the size of the texture is available and + * will be emitten when the size of the texture is available and * #ClutterTexture::load-finished will be emitted when the image has been * loaded or if an error occurred. * diff --git a/clutter/cogl/cogl-shader.h b/clutter/cogl/cogl-shader.h index cd0bc8c8b..59c75ede6 100644 --- a/clutter/cogl/cogl-shader.h +++ b/clutter/cogl/cogl-shader.h @@ -42,6 +42,17 @@ G_BEGIN_DECLS * The only supported format is GLSL shaders. */ +/** + * CoglShaderType: + * @COGL_SHADER_TYPE_VERTEX: A program for proccessing vertices + * @COGL_SHADER_TYPE_FRAGMENT: A program for processing fragments + */ +typedef enum _CoglShaderType +{ + COGL_SHADER_TYPE_VERTEX, + COGL_SHADER_TYPE_FRAGMENT +} CoglShaderType; + /** * cogl_create_shader: * @shader_type: CGL_VERTEX_SHADER or CGL_FRAGMENT_SHADER. @@ -51,7 +62,7 @@ G_BEGIN_DECLS * * Returns: a new shader handle. */ -CoglHandle cogl_create_shader (COGLenum shader_type); +CoglHandle cogl_create_shader (CoglShaderType shader_type); /** * cogl_shader_ref: @@ -91,8 +102,8 @@ gboolean cogl_is_shader (CoglHandle handle); * Replaces the current GLSL source associated with a shader with a new * one. */ -void cogl_shader_source (CoglHandle shader, - const gchar *source); +void cogl_shader_source (CoglHandle shader, + const char *source); /** * cogl_shader_compile: * @handle: #CoglHandle for a shader. @@ -113,22 +124,26 @@ void cogl_shader_compile (CoglHandle handle); * messages that caused a shader to not compile correctly, mainly useful for * debugging purposes. */ -void cogl_shader_get_info_log (CoglHandle handle, - guint size, - gchar *buffer); +void cogl_shader_get_info_log (CoglHandle handle, + size_t size, + char *buffer); /** - * cogl_shader_get_parameteriv: + * cogl_shader_get_type: * @handle: #CoglHandle for a shader. - * @pname: the named COGL parameter to retrieve. - * @dest: storage location for COGLint return value. * - * Retrieve a named parameter from a shader can be used to query to compile - * satus of a shader by passing in CGL_OBJECT_COMPILE_STATUS for @pname. + * Returns: COGL_SHADER_TYPE_VERTEX if the shader is a vertex processor + * or COGL_SHADER_TYPE_FRAGMENT if the shader is a frament processor */ -void cogl_shader_get_parameteriv (CoglHandle handle, - COGLenum pname, - COGLint *dest); +CoglShaderType cogl_shader_get_type (CoglHandle handle); + +/** + * cogl_shader_is_compiled: + * @handle: #CoglHandle for a shader. + * + * Returns: TRUE if the shader object has sucessfully be compiled else FALSE + */ +gboolean cogl_shader_is_compiled (CoglHandle handle); /** * cogl_create_program: @@ -213,9 +228,9 @@ void cogl_program_use (CoglHandle handle); * This uniform can be set using cogl_program_uniform_1f() when the * program is in use. */ -COGLint cogl_program_get_uniform_location - (CoglHandle handle, - const gchar *uniform_name); +int cogl_program_get_uniform_location + (CoglHandle handle, + const char *uniform_name); /** * cogl_program_uniform_1f: @@ -225,8 +240,8 @@ COGLint cogl_program_get_uniform_location * Changes the value of a floating point uniform in the currently * used (see cogl_program_use()) shader program. */ -void cogl_program_uniform_1f (COGLint uniform_no, - gfloat value); +void cogl_program_uniform_1f (int uniform_no, + float value); /** * cogl_program_uniform_1i: @@ -236,8 +251,8 @@ void cogl_program_uniform_1f (COGLint uniform_no, * Changes the value of an integer uniform in the currently * used (see cogl_program_use()) shader program. */ -void cogl_program_uniform_1i (COGLint uniform_no, - gint value); +void cogl_program_uniform_1i (int uniform_no, + int value); /** * cogl_program_uniform_float: @@ -249,9 +264,9 @@ void cogl_program_uniform_1i (COGLint uniform_no, * Changes the value of a float vector uniform, or uniform array in the * currently used (see #cogl_program_use) shader program. */ -void cogl_program_uniform_float (COGLint uniform_no, - gint size, - gint count, +void cogl_program_uniform_float (int uniform_no, + int size, + int count, const GLfloat *value); /** @@ -264,10 +279,10 @@ void cogl_program_uniform_float (COGLint uniform_no, * Changes the value of a int vector uniform, or uniform array in the * currently used (see cogl_program_use()) shader program. */ -void cogl_program_uniform_int (COGLint uniform_no, - gint size, - gint count, - const COGLint *value); +void cogl_program_uniform_int (int uniform_no, + int size, + int count, + const int *value); /** * cogl_program_uniform_matrix: @@ -281,11 +296,11 @@ void cogl_program_uniform_int (COGLint uniform_no, * currently used (see cogl_program_use()) shader program. The @size * parameter is used to determine the square size of the matrix. */ -void cogl_program_uniform_matrix (COGLint uniform_no, - gint size, - gint count, - gboolean transpose, - const GLfloat *value); +void cogl_program_uniform_matrix (int uniform_no, + int size, + int count, + gboolean transpose, + const float *value); G_END_DECLS diff --git a/clutter/cogl/cogl-texture.h b/clutter/cogl/cogl-texture.h index c63041bbd..6a8b00a01 100644 --- a/clutter/cogl/cogl-texture.h +++ b/clutter/cogl/cogl-texture.h @@ -228,6 +228,52 @@ guint cogl_texture_get_rowstride (CoglHandle handle); */ gint cogl_texture_get_max_waste (CoglHandle handle); +/** + * CoglTextureFilter: + * @COGL_TEXTURE_FILTER_NEAREST: Measuring in manhatten distance from the, + * current pixel center, use the nearest texture + * texel. + * @COGL_TEXTURE_FILTER_LINEAR: Use the weighted average of the 4 texels + * nearest the current pixel center. + * @COGL_TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST: Select the mimap level whose + * texel size most closely matches + * the current pixel, and use the + * COGL_TEXTURE_FILTER_NEAREST + * criterion. + * @COGL_TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST: Select the mimap level whose + * texel size most closely matches + * the current pixel, and use the + * COGL_TEXTURE_FILTER_LINEAR + * criterion. + * @COGL_TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR: Select the two mimap levels + * whose texel size most closely + * matches the current pixel, use + * the COGL_TEXTURE_FILTER_NEAREST + * criterion on each one and take + * their weighted average. + * @COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR: Select the two mimap levels + * whose texel size most closely + * matches the current pixel, use + * the COGL_TEXTURE_FILTER_LINEAR + * criterion on each one and take + * their weighted average. + * + * Texture filtering is used whenever the current pixel maps either to more + * than one texture element (texel) or less than one. These filter enums + * correspond to different strategies used to come up with a pixel color, by + * possibly referring to multiple neighbouring texels and taking a weighted + * average or simply using the nearest texel. + */ +typedef enum _CoglTextureFilter +{ + COGL_TEXTURE_FILTER_NEAREST = GL_NEAREST, + COGL_TEXTURE_FILTER_LINEAR = GL_LINEAR, + COGL_TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST = GL_NEAREST_MIPMAP_NEAREST, + COGL_TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST = GL_LINEAR_MIPMAP_NEAREST, + COGL_TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR = GL_NEAREST_MIPMAP_LINEAR, + COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR = GL_LINEAR_MIPMAP_LINEAR +} CoglTextureFilter; + /** * cogl_texture_get_min_filter: * @handle: a #CoglHandle for a texture. @@ -236,7 +282,7 @@ gint cogl_texture_get_max_waste (CoglHandle handle); * * Returns: the current downscaling filter for a cogl texture. */ -COGLenum cogl_texture_get_min_filter (CoglHandle handle); +CoglTextureFilter cogl_texture_get_min_filter (CoglHandle handle); /** * cogl_texture_get_mag_filter: @@ -246,7 +292,7 @@ COGLenum cogl_texture_get_min_filter (CoglHandle handle); * * Returns: the current downscaling filter for a cogl texture. */ -COGLenum cogl_texture_get_mag_filter (CoglHandle handle); +CoglTextureFilter cogl_texture_get_mag_filter (CoglHandle handle); /** * cogl_texture_is_sliced: @@ -307,8 +353,8 @@ gint cogl_texture_get_data (CoglHandle handle, * drawn at other scales than 100%. */ void cogl_texture_set_filters (CoglHandle handle, - COGLenum min_filter, - COGLenum mag_filter); + CoglTextureFilter min_filter, + CoglTextureFilter mag_filter); /** diff --git a/clutter/cogl/gl/cogl-defines.h.in b/clutter/cogl/gl/cogl-defines.h.in index 100cd74a0..8e2df9ec3 100644 --- a/clutter/cogl/gl/cogl-defines.h.in +++ b/clutter/cogl/gl/cogl-defines.h.in @@ -29,10 +29,6 @@ G_BEGIN_DECLS -typedef GLenum COGLenum; -typedef GLint COGLint; -typedef GLuint COGLuint; - /* FIXME + DOCUMENT */ #define COPENSTEP OPENSTEP @@ -226,7 +222,6 @@ typedef GLuint COGLuint; #define CGL_FOG_INDEX GL_FOG_INDEX #define CGL_FOG_START GL_FOG_START #define CGL_FOG_END GL_FOG_END -#define CGL_LINEAR GL_LINEAR #define CGL_EXP GL_EXP #define CGL_LOGIC_OP GL_LOGIC_OP #define CGL_INDEX_LOGIC_OP GL_INDEX_LOGIC_OP @@ -419,10 +414,6 @@ typedef GLuint COGLuint; #define CGL_TEXTURE_ALPHA_SIZE GL_TEXTURE_ALPHA_SIZE #define CGL_TEXTURE_LUMINANCE_SIZE GL_TEXTURE_LUMINANCE_SIZE #define CGL_TEXTURE_INTENSITY_SIZE GL_TEXTURE_INTENSITY_SIZE -#define CGL_NEAREST_MIPMAP_NEAREST GL_NEAREST_MIPMAP_NEAREST -#define CGL_NEAREST_MIPMAP_LINEAR GL_NEAREST_MIPMAP_LINEAR -#define CGL_LINEAR_MIPMAP_NEAREST GL_LINEAR_MIPMAP_NEAREST -#define CGL_LINEAR_MIPMAP_LINEAR GL_LINEAR_MIPMAP_LINEAR #define CGL_OBJECT_LINEAR GL_OBJECT_LINEAR #define CGL_OBJECT_PLANE GL_OBJECT_PLANE #define CGL_EYE_LINEAR GL_EYE_LINEAR @@ -430,7 +421,6 @@ typedef GLuint COGLuint; #define CGL_SPHERE_MAP GL_SPHERE_MAP #define CGL_DECAL GL_DECAL #define CGL_MODULATE GL_MODULATE -#define CGL_NEAREST GL_NEAREST #define CGL_REPEAT GL_REPEAT #define CGL_CLAMP GL_CLAMP #define CGL_S GL_S @@ -692,9 +682,6 @@ typedef GLuint COGLuint; #define CGL_UNSIGNED_SHORT_8_8_MESA 0 #endif -#define CGL_FRAGMENT_SHADER GL_FRAGMENT_SHADER_ARB -#define CGL_VERTEX_SHADER GL_VERTEX_SHADER_ARB - #define CGL_OBJECT_COMPILE_STATUS GL_OBJECT_COMPILE_STATUS_ARB #define CLUTTER_COGL_HAS_GL 1 diff --git a/clutter/cogl/gl/cogl-program.c b/clutter/cogl/gl/cogl-program.c index 1f652c95e..0a10cd4c4 100644 --- a/clutter/cogl/gl/cogl-program.c +++ b/clutter/cogl/gl/cogl-program.c @@ -139,7 +139,7 @@ cogl_program_use (CoglHandle handle) glUseProgramObjectARB (gl_handle); } -COGLint +int cogl_program_get_uniform_location (CoglHandle handle, const gchar *uniform_name) { @@ -155,7 +155,7 @@ cogl_program_get_uniform_location (CoglHandle handle, } void -cogl_program_uniform_1f (COGLint uniform_no, +cogl_program_uniform_1f (int uniform_no, gfloat value) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -163,7 +163,7 @@ cogl_program_uniform_1f (COGLint uniform_no, } void -cogl_program_uniform_1i (COGLint uniform_no, +cogl_program_uniform_1i (int uniform_no, gint value) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -171,7 +171,7 @@ cogl_program_uniform_1i (COGLint uniform_no, } void -cogl_program_uniform_float (COGLint uniform_no, +cogl_program_uniform_float (int uniform_no, gint size, gint count, const GLfloat *value) @@ -198,10 +198,10 @@ cogl_program_uniform_float (COGLint uniform_no, } void -cogl_program_uniform_int (COGLint uniform_no, +cogl_program_uniform_int (int uniform_no, gint size, gint count, - const COGLint *value) + const int *value) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -225,7 +225,7 @@ cogl_program_uniform_int (COGLint uniform_no, } void -cogl_program_uniform_matrix (COGLint uniform_no, +cogl_program_uniform_matrix (int uniform_no, gint size, gint count, gboolean transpose, diff --git a/clutter/cogl/gl/cogl-shader.c b/clutter/cogl/gl/cogl-shader.c index 0d0896c09..944e6736f 100644 --- a/clutter/cogl/gl/cogl-shader.c +++ b/clutter/cogl/gl/cogl-shader.c @@ -55,21 +55,33 @@ _cogl_shader_free (CoglShader *shader) } CoglHandle -cogl_create_shader (COGLenum shaderType) +cogl_create_shader (CoglShaderType type) { CoglShader *shader; + GLenum gl_type; - _COGL_GET_CONTEXT (ctx, 0); + _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); + + if (type == COGL_SHADER_TYPE_VERTEX) + gl_type = GL_VERTEX_SHADER; + else if (type == COGL_SHADER_TYPE_FRAGMENT) + gl_type = GL_FRAGMENT_SHADER; + else + { + g_warning ("Unexpected shader type (0x%08lX) given to " + "cogl_create_shader", (unsigned long) type); + return COGL_INVALID_HANDLE; + } shader = g_slice_new (CoglShader); - shader->gl_handle = glCreateShaderObjectARB (shaderType); + shader->gl_handle = glCreateShaderObjectARB (gl_type); return _cogl_shader_handle_new (shader); } void cogl_shader_source (CoglHandle handle, - const gchar *source) + const char *source) { CoglShader *shader; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -98,11 +110,11 @@ cogl_shader_compile (CoglHandle handle) void cogl_shader_get_info_log (CoglHandle handle, - guint size, - gchar *buffer) + size_t size, + char *buffer) { CoglShader *shader; - COGLint len; + int len; _COGL_GET_CONTEXT (ctx, NO_RETVAL); if (!cogl_is_shader (handle)) @@ -114,18 +126,51 @@ cogl_shader_get_info_log (CoglHandle handle, buffer[len]='\0'; } -void -cogl_shader_get_parameteriv (CoglHandle handle, - COGLenum pname, - COGLint *dest) +CoglShaderType +cogl_shader_get_type (CoglHandle handle) { + GLint type; CoglShader *shader; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + + _COGL_GET_CONTEXT (ctx, COGL_SHADER_TYPE_VERTEX); if (!cogl_is_shader (handle)) - return; + { + g_warning ("Non shader handle type passed to cogl_shader_get_type"); + return COGL_SHADER_TYPE_VERTEX; + } shader = _cogl_shader_pointer_from_handle (handle); - glGetObjectParameterivARB (shader->gl_handle, pname, dest); + GE (glGetObjectParameterivARB (shader->gl_handle, GL_SHADER_TYPE, &type)); + if (type == GL_VERTEX_SHADER) + return COGL_SHADER_TYPE_VERTEX; + else if (type == GL_FRAGMENT_SHADER) + return COGL_SHADER_TYPE_VERTEX; + else + { + g_warning ("Unexpected shader type 0x%08lX", (unsigned long)type); + return COGL_SHADER_TYPE_VERTEX; + } } + +gboolean +cogl_shader_is_compiled (CoglHandle handle) +{ + GLint status; + CoglShader *shader; + + _COGL_GET_CONTEXT (ctx, FALSE); + + if (!cogl_is_shader (handle)) + return FALSE; + + shader = _cogl_shader_pointer_from_handle (handle); + + GE (glGetObjectParameterivARB (shader->gl_handle, GL_COMPILE_STATUS, &status)); + if (status == GL_TRUE) + return TRUE; + else + return FALSE; +} + diff --git a/clutter/cogl/gl/cogl-texture-private.h b/clutter/cogl/gl/cogl-texture-private.h index cd60528e4..7cf6fe951 100644 --- a/clutter/cogl/gl/cogl-texture-private.h +++ b/clutter/cogl/gl/cogl-texture-private.h @@ -68,8 +68,8 @@ struct _CoglTexture GArray *slice_y_spans; GArray *slice_gl_handles; gint max_waste; - COGLenum min_filter; - COGLenum mag_filter; + CoglTextureFilter min_filter; + CoglTextureFilter mag_filter; gboolean is_foreign; GLint wrap_mode; gboolean auto_mipmap; diff --git a/clutter/cogl/gl/cogl-texture.c b/clutter/cogl/gl/cogl-texture.c index 8fb4980f5..cd02bc719 100644 --- a/clutter/cogl/gl/cogl-texture.c +++ b/clutter/cogl/gl/cogl-texture.c @@ -1247,8 +1247,8 @@ cogl_texture_new_with_size (guint width, tex->slice_gl_handles = NULL; tex->max_waste = max_waste; - tex->min_filter = CGL_NEAREST; - tex->mag_filter = CGL_NEAREST; + tex->min_filter = COGL_TEXTURE_FILTER_NEAREST; + tex->mag_filter = COGL_TEXTURE_FILTER_NEAREST; /* Find closest GL format match */ tex->bitmap.format = @@ -1308,8 +1308,8 @@ cogl_texture_new_from_data (guint width, tex->slice_gl_handles = NULL; tex->max_waste = max_waste; - tex->min_filter = CGL_NEAREST; - tex->mag_filter = CGL_NEAREST; + tex->min_filter = COGL_TEXTURE_FILTER_NEAREST; + tex->mag_filter = COGL_TEXTURE_FILTER_NEAREST; /* FIXME: If upload fails we should set some kind of * error flag but still return texture handle (this @@ -1365,8 +1365,8 @@ cogl_texture_new_from_bitmap (CoglHandle bmp_handle, tex->slice_gl_handles = NULL; tex->max_waste = max_waste; - tex->min_filter = CGL_NEAREST; - tex->mag_filter = CGL_NEAREST; + tex->min_filter = COGL_TEXTURE_FILTER_NEAREST; + tex->mag_filter = COGL_TEXTURE_FILTER_NEAREST; /* FIXME: If upload fails we should set some kind of * error flag but still return texture handle if the @@ -1693,7 +1693,7 @@ cogl_texture_get_gl_texture (CoglHandle handle, return TRUE; } -COGLenum +CoglTextureFilter cogl_texture_get_min_filter (CoglHandle handle) { CoglTexture *tex; @@ -1706,7 +1706,7 @@ cogl_texture_get_min_filter (CoglHandle handle) return tex->min_filter; } -COGLenum +CoglTextureFilter cogl_texture_get_mag_filter (CoglHandle handle) { CoglTexture *tex; @@ -1721,8 +1721,8 @@ cogl_texture_get_mag_filter (CoglHandle handle) void cogl_texture_set_filters (CoglHandle handle, - COGLenum min_filter, - COGLenum mag_filter) + CoglTextureFilter min_filter, + CoglTextureFilter mag_filter) { CoglTexture *tex; GLuint gl_handle; diff --git a/clutter/cogl/gles/cogl-defines.h.in b/clutter/cogl/gles/cogl-defines.h.in index d6010509b..2a356e873 100644 --- a/clutter/cogl/gles/cogl-defines.h.in +++ b/clutter/cogl/gles/cogl-defines.h.in @@ -430,10 +430,6 @@ G_BEGIN_DECLS #define CGL_WEIGHT_ARRAY_BUFFER_BINDING_OES GL_WEIGHT_ARRAY_BUFFER_BINDING_OES #define CGL_TEXTURE_CROP_RECT_OES GL_TEXTURE_CROP_RECT_OES -typedef GLenum COGLenum; -typedef GLint COGLint; -typedef GLuint COGLuint; - /* extras */ /* YUV textures also unsupported */ @@ -441,18 +437,6 @@ typedef GLuint COGLuint; #define CGL_UNSIGNED_SHORT_8_8_REV_MESA 0 #define CGL_UNSIGNED_SHORT_8_8_MESA 0 -#ifdef GL_FRAGMENT_SHADER -#define CGL_FRAGMENT_SHADER GL_FRAGMENT_SHADER -#else -#define CGL_FRAGMENT_SHADER 0 -#endif - -#ifdef GL_VERTEX_SHADER -#define CGL_VERTEX_SHADER GL_VERTEX_SHADER -#else -#define CGL_VERTEX_SHADER 0 -#endif - #if defined(GL_OBJECT_COMPILE_STATUS) #define CGL_OBJECT_COMPILE_STATUS GL_OBJECT_COMPILE_STATUS #elif defined(GL_COMPILE_STATUS) diff --git a/clutter/cogl/gles/cogl-program.c b/clutter/cogl/gles/cogl-program.c index 317310c32..e8fc6a0f0 100644 --- a/clutter/cogl/gles/cogl-program.c +++ b/clutter/cogl/gles/cogl-program.c @@ -122,7 +122,7 @@ cogl_program_use (CoglHandle handle) ctx->gles2.settings_dirty = TRUE; } -COGLint +int cogl_program_get_uniform_location (CoglHandle handle, const gchar *uniform_name) { @@ -155,21 +155,21 @@ cogl_program_get_uniform_location (CoglHandle handle, } void -cogl_program_uniform_1f (COGLint uniform_no, +cogl_program_uniform_1f (int uniform_no, gfloat value) { cogl_program_uniform_float (uniform_no, 1, 1, &value); } void -cogl_program_uniform_1i (COGLint uniform_no, +cogl_program_uniform_1i (int uniform_no, gint value) { cogl_program_uniform_int (uniform_no, 1, 1, &value); } static void -cogl_program_uniform_x (COGLint uniform_no, +cogl_program_uniform_x (int uniform_no, gint size, gint count, CoglBoxedType type, @@ -215,7 +215,7 @@ cogl_program_uniform_x (COGLint uniform_no, } void -cogl_program_uniform_float (COGLint uniform_no, +cogl_program_uniform_float (int uniform_no, gint size, gint count, const GLfloat *value) @@ -225,7 +225,7 @@ cogl_program_uniform_float (COGLint uniform_no, } void -cogl_program_uniform_int (COGLint uniform_no, +cogl_program_uniform_int (int uniform_no, gint size, gint count, const GLint *value) @@ -235,7 +235,7 @@ cogl_program_uniform_int (COGLint uniform_no, } void -cogl_program_uniform_matrix (COGLint uniform_no, +cogl_program_uniform_matrix (int uniform_no, gint size, gint count, gboolean transpose, @@ -296,7 +296,7 @@ cogl_program_use (CoglHandle program_handle) { } -COGLint +int cogl_program_get_uniform_location (CoglHandle program_handle, const gchar *uniform_name) { @@ -304,13 +304,13 @@ cogl_program_get_uniform_location (CoglHandle program_handle, } void -cogl_program_uniform_1f (COGLint uniform_no, +cogl_program_uniform_1f (int uniform_no, gfloat value) { } void -cogl_program_uniform_float (COGLint uniform_no, +cogl_program_uniform_float (int uniform_no, gint size, gint count, const GLfloat *value) @@ -318,15 +318,15 @@ cogl_program_uniform_float (COGLint uniform_no, } void -cogl_program_uniform_int (COGLint uniform_no, +cogl_program_uniform_int (int uniform_no, gint size, gint count, - const COGLint *value) + const int *value) { } void -cogl_program_uniform_matrix (COGLint uniform_no, +cogl_program_uniform_matrix (int uniform_no, gint size, gint count, gboolean transpose, diff --git a/clutter/cogl/gles/cogl-shader.c b/clutter/cogl/gles/cogl-shader.c index d261e1a0b..ff5f0c58a 100644 --- a/clutter/cogl/gles/cogl-shader.c +++ b/clutter/cogl/gles/cogl-shader.c @@ -48,22 +48,31 @@ _cogl_shader_free (CoglShader *shader) } CoglHandle -cogl_create_shader (COGLenum shaderType) +cogl_create_shader (CoglShaderType type) { CoglShader *shader; + GLenum gl_type; - _COGL_GET_CONTEXT (ctx, 0); + if (type == COGL_SHADER_TYPE_VERTEX) + gl_type = GL_VERTEX_SHADER; + else if (type == COGL_SHADER_TYPE_FRAGMENT) + gl_type = GL_FRAGMENT_SHADER; + else + { + g_warning ("Unexpected shader type (0x%08lX) given to " + "cogl_create_shader", (unsigned long) type); + return COGL_INVALID_HANDLE; + } shader = g_slice_new (CoglShader); - shader->gl_handle = glCreateShader (shaderType); - shader->type = shaderType; + shader->gl_handle = glCreateShader (gl_type); return _cogl_shader_handle_new (shader); } void cogl_shader_source (CoglHandle handle, - const gchar *source) + const char *source) { CoglShader *shader; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -92,11 +101,11 @@ cogl_shader_compile (CoglHandle handle) void cogl_shader_get_info_log (CoglHandle handle, - guint size, - gchar *buffer) + size_t size, + char *buffer) { CoglShader *shader; - COGLint len = 0; + int len = 0; _COGL_GET_CONTEXT (ctx, NO_RETVAL); if (!cogl_is_shader (handle)) @@ -108,20 +117,48 @@ cogl_shader_get_info_log (CoglHandle handle, buffer[len] = '\0'; } -void -cogl_shader_get_parameteriv (CoglHandle handle, - COGLenum pname, - COGLint *dest) +CoglShaderType +cogl_shader_get_type (CoglHandle handle) { + GLint type; CoglShader *shader; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); if (!cogl_is_shader (handle)) - return; + { + g_warning ("Non shader handle type passed to cogl_shader_get_type"); + return COGL_SHADER_TYPE_VERTEX; + } shader = _cogl_shader_pointer_from_handle (handle); - glGetShaderiv (shader->gl_handle, pname, dest); + GE (glGetShaderiv (shader->gl_handle, GL_SHADER_TYPE, &type)); + if (type == GL_VERTEX_SHADER) + return COGL_SHADER_TYPE_VERTEX; + else if (type == GL_FRAGMENT_SHADER) + return COGL_SHADER_TYPE_VERTEX; + else + { + g_warning ("Unexpected shader type 0x%08lX", (unsigned long)type); + return COGL_SHADER_TYPE_VERTEX; + } +} + +gboolean +cogl_shader_is_compiled (CoglHandle handle) +{ + GLint status; + CoglShader *shader; + + if (!cogl_is_shader (handle)) + return FALSE; + + shader = _cogl_shader_pointer_from_handle (handle); + + GE (glGetShaderiv (shader->gl_handle, GL_COMPILE_STATUS, &status)); + if (status == GL_TRUE) + return TRUE; + else + return FALSE; } #else /* HAVE_COGL_GLES2 */ @@ -129,7 +166,7 @@ cogl_shader_get_parameteriv (CoglHandle handle, /* No support on regular OpenGL 1.1 */ CoglHandle -cogl_create_shader (COGLenum shaderType) +cogl_create_shader (CoglShaderType type) { return COGL_INVALID_HANDLE; } @@ -153,7 +190,7 @@ cogl_shader_unref (CoglHandle handle) void cogl_shader_source (CoglHandle shader, - const gchar *source) + const char *source) { } @@ -164,16 +201,21 @@ cogl_shader_compile (CoglHandle shader_handle) void cogl_shader_get_info_log (CoglHandle handle, - guint size, - gchar *buffer) + size_t size, + char *buffer) { } -void -cogl_shader_get_parameteriv (CoglHandle handle, - COGLenum pname, - COGLint *dest) +CoglShaderType +cogl_shader_get_type (CoglHandle handle) { + return COGL_SHADER_TYPE_VERTEX; +} + +gboolean +cogl_shader_is_compiled (CoglHandle handle) +{ + return FALSE; } #endif /* HAVE_COGL_GLES2 */ diff --git a/clutter/cogl/gles/cogl-texture-private.h b/clutter/cogl/gles/cogl-texture-private.h index cd60528e4..7cf6fe951 100644 --- a/clutter/cogl/gles/cogl-texture-private.h +++ b/clutter/cogl/gles/cogl-texture-private.h @@ -68,8 +68,8 @@ struct _CoglTexture GArray *slice_y_spans; GArray *slice_gl_handles; gint max_waste; - COGLenum min_filter; - COGLenum mag_filter; + CoglTextureFilter min_filter; + CoglTextureFilter mag_filter; gboolean is_foreign; GLint wrap_mode; gboolean auto_mipmap; diff --git a/clutter/cogl/gles/cogl-texture.c b/clutter/cogl/gles/cogl-texture.c index 0954798d9..ce5d4fe26 100644 --- a/clutter/cogl/gles/cogl-texture.c +++ b/clutter/cogl/gles/cogl-texture.c @@ -1778,7 +1778,7 @@ cogl_texture_get_gl_texture (CoglHandle handle, return TRUE; } -COGLenum +CoglTextureFilter cogl_texture_get_min_filter (CoglHandle handle) { CoglTexture *tex; @@ -1791,7 +1791,7 @@ cogl_texture_get_min_filter (CoglHandle handle) return tex->min_filter; } -COGLenum +CoglTextureFilter cogl_texture_get_mag_filter (CoglHandle handle) { CoglTexture *tex; @@ -1806,8 +1806,8 @@ cogl_texture_get_mag_filter (CoglHandle handle) void cogl_texture_set_filters (CoglHandle handle, - COGLenum min_filter, - COGLenum mag_filter) + CoglTextureFilter min_filter, + CoglTextureFilter mag_filter) { CoglTexture *tex; GLuint gl_handle; diff --git a/clutter/glx/clutter-glx-texture-pixmap.c b/clutter/glx/clutter-glx-texture-pixmap.c index 4a41070b5..c2f5aadcc 100644 --- a/clutter/glx/clutter-glx-texture-pixmap.c +++ b/clutter/glx/clutter-glx-texture-pixmap.c @@ -25,7 +25,7 @@ * Boston, MA 02111-1307, USA. */ -/* TODO: +/* TODO: * - Automagically handle named pixmaps, and window resizes (i.e * essentially handle window id's being passed in) ? */ @@ -94,8 +94,6 @@ static RectangleState _rectangle_state = CLUTTER_GLX_RECTANGLE_ALLOW; struct _ClutterGLXTexturePixmapPrivate { - COGLenum target_type; - guint texture_id; GLXPixmap glx_pixmap; gboolean use_fallback; @@ -107,14 +105,14 @@ struct _ClutterGLXTexturePixmapPrivate gboolean using_rectangle; }; -static void +static void clutter_glx_texture_pixmap_update_area (ClutterX11TexturePixmap *texture, gint x, gint y, gint width, gint height); -static void +static void clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *tex); static ClutterX11TexturePixmapClass *parent_class = NULL; @@ -137,12 +135,12 @@ texture_bind (ClutterGLXTexturePixmap *tex) /* FIXME: fire off an error here? */ glBindTexture (target, handle); - if (clutter_texture_get_filter_quality (CLUTTER_TEXTURE (tex)) + if (clutter_texture_get_filter_quality (CLUTTER_TEXTURE (tex)) == CLUTTER_TEXTURE_QUALITY_HIGH && tex->priv->can_mipmap) { - cogl_texture_set_filters (cogl_tex, - CGL_LINEAR_MIPMAP_LINEAR, - CGL_LINEAR); + cogl_texture_set_filters (cogl_tex, + COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR, + COGL_TEXTURE_FILTER_LINEAR); } return TRUE; @@ -157,13 +155,13 @@ on_glx_texture_pixmap_pre_paint (ClutterGLXTexturePixmap *texture, GLuint handle = 0; GLenum target = 0; CoglHandle cogl_tex; - cogl_tex = clutter_texture_get_cogl_texture + cogl_tex = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE(texture)); texture_bind (texture); cogl_texture_get_gl_texture (cogl_tex, &handle, &target); - + _gl_generate_mipmap (target); texture->priv->mipmap_generate_queued = 0; @@ -408,11 +406,11 @@ clutter_glx_texture_pixmap_realize (ClutterActor *actor) "pixmap-width", &pixmap_width, "pixmap-height", &pixmap_height, NULL); - + if (!pixmap) return; - if (!create_cogl_texture (CLUTTER_TEXTURE (actor), + if (!create_cogl_texture (CLUTTER_TEXTURE (actor), pixmap_width, pixmap_height)) { CLUTTER_NOTE (TEXTURE, "Unable to create a valid pixmap"); @@ -460,7 +458,7 @@ clutter_glx_texture_pixmap_unrealize (ClutterActor *actor) priv->bound = FALSE; } - + CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED); } @@ -739,8 +737,8 @@ clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *texture) if (glx_pixmap != None) { priv->glx_pixmap = glx_pixmap; - - create_cogl_texture (CLUTTER_TEXTURE (texture), + + create_cogl_texture (CLUTTER_TEXTURE (texture), pixmap_width, pixmap_height); CLUTTER_NOTE (TEXTURE, "Created GLXPixmap"); @@ -762,7 +760,7 @@ clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *texture) priv->glx_pixmap = None; /* Some fucky logic here - we've fallen back and need to make sure - * we realize here.. + * we realize here.. */ clutter_actor_realize (CLUTTER_ACTOR (texture)); } @@ -800,22 +798,22 @@ clutter_glx_texture_pixmap_update_area (ClutterX11TexturePixmap *texture, if (priv->glx_pixmap == None) return; - + if (texture_bind (CLUTTER_GLX_TEXTURE_PIXMAP(texture))) { CLUTTER_NOTE (TEXTURE, "Really updating via GLX"); clutter_x11_trap_x_errors (); - + (_gl_bind_tex_image) (dpy, priv->glx_pixmap, GLX_FRONT_LEFT_EXT, NULL); - + XSync (clutter_x11_get_default_display(), FALSE); - + /* Note above fires X error for non name pixmaps - but - * things still seem to work - i.e pixmap updated + * things still seem to work - i.e pixmap updated */ if (clutter_x11_untrap_x_errors ()) CLUTTER_NOTE (TEXTURE, "Update bind_tex_image failed"); @@ -829,7 +827,7 @@ clutter_glx_texture_pixmap_update_area (ClutterX11TexturePixmap *texture, { /* FIXME: It may make more sense to set a flag here and only * generate the mipmap on a pre paint.. compressing need - * to call generate mipmap + * to call generate mipmap * May break clones however.. */ priv->mipmap_generate_queued++; @@ -870,7 +868,7 @@ clutter_glx_texture_pixmap_class_init (ClutterGLXTexturePixmapClass *klass) * clutter_glx_texture_pixmap_using_extension: * @texture: A #ClutterGLXTexturePixmap * - * Return value: A boolean indicating if the texture is using the + * Return value: A boolean indicating if the texture is using the * GLX_EXT_texture_from_pixmap OpenGL extension or falling back to * slower software mechanism. * @@ -883,8 +881,8 @@ clutter_glx_texture_pixmap_using_extension (ClutterGLXTexturePixmap *texture) priv = CLUTTER_GLX_TEXTURE_PIXMAP (texture)->priv; - return (_have_tex_from_pixmap_ext && !priv->use_fallback); - /* Assume NPOT TFP's are supported even if regular NPOT isn't advertised + return (_have_tex_from_pixmap_ext && !priv->use_fallback); + /* Assume NPOT TFP's are supported even if regular NPOT isn't advertised * but tfp is. Seemingly some Intel drivers do this ? */ /* && clutter_feature_available (COGL_FEATURE_TEXTURE_NPOT)); */ diff --git a/clutter/pango/cogl-pango-glyph-cache.c b/clutter/pango/cogl-pango-glyph-cache.c index 04e7805e4..892255623 100644 --- a/clutter/pango/cogl-pango-glyph-cache.c +++ b/clutter/pango/cogl-pango-glyph-cache.c @@ -311,12 +311,12 @@ cogl_pango_glyph_cache_set (CoglPangoGlyphCache *cache, if (cache->use_mipmapping) cogl_texture_set_filters (texture->texture, - CGL_LINEAR_MIPMAP_LINEAR, - CGL_LINEAR); + COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR, + COGL_TEXTURE_FILTER_LINEAR); else cogl_texture_set_filters (texture->texture, - CGL_LINEAR, - CGL_LINEAR); + COGL_TEXTURE_FILTER_LINEAR, + COGL_TEXTURE_FILTER_LINEAR); } band = g_slice_new (CoglPangoGlyphCacheBand); diff --git a/doc/reference/cogl/cogl-sections.txt b/doc/reference/cogl/cogl-sections.txt index ff8df1cbc..3032a6863 100644 --- a/doc/reference/cogl/cogl-sections.txt +++ b/doc/reference/cogl/cogl-sections.txt @@ -149,7 +149,8 @@ cogl_is_shader cogl_shader_source cogl_shader_compile cogl_shader_get_info_log -cogl_shader_get_parameteriv +cogl_shader_get_type +cogl_shader_is_compiled cogl_create_program cogl_program_ref diff --git a/tests/interactive/test-cogl-tex-polygon.c b/tests/interactive/test-cogl-tex-polygon.c index c288815a3..0132802a4 100644 --- a/tests/interactive/test-cogl-tex-polygon.c +++ b/tests/interactive/test-cogl-tex-polygon.c @@ -9,7 +9,7 @@ *--------------------------------------------------*/ G_BEGIN_DECLS - + #define TEST_TYPE_COGLBOX test_coglbox_get_type() #define TEST_COGLBOX(obj) \ @@ -44,7 +44,7 @@ struct _TestCoglbox TestCoglboxPrivate *priv; }; -struct _TestCoglboxClass +struct _TestCoglboxClass { ClutterActorClass parent_class; @@ -91,7 +91,7 @@ test_coglbox_fade_texture (CoglHandle tex_id, { CoglTextureVertex vertices[4]; int i; - + vertices[0].x = x1; vertices[0].y = y1; vertices[0].z = 0; @@ -142,7 +142,7 @@ test_coglbox_triangle_texture (CoglHandle tex_id, CoglTextureVertex vertices[3]; int tex_width = cogl_texture_get_width (tex_id); int tex_height = cogl_texture_get_height (tex_id); - + vertices[0].x = x + tx1 * tex_width; vertices[0].y = y + ty1 * tex_height; vertices[0].z = 0; @@ -176,9 +176,11 @@ test_coglbox_paint (ClutterActor *self) cogl_texture_set_filters (tex_handle, priv->use_linear_filtering - ? CGL_LINEAR : CGL_NEAREST, + ? COGL_TEXTURE_FILTER_LINEAR : + COGL_TEXTURE_FILTER_NEAREST, priv->use_linear_filtering - ? CGL_LINEAR : CGL_NEAREST); + ? COGL_TEXTURE_FILTER_LINEAR : + COGL_TEXTURE_FILTER_NEAREST); cogl_push_matrix (); cogl_translate (tex_width / 2, 0, 0); @@ -227,11 +229,11 @@ static void test_coglbox_dispose (GObject *object) { TestCoglboxPrivate *priv; - + priv = TEST_COGLBOX_GET_PRIVATE (object); cogl_handle_unref (priv->not_sliced_tex); cogl_handle_unref (priv->sliced_tex); - + G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object); } @@ -244,7 +246,7 @@ test_coglbox_init (TestCoglbox *self) priv->use_linear_filtering = FALSE; priv->use_sliced = FALSE; - + priv->sliced_tex = cogl_texture_new_from_file ("redhand.png", 10, COGL_TEXTURE_NONE, @@ -286,9 +288,9 @@ test_coglbox_class_init (TestCoglboxClass *klass) ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); gobject_class->finalize = test_coglbox_finalize; - gobject_class->dispose = test_coglbox_dispose; + gobject_class->dispose = test_coglbox_dispose; actor_class->paint = test_coglbox_paint; - + g_type_class_add_private (gobject_class, sizeof (TestCoglboxPrivate)); } @@ -304,7 +306,7 @@ frame_cb (ClutterTimeline *timeline, gpointer data) { TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (data); - + priv->frame = frame_num; clutter_actor_queue_redraw (CLUTTER_ACTOR (data)); } @@ -330,11 +332,11 @@ make_toggle (const char *label_text, gboolean *toggle_val) ClutterActor *group = clutter_group_new (); ClutterActor *label = clutter_text_new_with_text ("Sans 14", label_text); ClutterActor *button = clutter_text_new_with_text ("Sans 14", ""); - + clutter_actor_set_reactive (button, TRUE); update_toggle_text (CLUTTER_TEXT (button), *toggle_val); - + clutter_actor_set_position (button, clutter_actor_get_width (label) + 10, 0); clutter_container_add (CLUTTER_CONTAINER (group), label, button, NULL); @@ -354,19 +356,19 @@ test_cogl_tex_polygon_main (int argc, char *argv[]) ClutterActor *note; ClutterTimeline *timeline; ClutterColor blue = { 0x30, 0x30, 0xff, 0xff }; - + clutter_init (&argc, &argv); - + /* Stage */ stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &blue); clutter_actor_set_size (stage, 640, 480); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test"); - + /* Cogl Box */ coglbox = test_coglbox_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox); - + /* Timeline for animation */ timeline = clutter_timeline_new (360, 60); /* num frames, fps */ g_object_set (timeline, "loop", TRUE, NULL); /* have it loop */ @@ -398,10 +400,10 @@ test_cogl_tex_polygon_main (int argc, char *argv[]) filtering_toggle, note, NULL); - + clutter_actor_show (stage); - + clutter_main (); - + return 0; } diff --git a/tests/interactive/test-cogl-tex-tile.c b/tests/interactive/test-cogl-tex-tile.c index 9a40ae66c..1402d2e28 100644 --- a/tests/interactive/test-cogl-tex-tile.c +++ b/tests/interactive/test-cogl-tex-tile.c @@ -10,7 +10,7 @@ *--------------------------------------------------*/ G_BEGIN_DECLS - + #define TEST_TYPE_COGLBOX test_coglbox_get_type() #define TEST_COGLBOX(obj) \ @@ -45,7 +45,7 @@ struct _TestCoglbox TestCoglboxPrivate *priv; }; -struct _TestCoglboxClass +struct _TestCoglboxClass { ClutterActorClass parent_class; @@ -89,34 +89,34 @@ test_coglbox_paint (ClutterActor *self) sin_frame = sinf ((float) priv->frame); cos_frame = cosf ((float) priv->frame); - + pingpong_frame = (priv->frame <= 180 ? priv->frame : 360 - priv->frame); frac_frame = (float) pingpong_frame / 180.0; frac_frame += 0.5; frac_frame *= 2; - + for (t=0; t<4; t+=2) { texcoords[t] += cos_frame; texcoords[t+1] += sin_frame; - + texcoords[t] = (texcoords[t] * frac_frame); texcoords[t+1] = (texcoords[t+1] * frac_frame); } - + priv = TEST_COGLBOX_GET_PRIVATE (self); - + cogl_push_matrix (); cogl_set_source_color4ub (0x66, 0x66, 0xdd, 0xff); cogl_rectangle (0, 0, 400, 400); - + cogl_translate (100, 100, 0); cogl_set_source_texture (priv->cogl_tex_id); cogl_rectangle_with_texture_coords (0, 0, 200, 213, texcoords[0], texcoords[1], texcoords[2], texcoords[3]); - + cogl_pop_matrix(); } @@ -130,10 +130,10 @@ static void test_coglbox_dispose (GObject *object) { TestCoglboxPrivate *priv; - + priv = TEST_COGLBOX_GET_PRIVATE (object); cogl_handle_unref (priv->cogl_tex_id); - + G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object); } @@ -142,14 +142,15 @@ test_coglbox_init (TestCoglbox *self) { TestCoglboxPrivate *priv; self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self); - + priv->cogl_tex_id = cogl_texture_new_from_file ("redhand.png", 0, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_ANY, NULL); - + cogl_texture_set_filters (priv->cogl_tex_id, - CGL_LINEAR, CGL_LINEAR); + COGL_TEXTURE_FILTER_LINEAR, + COGL_TEXTURE_FILTER_LINEAR); } static void @@ -159,9 +160,9 @@ test_coglbox_class_init (TestCoglboxClass *klass) ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); gobject_class->finalize = test_coglbox_finalize; - gobject_class->dispose = test_coglbox_dispose; + gobject_class->dispose = test_coglbox_dispose; actor_class->paint = test_coglbox_paint; - + g_type_class_add_private (gobject_class, sizeof (TestCoglboxPrivate)); } @@ -177,7 +178,7 @@ frame_cb (ClutterTimeline *timeline, gpointer data) { TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (data); - + priv->frame = frame_num; clutter_actor_queue_redraw (CLUTTER_ACTOR (data)); } @@ -188,27 +189,27 @@ test_cogl_tex_tile_main (int argc, char *argv[]) ClutterActor *stage; ClutterActor *coglbox; ClutterTimeline *timeline; - + clutter_init(&argc, &argv); - + /* Stage */ stage = clutter_stage_get_default (); clutter_actor_set_size (stage, 400, 400); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test"); - + /* Cogl Box */ coglbox = test_coglbox_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox); - + /* Timeline for animation */ timeline = clutter_timeline_new (360, 60); /* num frames, fps */ g_object_set (timeline, "loop", TRUE, NULL); /* have it loop */ g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), coglbox); clutter_timeline_start (timeline); - + clutter_actor_show_all (stage); - + clutter_main (); - + return 0; }