[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

@ -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;
} }

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:
@ -92,7 +103,7 @@ gboolean cogl_is_shader (CoglHandle handle);
* 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.
@ -114,21 +125,25 @@ void cogl_shader_compile (CoglHandle handle);
* 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

@ -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;
@ -141,8 +139,8 @@ texture_bind (ClutterGLXTexturePixmap *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;

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

@ -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);

View File

@ -149,7 +149,8 @@ test_coglbox_init (TestCoglbox *self)
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