[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.
This commit is contained in:
Robert Bragg 2009-05-12 14:15:18 +01:00
parent cea711cc7e
commit 36cfb60307
22 changed files with 375 additions and 243 deletions

16
README
View File

@ -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 exposing color mask if anyone wants it later. It was assumed that no one was
using this currently. 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 Release Notes for Clutter 0.8
------------------------------- -------------------------------

View File

@ -88,7 +88,7 @@ struct _ClutterShaderFloat
struct _ClutterShaderInt struct _ClutterShaderInt
{ {
gint size; gint size;
COGLint value[4]; int value[4];
}; };
struct _ClutterShaderMatrix struct _ClutterShaderMatrix
@ -223,7 +223,7 @@ clutter_value_collect_shader_int (GValue *value,
guint collect_flags) guint collect_flags)
{ {
gint int_count = collect_values[0].v_int; 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) if (!ints)
return g_strdup_printf ("value location for '%s' passed as NULL", 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) guint collect_flags)
{ {
gint *int_count = collect_values[0].v_pointer; 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; ClutterShaderInt *shader_int = value->data[0].v_pointer;
if (!int_count || !ints) if (!int_count || !ints)
@ -250,7 +250,7 @@ clutter_value_lcopy_shader_int (const GValue *value,
G_VALUE_TYPE_NAME (value)); G_VALUE_TYPE_NAME (value));
*int_count = shader_int->size; *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; return NULL;
} }
@ -514,7 +514,7 @@ clutter_value_get_shader_float (const GValue *value,
* *
* Since: 0.8 * Since: 0.8
*/ */
G_CONST_RETURN COGLint * G_CONST_RETURN int *
clutter_value_get_shader_int (const GValue *value, clutter_value_get_shader_int (const GValue *value,
gsize *length) gsize *length)
{ {

View File

@ -86,7 +86,7 @@ void clutter_value_set_shader_matrix (GValue *value,
const gfloat *matrix); const gfloat *matrix);
G_CONST_RETURN gfloat * clutter_value_get_shader_float (const GValue *value, G_CONST_RETURN gfloat * clutter_value_get_shader_float (const GValue *value,
gsize *length); 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); gsize *length);
G_CONST_RETURN gfloat * clutter_value_get_shader_matrix (const GValue *value, G_CONST_RETURN gfloat * clutter_value_get_shader_matrix (const GValue *value,
gsize *length); gsize *length);

View File

@ -84,7 +84,7 @@ struct _ClutterShaderPrivate
CoglHandle fragment_shader; CoglHandle fragment_shader;
}; };
enum enum
{ {
PROP_0, PROP_0,
@ -126,11 +126,11 @@ clutter_shader_set_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_VERTEX_SOURCE: case PROP_VERTEX_SOURCE:
clutter_shader_set_vertex_source (shader, clutter_shader_set_vertex_source (shader,
g_value_get_string (value), -1); g_value_get_string (value), -1);
break; break;
case PROP_FRAGMENT_SOURCE: case PROP_FRAGMENT_SOURCE:
clutter_shader_set_fragment_source (shader, clutter_shader_set_fragment_source (shader,
g_value_get_string (value), -1); g_value_get_string (value), -1);
break; break;
case PROP_ENABLED: case PROP_ENABLED:
@ -427,20 +427,19 @@ clutter_shader_glsl_bind (ClutterShader *self,
GError **error) GError **error)
{ {
ClutterShaderPrivate *priv = self->priv; ClutterShaderPrivate *priv = self->priv;
GLint is_compiled = CGL_FALSE;
CoglHandle shader = COGL_INVALID_HANDLE; CoglHandle shader = COGL_INVALID_HANDLE;
switch (shader_type) switch (shader_type)
{ {
case CLUTTER_VERTEX_SHADER: 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); cogl_shader_source (shader, priv->vertex_source);
priv->vertex_shader = shader; priv->vertex_shader = shader;
break; break;
case CLUTTER_FRAGMENT_SHADER: 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); cogl_shader_source (shader, priv->fragment_source);
priv->fragment_shader = shader; priv->fragment_shader = shader;
@ -450,11 +449,7 @@ clutter_shader_glsl_bind (ClutterShader *self,
g_assert (shader != COGL_INVALID_HANDLE); g_assert (shader != COGL_INVALID_HANDLE);
cogl_shader_compile (shader); cogl_shader_compile (shader);
cogl_shader_get_parameteriv (shader, if (!cogl_shader_is_compiled (shader))
CGL_OBJECT_COMPILE_STATUS,
&is_compiled);
if (is_compiled != CGL_TRUE)
{ {
gchar error_buf[512]; gchar error_buf[512];
@ -739,7 +734,7 @@ clutter_shader_set_uniform (ClutterShader *shader,
} }
else if (CLUTTER_VALUE_HOLDS_SHADER_INT (value)) else if (CLUTTER_VALUE_HOLDS_SHADER_INT (value))
{ {
const COGLint *ints; const int *ints;
ints = clutter_value_get_shader_int (value, &size); ints = clutter_value_get_shader_int (value, &size);
cogl_program_uniform_int (location, size, 1, ints); 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)) 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); cogl_program_uniform_int (location, 1, 1, &int_val);
} }

View File

@ -187,18 +187,18 @@ clutter_texture_quality_to_filters (ClutterTextureQuality quality,
switch (quality) switch (quality)
{ {
case CLUTTER_TEXTURE_QUALITY_LOW: case CLUTTER_TEXTURE_QUALITY_LOW:
min_filter = CGL_NEAREST; min_filter = COGL_TEXTURE_FILTER_NEAREST;
mag_filter = CGL_NEAREST; mag_filter = COGL_TEXTURE_FILTER_NEAREST;
break; break;
case CLUTTER_TEXTURE_QUALITY_MEDIUM: case CLUTTER_TEXTURE_QUALITY_MEDIUM:
min_filter = CGL_LINEAR; min_filter = COGL_TEXTURE_FILTER_LINEAR;
mag_filter = CGL_LINEAR; mag_filter = COGL_TEXTURE_FILTER_LINEAR;
break; break;
case CLUTTER_TEXTURE_QUALITY_HIGH: case CLUTTER_TEXTURE_QUALITY_HIGH:
min_filter = CGL_LINEAR_MIPMAP_LINEAR; min_filter = COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR;
mag_filter = CGL_LINEAR; mag_filter = COGL_TEXTURE_FILTER_LINEAR;
break; break;
} }
@ -1891,7 +1891,7 @@ clutter_texture_async_load (ClutterTexture *self,
* If #ClutterTexture:load-async is set to %TRUE, this function * If #ClutterTexture:load-async is set to %TRUE, this function
* will return as soon as possible, and the actual image loading * will return as soon as possible, and the actual image loading
* from disk will be performed asynchronously. #ClutterTexture::size-change * 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 * #ClutterTexture::load-finished will be emitted when the image has been
* loaded or if an error occurred. * loaded or if an error occurred.
* *

View File

@ -42,6 +42,17 @@ G_BEGIN_DECLS
* The only supported format is GLSL shaders. * 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: * cogl_create_shader:
* @shader_type: CGL_VERTEX_SHADER or CGL_FRAGMENT_SHADER. * @shader_type: CGL_VERTEX_SHADER or CGL_FRAGMENT_SHADER.
@ -51,7 +62,7 @@ G_BEGIN_DECLS
* *
* Returns: a new shader handle. * Returns: a new shader handle.
*/ */
CoglHandle cogl_create_shader (COGLenum shader_type); CoglHandle cogl_create_shader (CoglShaderType shader_type);
/** /**
* cogl_shader_ref: * 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 * Replaces the current GLSL source associated with a shader with a new
* one. * one.
*/ */
void cogl_shader_source (CoglHandle shader, void cogl_shader_source (CoglHandle shader,
const gchar *source); const char *source);
/** /**
* cogl_shader_compile: * cogl_shader_compile:
* @handle: #CoglHandle for a shader. * @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 * messages that caused a shader to not compile correctly, mainly useful for
* debugging purposes. * debugging purposes.
*/ */
void cogl_shader_get_info_log (CoglHandle handle, void cogl_shader_get_info_log (CoglHandle handle,
guint size, size_t size,
gchar *buffer); char *buffer);
/** /**
* cogl_shader_get_parameteriv: * cogl_shader_get_type:
* @handle: #CoglHandle for a shader. * @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 * Returns: COGL_SHADER_TYPE_VERTEX if the shader is a vertex processor
* satus of a shader by passing in CGL_OBJECT_COMPILE_STATUS for @pname. * or COGL_SHADER_TYPE_FRAGMENT if the shader is a frament processor
*/ */
void cogl_shader_get_parameteriv (CoglHandle handle, CoglShaderType cogl_shader_get_type (CoglHandle handle);
COGLenum pname,
COGLint *dest); /**
* 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: * 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 * This uniform can be set using cogl_program_uniform_1f() when the
* program is in use. * program is in use.
*/ */
COGLint cogl_program_get_uniform_location int cogl_program_get_uniform_location
(CoglHandle handle, (CoglHandle handle,
const gchar *uniform_name); const char *uniform_name);
/** /**
* cogl_program_uniform_1f: * 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 * Changes the value of a floating point uniform in the currently
* used (see cogl_program_use()) shader program. * used (see cogl_program_use()) shader program.
*/ */
void cogl_program_uniform_1f (COGLint uniform_no, void cogl_program_uniform_1f (int uniform_no,
gfloat value); float value);
/** /**
* cogl_program_uniform_1i: * 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 * Changes the value of an integer uniform in the currently
* used (see cogl_program_use()) shader program. * used (see cogl_program_use()) shader program.
*/ */
void cogl_program_uniform_1i (COGLint uniform_no, void cogl_program_uniform_1i (int uniform_no,
gint value); int value);
/** /**
* cogl_program_uniform_float: * 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 * Changes the value of a float vector uniform, or uniform array in the
* currently used (see #cogl_program_use) shader program. * currently used (see #cogl_program_use) shader program.
*/ */
void cogl_program_uniform_float (COGLint uniform_no, void cogl_program_uniform_float (int uniform_no,
gint size, int size,
gint count, int count,
const GLfloat *value); 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 * Changes the value of a int vector uniform, or uniform array in the
* currently used (see cogl_program_use()) shader program. * currently used (see cogl_program_use()) shader program.
*/ */
void cogl_program_uniform_int (COGLint uniform_no, void cogl_program_uniform_int (int uniform_no,
gint size, int size,
gint count, int count,
const COGLint *value); const int *value);
/** /**
* cogl_program_uniform_matrix: * 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 * currently used (see cogl_program_use()) shader program. The @size
* parameter is used to determine the square size of the matrix. * parameter is used to determine the square size of the matrix.
*/ */
void cogl_program_uniform_matrix (COGLint uniform_no, void cogl_program_uniform_matrix (int uniform_no,
gint size, int size,
gint count, int count,
gboolean transpose, gboolean transpose,
const GLfloat *value); const float *value);
G_END_DECLS G_END_DECLS

View File

@ -228,6 +228,52 @@ guint cogl_texture_get_rowstride (CoglHandle handle);
*/ */
gint cogl_texture_get_max_waste (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: * cogl_texture_get_min_filter:
* @handle: a #CoglHandle for a texture. * @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. * 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: * 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. * 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: * cogl_texture_is_sliced:
@ -307,8 +353,8 @@ gint cogl_texture_get_data (CoglHandle handle,
* drawn at other scales than 100%. * drawn at other scales than 100%.
*/ */
void cogl_texture_set_filters (CoglHandle handle, void cogl_texture_set_filters (CoglHandle handle,
COGLenum min_filter, CoglTextureFilter min_filter,
COGLenum mag_filter); CoglTextureFilter mag_filter);
/** /**

View File

@ -29,10 +29,6 @@
G_BEGIN_DECLS G_BEGIN_DECLS
typedef GLenum COGLenum;
typedef GLint COGLint;
typedef GLuint COGLuint;
/* FIXME + DOCUMENT */ /* FIXME + DOCUMENT */
#define COPENSTEP OPENSTEP #define COPENSTEP OPENSTEP
@ -226,7 +222,6 @@ typedef GLuint COGLuint;
#define CGL_FOG_INDEX GL_FOG_INDEX #define CGL_FOG_INDEX GL_FOG_INDEX
#define CGL_FOG_START GL_FOG_START #define CGL_FOG_START GL_FOG_START
#define CGL_FOG_END GL_FOG_END #define CGL_FOG_END GL_FOG_END
#define CGL_LINEAR GL_LINEAR
#define CGL_EXP GL_EXP #define CGL_EXP GL_EXP
#define CGL_LOGIC_OP GL_LOGIC_OP #define CGL_LOGIC_OP GL_LOGIC_OP
#define CGL_INDEX_LOGIC_OP GL_INDEX_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_ALPHA_SIZE GL_TEXTURE_ALPHA_SIZE
#define CGL_TEXTURE_LUMINANCE_SIZE GL_TEXTURE_LUMINANCE_SIZE #define CGL_TEXTURE_LUMINANCE_SIZE GL_TEXTURE_LUMINANCE_SIZE
#define CGL_TEXTURE_INTENSITY_SIZE GL_TEXTURE_INTENSITY_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_LINEAR GL_OBJECT_LINEAR
#define CGL_OBJECT_PLANE GL_OBJECT_PLANE #define CGL_OBJECT_PLANE GL_OBJECT_PLANE
#define CGL_EYE_LINEAR GL_EYE_LINEAR #define CGL_EYE_LINEAR GL_EYE_LINEAR
@ -430,7 +421,6 @@ typedef GLuint COGLuint;
#define CGL_SPHERE_MAP GL_SPHERE_MAP #define CGL_SPHERE_MAP GL_SPHERE_MAP
#define CGL_DECAL GL_DECAL #define CGL_DECAL GL_DECAL
#define CGL_MODULATE GL_MODULATE #define CGL_MODULATE GL_MODULATE
#define CGL_NEAREST GL_NEAREST
#define CGL_REPEAT GL_REPEAT #define CGL_REPEAT GL_REPEAT
#define CGL_CLAMP GL_CLAMP #define CGL_CLAMP GL_CLAMP
#define CGL_S GL_S #define CGL_S GL_S
@ -692,9 +682,6 @@ typedef GLuint COGLuint;
#define CGL_UNSIGNED_SHORT_8_8_MESA 0 #define CGL_UNSIGNED_SHORT_8_8_MESA 0
#endif #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 CGL_OBJECT_COMPILE_STATUS GL_OBJECT_COMPILE_STATUS_ARB
#define CLUTTER_COGL_HAS_GL 1 #define CLUTTER_COGL_HAS_GL 1

View File

@ -139,7 +139,7 @@ cogl_program_use (CoglHandle handle)
glUseProgramObjectARB (gl_handle); glUseProgramObjectARB (gl_handle);
} }
COGLint int
cogl_program_get_uniform_location (CoglHandle handle, cogl_program_get_uniform_location (CoglHandle handle,
const gchar *uniform_name) const gchar *uniform_name)
{ {
@ -155,7 +155,7 @@ cogl_program_get_uniform_location (CoglHandle handle,
} }
void void
cogl_program_uniform_1f (COGLint uniform_no, cogl_program_uniform_1f (int uniform_no,
gfloat value) gfloat value)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -163,7 +163,7 @@ cogl_program_uniform_1f (COGLint uniform_no,
} }
void void
cogl_program_uniform_1i (COGLint uniform_no, cogl_program_uniform_1i (int uniform_no,
gint value) gint value)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -171,7 +171,7 @@ cogl_program_uniform_1i (COGLint uniform_no,
} }
void void
cogl_program_uniform_float (COGLint uniform_no, cogl_program_uniform_float (int uniform_no,
gint size, gint size,
gint count, gint count,
const GLfloat *value) const GLfloat *value)
@ -198,10 +198,10 @@ cogl_program_uniform_float (COGLint uniform_no,
} }
void void
cogl_program_uniform_int (COGLint uniform_no, cogl_program_uniform_int (int uniform_no,
gint size, gint size,
gint count, gint count,
const COGLint *value) const int *value)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -225,7 +225,7 @@ cogl_program_uniform_int (COGLint uniform_no,
} }
void void
cogl_program_uniform_matrix (COGLint uniform_no, cogl_program_uniform_matrix (int uniform_no,
gint size, gint size,
gint count, gint count,
gboolean transpose, gboolean transpose,

View File

@ -55,21 +55,33 @@ _cogl_shader_free (CoglShader *shader)
} }
CoglHandle CoglHandle
cogl_create_shader (COGLenum shaderType) cogl_create_shader (CoglShaderType type)
{ {
CoglShader *shader; 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 = g_slice_new (CoglShader);
shader->gl_handle = glCreateShaderObjectARB (shaderType); shader->gl_handle = glCreateShaderObjectARB (gl_type);
return _cogl_shader_handle_new (shader); return _cogl_shader_handle_new (shader);
} }
void void
cogl_shader_source (CoglHandle handle, cogl_shader_source (CoglHandle handle,
const gchar *source) const char *source)
{ {
CoglShader *shader; CoglShader *shader;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -98,11 +110,11 @@ cogl_shader_compile (CoglHandle handle)
void void
cogl_shader_get_info_log (CoglHandle handle, cogl_shader_get_info_log (CoglHandle handle,
guint size, size_t size,
gchar *buffer) char *buffer)
{ {
CoglShader *shader; CoglShader *shader;
COGLint len; int len;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (!cogl_is_shader (handle)) if (!cogl_is_shader (handle))
@ -114,18 +126,51 @@ cogl_shader_get_info_log (CoglHandle handle,
buffer[len]='\0'; buffer[len]='\0';
} }
void CoglShaderType
cogl_shader_get_parameteriv (CoglHandle handle, cogl_shader_get_type (CoglHandle handle)
COGLenum pname,
COGLint *dest)
{ {
GLint type;
CoglShader *shader; CoglShader *shader;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
_COGL_GET_CONTEXT (ctx, COGL_SHADER_TYPE_VERTEX);
if (!cogl_is_shader (handle)) 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); 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;
}

View File

@ -68,8 +68,8 @@ struct _CoglTexture
GArray *slice_y_spans; GArray *slice_y_spans;
GArray *slice_gl_handles; GArray *slice_gl_handles;
gint max_waste; gint max_waste;
COGLenum min_filter; CoglTextureFilter min_filter;
COGLenum mag_filter; CoglTextureFilter mag_filter;
gboolean is_foreign; gboolean is_foreign;
GLint wrap_mode; GLint wrap_mode;
gboolean auto_mipmap; gboolean auto_mipmap;

View File

@ -1247,8 +1247,8 @@ cogl_texture_new_with_size (guint width,
tex->slice_gl_handles = NULL; tex->slice_gl_handles = NULL;
tex->max_waste = max_waste; tex->max_waste = max_waste;
tex->min_filter = CGL_NEAREST; tex->min_filter = COGL_TEXTURE_FILTER_NEAREST;
tex->mag_filter = CGL_NEAREST; tex->mag_filter = COGL_TEXTURE_FILTER_NEAREST;
/* Find closest GL format match */ /* Find closest GL format match */
tex->bitmap.format = tex->bitmap.format =
@ -1308,8 +1308,8 @@ cogl_texture_new_from_data (guint width,
tex->slice_gl_handles = NULL; tex->slice_gl_handles = NULL;
tex->max_waste = max_waste; tex->max_waste = max_waste;
tex->min_filter = CGL_NEAREST; tex->min_filter = COGL_TEXTURE_FILTER_NEAREST;
tex->mag_filter = CGL_NEAREST; tex->mag_filter = COGL_TEXTURE_FILTER_NEAREST;
/* FIXME: If upload fails we should set some kind of /* FIXME: If upload fails we should set some kind of
* error flag but still return texture handle (this * 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->slice_gl_handles = NULL;
tex->max_waste = max_waste; tex->max_waste = max_waste;
tex->min_filter = CGL_NEAREST; tex->min_filter = COGL_TEXTURE_FILTER_NEAREST;
tex->mag_filter = CGL_NEAREST; tex->mag_filter = COGL_TEXTURE_FILTER_NEAREST;
/* FIXME: If upload fails we should set some kind of /* FIXME: If upload fails we should set some kind of
* error flag but still return texture handle if the * error flag but still return texture handle if the
@ -1693,7 +1693,7 @@ cogl_texture_get_gl_texture (CoglHandle handle,
return TRUE; return TRUE;
} }
COGLenum CoglTextureFilter
cogl_texture_get_min_filter (CoglHandle handle) cogl_texture_get_min_filter (CoglHandle handle)
{ {
CoglTexture *tex; CoglTexture *tex;
@ -1706,7 +1706,7 @@ cogl_texture_get_min_filter (CoglHandle handle)
return tex->min_filter; return tex->min_filter;
} }
COGLenum CoglTextureFilter
cogl_texture_get_mag_filter (CoglHandle handle) cogl_texture_get_mag_filter (CoglHandle handle)
{ {
CoglTexture *tex; CoglTexture *tex;
@ -1721,8 +1721,8 @@ cogl_texture_get_mag_filter (CoglHandle handle)
void void
cogl_texture_set_filters (CoglHandle handle, cogl_texture_set_filters (CoglHandle handle,
COGLenum min_filter, CoglTextureFilter min_filter,
COGLenum mag_filter) CoglTextureFilter mag_filter)
{ {
CoglTexture *tex; CoglTexture *tex;
GLuint gl_handle; GLuint gl_handle;

View File

@ -430,10 +430,6 @@ G_BEGIN_DECLS
#define CGL_WEIGHT_ARRAY_BUFFER_BINDING_OES GL_WEIGHT_ARRAY_BUFFER_BINDING_OES #define CGL_WEIGHT_ARRAY_BUFFER_BINDING_OES GL_WEIGHT_ARRAY_BUFFER_BINDING_OES
#define CGL_TEXTURE_CROP_RECT_OES GL_TEXTURE_CROP_RECT_OES #define CGL_TEXTURE_CROP_RECT_OES GL_TEXTURE_CROP_RECT_OES
typedef GLenum COGLenum;
typedef GLint COGLint;
typedef GLuint COGLuint;
/* extras */ /* extras */
/* YUV textures also unsupported */ /* 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_REV_MESA 0
#define CGL_UNSIGNED_SHORT_8_8_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) #if defined(GL_OBJECT_COMPILE_STATUS)
#define CGL_OBJECT_COMPILE_STATUS GL_OBJECT_COMPILE_STATUS #define CGL_OBJECT_COMPILE_STATUS GL_OBJECT_COMPILE_STATUS
#elif defined(GL_COMPILE_STATUS) #elif defined(GL_COMPILE_STATUS)

View File

@ -122,7 +122,7 @@ cogl_program_use (CoglHandle handle)
ctx->gles2.settings_dirty = TRUE; ctx->gles2.settings_dirty = TRUE;
} }
COGLint int
cogl_program_get_uniform_location (CoglHandle handle, cogl_program_get_uniform_location (CoglHandle handle,
const gchar *uniform_name) const gchar *uniform_name)
{ {
@ -155,21 +155,21 @@ cogl_program_get_uniform_location (CoglHandle handle,
} }
void void
cogl_program_uniform_1f (COGLint uniform_no, cogl_program_uniform_1f (int uniform_no,
gfloat value) gfloat value)
{ {
cogl_program_uniform_float (uniform_no, 1, 1, &value); cogl_program_uniform_float (uniform_no, 1, 1, &value);
} }
void void
cogl_program_uniform_1i (COGLint uniform_no, cogl_program_uniform_1i (int uniform_no,
gint value) gint value)
{ {
cogl_program_uniform_int (uniform_no, 1, 1, &value); cogl_program_uniform_int (uniform_no, 1, 1, &value);
} }
static void static void
cogl_program_uniform_x (COGLint uniform_no, cogl_program_uniform_x (int uniform_no,
gint size, gint size,
gint count, gint count,
CoglBoxedType type, CoglBoxedType type,
@ -215,7 +215,7 @@ cogl_program_uniform_x (COGLint uniform_no,
} }
void void
cogl_program_uniform_float (COGLint uniform_no, cogl_program_uniform_float (int uniform_no,
gint size, gint size,
gint count, gint count,
const GLfloat *value) const GLfloat *value)
@ -225,7 +225,7 @@ cogl_program_uniform_float (COGLint uniform_no,
} }
void void
cogl_program_uniform_int (COGLint uniform_no, cogl_program_uniform_int (int uniform_no,
gint size, gint size,
gint count, gint count,
const GLint *value) const GLint *value)
@ -235,7 +235,7 @@ cogl_program_uniform_int (COGLint uniform_no,
} }
void void
cogl_program_uniform_matrix (COGLint uniform_no, cogl_program_uniform_matrix (int uniform_no,
gint size, gint size,
gint count, gint count,
gboolean transpose, gboolean transpose,
@ -296,7 +296,7 @@ cogl_program_use (CoglHandle program_handle)
{ {
} }
COGLint int
cogl_program_get_uniform_location (CoglHandle program_handle, cogl_program_get_uniform_location (CoglHandle program_handle,
const gchar *uniform_name) const gchar *uniform_name)
{ {
@ -304,13 +304,13 @@ cogl_program_get_uniform_location (CoglHandle program_handle,
} }
void void
cogl_program_uniform_1f (COGLint uniform_no, cogl_program_uniform_1f (int uniform_no,
gfloat value) gfloat value)
{ {
} }
void void
cogl_program_uniform_float (COGLint uniform_no, cogl_program_uniform_float (int uniform_no,
gint size, gint size,
gint count, gint count,
const GLfloat *value) const GLfloat *value)
@ -318,15 +318,15 @@ cogl_program_uniform_float (COGLint uniform_no,
} }
void void
cogl_program_uniform_int (COGLint uniform_no, cogl_program_uniform_int (int uniform_no,
gint size, gint size,
gint count, gint count,
const COGLint *value) const int *value)
{ {
} }
void void
cogl_program_uniform_matrix (COGLint uniform_no, cogl_program_uniform_matrix (int uniform_no,
gint size, gint size,
gint count, gint count,
gboolean transpose, gboolean transpose,

View File

@ -48,22 +48,31 @@ _cogl_shader_free (CoglShader *shader)
} }
CoglHandle CoglHandle
cogl_create_shader (COGLenum shaderType) cogl_create_shader (CoglShaderType type)
{ {
CoglShader *shader; 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 = g_slice_new (CoglShader);
shader->gl_handle = glCreateShader (shaderType); shader->gl_handle = glCreateShader (gl_type);
shader->type = shaderType;
return _cogl_shader_handle_new (shader); return _cogl_shader_handle_new (shader);
} }
void void
cogl_shader_source (CoglHandle handle, cogl_shader_source (CoglHandle handle,
const gchar *source) const char *source)
{ {
CoglShader *shader; CoglShader *shader;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -92,11 +101,11 @@ cogl_shader_compile (CoglHandle handle)
void void
cogl_shader_get_info_log (CoglHandle handle, cogl_shader_get_info_log (CoglHandle handle,
guint size, size_t size,
gchar *buffer) char *buffer)
{ {
CoglShader *shader; CoglShader *shader;
COGLint len = 0; int len = 0;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (!cogl_is_shader (handle)) if (!cogl_is_shader (handle))
@ -108,20 +117,48 @@ cogl_shader_get_info_log (CoglHandle handle,
buffer[len] = '\0'; buffer[len] = '\0';
} }
void CoglShaderType
cogl_shader_get_parameteriv (CoglHandle handle, cogl_shader_get_type (CoglHandle handle)
COGLenum pname,
COGLint *dest)
{ {
GLint type;
CoglShader *shader; CoglShader *shader;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (!cogl_is_shader (handle)) 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); 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 */ #else /* HAVE_COGL_GLES2 */
@ -129,7 +166,7 @@ cogl_shader_get_parameteriv (CoglHandle handle,
/* No support on regular OpenGL 1.1 */ /* No support on regular OpenGL 1.1 */
CoglHandle CoglHandle
cogl_create_shader (COGLenum shaderType) cogl_create_shader (CoglShaderType type)
{ {
return COGL_INVALID_HANDLE; return COGL_INVALID_HANDLE;
} }
@ -153,7 +190,7 @@ cogl_shader_unref (CoglHandle handle)
void void
cogl_shader_source (CoglHandle shader, cogl_shader_source (CoglHandle shader,
const gchar *source) const char *source)
{ {
} }
@ -164,16 +201,21 @@ cogl_shader_compile (CoglHandle shader_handle)
void void
cogl_shader_get_info_log (CoglHandle handle, cogl_shader_get_info_log (CoglHandle handle,
guint size, size_t size,
gchar *buffer) char *buffer)
{ {
} }
void CoglShaderType
cogl_shader_get_parameteriv (CoglHandle handle, cogl_shader_get_type (CoglHandle handle)
COGLenum pname,
COGLint *dest)
{ {
return COGL_SHADER_TYPE_VERTEX;
}
gboolean
cogl_shader_is_compiled (CoglHandle handle)
{
return FALSE;
} }
#endif /* HAVE_COGL_GLES2 */ #endif /* HAVE_COGL_GLES2 */

View File

@ -68,8 +68,8 @@ struct _CoglTexture
GArray *slice_y_spans; GArray *slice_y_spans;
GArray *slice_gl_handles; GArray *slice_gl_handles;
gint max_waste; gint max_waste;
COGLenum min_filter; CoglTextureFilter min_filter;
COGLenum mag_filter; CoglTextureFilter mag_filter;
gboolean is_foreign; gboolean is_foreign;
GLint wrap_mode; GLint wrap_mode;
gboolean auto_mipmap; gboolean auto_mipmap;

View File

@ -1778,7 +1778,7 @@ cogl_texture_get_gl_texture (CoglHandle handle,
return TRUE; return TRUE;
} }
COGLenum CoglTextureFilter
cogl_texture_get_min_filter (CoglHandle handle) cogl_texture_get_min_filter (CoglHandle handle)
{ {
CoglTexture *tex; CoglTexture *tex;
@ -1791,7 +1791,7 @@ cogl_texture_get_min_filter (CoglHandle handle)
return tex->min_filter; return tex->min_filter;
} }
COGLenum CoglTextureFilter
cogl_texture_get_mag_filter (CoglHandle handle) cogl_texture_get_mag_filter (CoglHandle handle)
{ {
CoglTexture *tex; CoglTexture *tex;
@ -1806,8 +1806,8 @@ cogl_texture_get_mag_filter (CoglHandle handle)
void void
cogl_texture_set_filters (CoglHandle handle, cogl_texture_set_filters (CoglHandle handle,
COGLenum min_filter, CoglTextureFilter min_filter,
COGLenum mag_filter) CoglTextureFilter mag_filter)
{ {
CoglTexture *tex; CoglTexture *tex;
GLuint gl_handle; GLuint gl_handle;

View File

@ -25,7 +25,7 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
/* TODO: /* TODO:
* - Automagically handle named pixmaps, and window resizes (i.e * - Automagically handle named pixmaps, and window resizes (i.e
* essentially handle window id's being passed in) ? * essentially handle window id's being passed in) ?
*/ */
@ -94,8 +94,6 @@ static RectangleState _rectangle_state = CLUTTER_GLX_RECTANGLE_ALLOW;
struct _ClutterGLXTexturePixmapPrivate struct _ClutterGLXTexturePixmapPrivate
{ {
COGLenum target_type;
guint texture_id;
GLXPixmap glx_pixmap; GLXPixmap glx_pixmap;
gboolean use_fallback; gboolean use_fallback;
@ -107,14 +105,14 @@ struct _ClutterGLXTexturePixmapPrivate
gboolean using_rectangle; gboolean using_rectangle;
}; };
static void static void
clutter_glx_texture_pixmap_update_area (ClutterX11TexturePixmap *texture, clutter_glx_texture_pixmap_update_area (ClutterX11TexturePixmap *texture,
gint x, gint x,
gint y, gint y,
gint width, gint width,
gint height); gint height);
static void static void
clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *tex); clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *tex);
static ClutterX11TexturePixmapClass *parent_class = NULL; static ClutterX11TexturePixmapClass *parent_class = NULL;
@ -137,12 +135,12 @@ texture_bind (ClutterGLXTexturePixmap *tex)
/* FIXME: fire off an error here? */ /* FIXME: fire off an error here? */
glBindTexture (target, handle); 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) == CLUTTER_TEXTURE_QUALITY_HIGH && tex->priv->can_mipmap)
{ {
cogl_texture_set_filters (cogl_tex, cogl_texture_set_filters (cogl_tex,
CGL_LINEAR_MIPMAP_LINEAR, COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR,
CGL_LINEAR); COGL_TEXTURE_FILTER_LINEAR);
} }
return TRUE; return TRUE;
@ -157,13 +155,13 @@ on_glx_texture_pixmap_pre_paint (ClutterGLXTexturePixmap *texture,
GLuint handle = 0; GLuint handle = 0;
GLenum target = 0; GLenum target = 0;
CoglHandle cogl_tex; CoglHandle cogl_tex;
cogl_tex = clutter_texture_get_cogl_texture cogl_tex = clutter_texture_get_cogl_texture
(CLUTTER_TEXTURE(texture)); (CLUTTER_TEXTURE(texture));
texture_bind (texture); texture_bind (texture);
cogl_texture_get_gl_texture (cogl_tex, &handle, &target); cogl_texture_get_gl_texture (cogl_tex, &handle, &target);
_gl_generate_mipmap (target); _gl_generate_mipmap (target);
texture->priv->mipmap_generate_queued = 0; texture->priv->mipmap_generate_queued = 0;
@ -408,11 +406,11 @@ clutter_glx_texture_pixmap_realize (ClutterActor *actor)
"pixmap-width", &pixmap_width, "pixmap-width", &pixmap_width,
"pixmap-height", &pixmap_height, "pixmap-height", &pixmap_height,
NULL); NULL);
if (!pixmap) if (!pixmap)
return; return;
if (!create_cogl_texture (CLUTTER_TEXTURE (actor), if (!create_cogl_texture (CLUTTER_TEXTURE (actor),
pixmap_width, pixmap_height)) pixmap_width, pixmap_height))
{ {
CLUTTER_NOTE (TEXTURE, "Unable to create a valid pixmap"); CLUTTER_NOTE (TEXTURE, "Unable to create a valid pixmap");
@ -460,7 +458,7 @@ clutter_glx_texture_pixmap_unrealize (ClutterActor *actor)
priv->bound = FALSE; priv->bound = FALSE;
} }
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED); 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) if (glx_pixmap != None)
{ {
priv->glx_pixmap = glx_pixmap; priv->glx_pixmap = glx_pixmap;
create_cogl_texture (CLUTTER_TEXTURE (texture), create_cogl_texture (CLUTTER_TEXTURE (texture),
pixmap_width, pixmap_height); pixmap_width, pixmap_height);
CLUTTER_NOTE (TEXTURE, "Created GLXPixmap"); CLUTTER_NOTE (TEXTURE, "Created GLXPixmap");
@ -762,7 +760,7 @@ clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *texture)
priv->glx_pixmap = None; priv->glx_pixmap = None;
/* Some fucky logic here - we've fallen back and need to make sure /* 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)); clutter_actor_realize (CLUTTER_ACTOR (texture));
} }
@ -800,22 +798,22 @@ clutter_glx_texture_pixmap_update_area (ClutterX11TexturePixmap *texture,
if (priv->glx_pixmap == None) if (priv->glx_pixmap == None)
return; return;
if (texture_bind (CLUTTER_GLX_TEXTURE_PIXMAP(texture))) if (texture_bind (CLUTTER_GLX_TEXTURE_PIXMAP(texture)))
{ {
CLUTTER_NOTE (TEXTURE, "Really updating via GLX"); CLUTTER_NOTE (TEXTURE, "Really updating via GLX");
clutter_x11_trap_x_errors (); clutter_x11_trap_x_errors ();
(_gl_bind_tex_image) (dpy, (_gl_bind_tex_image) (dpy,
priv->glx_pixmap, priv->glx_pixmap,
GLX_FRONT_LEFT_EXT, GLX_FRONT_LEFT_EXT,
NULL); NULL);
XSync (clutter_x11_get_default_display(), FALSE); XSync (clutter_x11_get_default_display(), FALSE);
/* Note above fires X error for non name pixmaps - but /* 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 ()) if (clutter_x11_untrap_x_errors ())
CLUTTER_NOTE (TEXTURE, "Update bind_tex_image failed"); 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 /* FIXME: It may make more sense to set a flag here and only
* generate the mipmap on a pre paint.. compressing need * generate the mipmap on a pre paint.. compressing need
* to call generate mipmap * to call generate mipmap
* May break clones however.. * May break clones however..
*/ */
priv->mipmap_generate_queued++; priv->mipmap_generate_queued++;
@ -870,7 +868,7 @@ clutter_glx_texture_pixmap_class_init (ClutterGLXTexturePixmapClass *klass)
* clutter_glx_texture_pixmap_using_extension: * clutter_glx_texture_pixmap_using_extension:
* @texture: A #ClutterGLXTexturePixmap * @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 * GLX_EXT_texture_from_pixmap OpenGL extension or falling back to
* slower software mechanism. * slower software mechanism.
* *
@ -883,8 +881,8 @@ clutter_glx_texture_pixmap_using_extension (ClutterGLXTexturePixmap *texture)
priv = CLUTTER_GLX_TEXTURE_PIXMAP (texture)->priv; priv = CLUTTER_GLX_TEXTURE_PIXMAP (texture)->priv;
return (_have_tex_from_pixmap_ext && !priv->use_fallback); return (_have_tex_from_pixmap_ext && !priv->use_fallback);
/* Assume NPOT TFP's are supported even if regular NPOT isn't advertised /* Assume NPOT TFP's are supported even if regular NPOT isn't advertised
* but tfp is. Seemingly some Intel drivers do this ? * but tfp is. Seemingly some Intel drivers do this ?
*/ */
/* && clutter_feature_available (COGL_FEATURE_TEXTURE_NPOT)); */ /* && clutter_feature_available (COGL_FEATURE_TEXTURE_NPOT)); */

View File

@ -311,12 +311,12 @@ cogl_pango_glyph_cache_set (CoglPangoGlyphCache *cache,
if (cache->use_mipmapping) if (cache->use_mipmapping)
cogl_texture_set_filters (texture->texture, cogl_texture_set_filters (texture->texture,
CGL_LINEAR_MIPMAP_LINEAR, COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR,
CGL_LINEAR); COGL_TEXTURE_FILTER_LINEAR);
else else
cogl_texture_set_filters (texture->texture, cogl_texture_set_filters (texture->texture,
CGL_LINEAR, COGL_TEXTURE_FILTER_LINEAR,
CGL_LINEAR); COGL_TEXTURE_FILTER_LINEAR);
} }
band = g_slice_new (CoglPangoGlyphCacheBand); band = g_slice_new (CoglPangoGlyphCacheBand);

View File

@ -149,7 +149,8 @@ cogl_is_shader
cogl_shader_source cogl_shader_source
cogl_shader_compile cogl_shader_compile
cogl_shader_get_info_log cogl_shader_get_info_log
cogl_shader_get_parameteriv cogl_shader_get_type
cogl_shader_is_compiled
<SUBSECTION> <SUBSECTION>
cogl_create_program cogl_create_program
cogl_program_ref cogl_program_ref

View File

@ -9,7 +9,7 @@
*--------------------------------------------------*/ *--------------------------------------------------*/
G_BEGIN_DECLS G_BEGIN_DECLS
#define TEST_TYPE_COGLBOX test_coglbox_get_type() #define TEST_TYPE_COGLBOX test_coglbox_get_type()
#define TEST_COGLBOX(obj) \ #define TEST_COGLBOX(obj) \
@ -44,7 +44,7 @@ struct _TestCoglbox
TestCoglboxPrivate *priv; TestCoglboxPrivate *priv;
}; };
struct _TestCoglboxClass struct _TestCoglboxClass
{ {
ClutterActorClass parent_class; ClutterActorClass parent_class;
@ -91,7 +91,7 @@ test_coglbox_fade_texture (CoglHandle tex_id,
{ {
CoglTextureVertex vertices[4]; CoglTextureVertex vertices[4];
int i; int i;
vertices[0].x = x1; vertices[0].x = x1;
vertices[0].y = y1; vertices[0].y = y1;
vertices[0].z = 0; vertices[0].z = 0;
@ -142,7 +142,7 @@ test_coglbox_triangle_texture (CoglHandle tex_id,
CoglTextureVertex vertices[3]; CoglTextureVertex vertices[3];
int tex_width = cogl_texture_get_width (tex_id); int tex_width = cogl_texture_get_width (tex_id);
int tex_height = cogl_texture_get_height (tex_id); int tex_height = cogl_texture_get_height (tex_id);
vertices[0].x = x + tx1 * tex_width; vertices[0].x = x + tx1 * tex_width;
vertices[0].y = y + ty1 * tex_height; vertices[0].y = y + ty1 * tex_height;
vertices[0].z = 0; vertices[0].z = 0;
@ -176,9 +176,11 @@ test_coglbox_paint (ClutterActor *self)
cogl_texture_set_filters (tex_handle, cogl_texture_set_filters (tex_handle,
priv->use_linear_filtering priv->use_linear_filtering
? CGL_LINEAR : CGL_NEAREST, ? COGL_TEXTURE_FILTER_LINEAR :
COGL_TEXTURE_FILTER_NEAREST,
priv->use_linear_filtering priv->use_linear_filtering
? CGL_LINEAR : CGL_NEAREST); ? COGL_TEXTURE_FILTER_LINEAR :
COGL_TEXTURE_FILTER_NEAREST);
cogl_push_matrix (); cogl_push_matrix ();
cogl_translate (tex_width / 2, 0, 0); cogl_translate (tex_width / 2, 0, 0);
@ -227,11 +229,11 @@ static void
test_coglbox_dispose (GObject *object) test_coglbox_dispose (GObject *object)
{ {
TestCoglboxPrivate *priv; TestCoglboxPrivate *priv;
priv = TEST_COGLBOX_GET_PRIVATE (object); priv = TEST_COGLBOX_GET_PRIVATE (object);
cogl_handle_unref (priv->not_sliced_tex); cogl_handle_unref (priv->not_sliced_tex);
cogl_handle_unref (priv->sliced_tex); cogl_handle_unref (priv->sliced_tex);
G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object); 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_linear_filtering = FALSE;
priv->use_sliced = FALSE; priv->use_sliced = FALSE;
priv->sliced_tex = priv->sliced_tex =
cogl_texture_new_from_file ("redhand.png", 10, cogl_texture_new_from_file ("redhand.png", 10,
COGL_TEXTURE_NONE, COGL_TEXTURE_NONE,
@ -286,9 +288,9 @@ test_coglbox_class_init (TestCoglboxClass *klass)
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
gobject_class->finalize = test_coglbox_finalize; gobject_class->finalize = test_coglbox_finalize;
gobject_class->dispose = test_coglbox_dispose; gobject_class->dispose = test_coglbox_dispose;
actor_class->paint = test_coglbox_paint; actor_class->paint = test_coglbox_paint;
g_type_class_add_private (gobject_class, sizeof (TestCoglboxPrivate)); g_type_class_add_private (gobject_class, sizeof (TestCoglboxPrivate));
} }
@ -304,7 +306,7 @@ frame_cb (ClutterTimeline *timeline,
gpointer data) gpointer data)
{ {
TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (data); TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (data);
priv->frame = frame_num; priv->frame = frame_num;
clutter_actor_queue_redraw (CLUTTER_ACTOR (data)); 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 *group = clutter_group_new ();
ClutterActor *label = clutter_text_new_with_text ("Sans 14", label_text); ClutterActor *label = clutter_text_new_with_text ("Sans 14", label_text);
ClutterActor *button = clutter_text_new_with_text ("Sans 14", ""); ClutterActor *button = clutter_text_new_with_text ("Sans 14", "");
clutter_actor_set_reactive (button, TRUE); clutter_actor_set_reactive (button, TRUE);
update_toggle_text (CLUTTER_TEXT (button), *toggle_val); update_toggle_text (CLUTTER_TEXT (button), *toggle_val);
clutter_actor_set_position (button, clutter_actor_get_width (label) + 10, 0); clutter_actor_set_position (button, clutter_actor_get_width (label) + 10, 0);
clutter_container_add (CLUTTER_CONTAINER (group), label, button, NULL); clutter_container_add (CLUTTER_CONTAINER (group), label, button, NULL);
@ -354,19 +356,19 @@ test_cogl_tex_polygon_main (int argc, char *argv[])
ClutterActor *note; ClutterActor *note;
ClutterTimeline *timeline; ClutterTimeline *timeline;
ClutterColor blue = { 0x30, 0x30, 0xff, 0xff }; ClutterColor blue = { 0x30, 0x30, 0xff, 0xff };
clutter_init (&argc, &argv); clutter_init (&argc, &argv);
/* Stage */ /* Stage */
stage = clutter_stage_get_default (); stage = clutter_stage_get_default ();
clutter_stage_set_color (CLUTTER_STAGE (stage), &blue); clutter_stage_set_color (CLUTTER_STAGE (stage), &blue);
clutter_actor_set_size (stage, 640, 480); clutter_actor_set_size (stage, 640, 480);
clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test"); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test");
/* Cogl Box */ /* Cogl Box */
coglbox = test_coglbox_new (); coglbox = test_coglbox_new ();
clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox); clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox);
/* Timeline for animation */ /* Timeline for animation */
timeline = clutter_timeline_new (360, 60); /* num frames, fps */ timeline = clutter_timeline_new (360, 60); /* num frames, fps */
g_object_set (timeline, "loop", TRUE, NULL); /* have it loop */ 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, filtering_toggle,
note, note,
NULL); NULL);
clutter_actor_show (stage); clutter_actor_show (stage);
clutter_main (); clutter_main ();
return 0; return 0;
} }

View File

@ -10,7 +10,7 @@
*--------------------------------------------------*/ *--------------------------------------------------*/
G_BEGIN_DECLS G_BEGIN_DECLS
#define TEST_TYPE_COGLBOX test_coglbox_get_type() #define TEST_TYPE_COGLBOX test_coglbox_get_type()
#define TEST_COGLBOX(obj) \ #define TEST_COGLBOX(obj) \
@ -45,7 +45,7 @@ struct _TestCoglbox
TestCoglboxPrivate *priv; TestCoglboxPrivate *priv;
}; };
struct _TestCoglboxClass struct _TestCoglboxClass
{ {
ClutterActorClass parent_class; ClutterActorClass parent_class;
@ -89,34 +89,34 @@ test_coglbox_paint (ClutterActor *self)
sin_frame = sinf ((float) priv->frame); sin_frame = sinf ((float) priv->frame);
cos_frame = cosf ((float) priv->frame); cos_frame = cosf ((float) priv->frame);
pingpong_frame = (priv->frame <= 180 ? priv->frame : 360 - priv->frame); pingpong_frame = (priv->frame <= 180 ? priv->frame : 360 - priv->frame);
frac_frame = (float) pingpong_frame / 180.0; frac_frame = (float) pingpong_frame / 180.0;
frac_frame += 0.5; frac_frame += 0.5;
frac_frame *= 2; frac_frame *= 2;
for (t=0; t<4; t+=2) for (t=0; t<4; t+=2)
{ {
texcoords[t] += cos_frame; texcoords[t] += cos_frame;
texcoords[t+1] += sin_frame; texcoords[t+1] += sin_frame;
texcoords[t] = (texcoords[t] * frac_frame); texcoords[t] = (texcoords[t] * frac_frame);
texcoords[t+1] = (texcoords[t+1] * frac_frame); texcoords[t+1] = (texcoords[t+1] * frac_frame);
} }
priv = TEST_COGLBOX_GET_PRIVATE (self); priv = TEST_COGLBOX_GET_PRIVATE (self);
cogl_push_matrix (); cogl_push_matrix ();
cogl_set_source_color4ub (0x66, 0x66, 0xdd, 0xff); cogl_set_source_color4ub (0x66, 0x66, 0xdd, 0xff);
cogl_rectangle (0, 0, 400, 400); cogl_rectangle (0, 0, 400, 400);
cogl_translate (100, 100, 0); cogl_translate (100, 100, 0);
cogl_set_source_texture (priv->cogl_tex_id); cogl_set_source_texture (priv->cogl_tex_id);
cogl_rectangle_with_texture_coords (0, 0, 200, 213, cogl_rectangle_with_texture_coords (0, 0, 200, 213,
texcoords[0], texcoords[1], texcoords[0], texcoords[1],
texcoords[2], texcoords[3]); texcoords[2], texcoords[3]);
cogl_pop_matrix(); cogl_pop_matrix();
} }
@ -130,10 +130,10 @@ static void
test_coglbox_dispose (GObject *object) test_coglbox_dispose (GObject *object)
{ {
TestCoglboxPrivate *priv; TestCoglboxPrivate *priv;
priv = TEST_COGLBOX_GET_PRIVATE (object); priv = TEST_COGLBOX_GET_PRIVATE (object);
cogl_handle_unref (priv->cogl_tex_id); cogl_handle_unref (priv->cogl_tex_id);
G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object); G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object);
} }
@ -142,14 +142,15 @@ test_coglbox_init (TestCoglbox *self)
{ {
TestCoglboxPrivate *priv; TestCoglboxPrivate *priv;
self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self); self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self);
priv->cogl_tex_id = cogl_texture_new_from_file ("redhand.png", 0, priv->cogl_tex_id = cogl_texture_new_from_file ("redhand.png", 0,
COGL_TEXTURE_NONE, COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_ANY, COGL_PIXEL_FORMAT_ANY,
NULL); NULL);
cogl_texture_set_filters (priv->cogl_tex_id, cogl_texture_set_filters (priv->cogl_tex_id,
CGL_LINEAR, CGL_LINEAR); COGL_TEXTURE_FILTER_LINEAR,
COGL_TEXTURE_FILTER_LINEAR);
} }
static void static void
@ -159,9 +160,9 @@ test_coglbox_class_init (TestCoglboxClass *klass)
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
gobject_class->finalize = test_coglbox_finalize; gobject_class->finalize = test_coglbox_finalize;
gobject_class->dispose = test_coglbox_dispose; gobject_class->dispose = test_coglbox_dispose;
actor_class->paint = test_coglbox_paint; actor_class->paint = test_coglbox_paint;
g_type_class_add_private (gobject_class, sizeof (TestCoglboxPrivate)); g_type_class_add_private (gobject_class, sizeof (TestCoglboxPrivate));
} }
@ -177,7 +178,7 @@ frame_cb (ClutterTimeline *timeline,
gpointer data) gpointer data)
{ {
TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (data); TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (data);
priv->frame = frame_num; priv->frame = frame_num;
clutter_actor_queue_redraw (CLUTTER_ACTOR (data)); clutter_actor_queue_redraw (CLUTTER_ACTOR (data));
} }
@ -188,27 +189,27 @@ test_cogl_tex_tile_main (int argc, char *argv[])
ClutterActor *stage; ClutterActor *stage;
ClutterActor *coglbox; ClutterActor *coglbox;
ClutterTimeline *timeline; ClutterTimeline *timeline;
clutter_init(&argc, &argv); clutter_init(&argc, &argv);
/* Stage */ /* Stage */
stage = clutter_stage_get_default (); stage = clutter_stage_get_default ();
clutter_actor_set_size (stage, 400, 400); clutter_actor_set_size (stage, 400, 400);
clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test"); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test");
/* Cogl Box */ /* Cogl Box */
coglbox = test_coglbox_new (); coglbox = test_coglbox_new ();
clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox); clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox);
/* Timeline for animation */ /* Timeline for animation */
timeline = clutter_timeline_new (360, 60); /* num frames, fps */ timeline = clutter_timeline_new (360, 60); /* num frames, fps */
g_object_set (timeline, "loop", TRUE, NULL); /* have it loop */ g_object_set (timeline, "loop", TRUE, NULL); /* have it loop */
g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), coglbox); g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), coglbox);
clutter_timeline_start (timeline); clutter_timeline_start (timeline);
clutter_actor_show_all (stage); clutter_actor_show_all (stage);
clutter_main (); clutter_main ();
return 0; return 0;
} }