mirror of
https://github.com/brl/mutter.git
synced 2025-02-16 21:34:09 +00:00
Don't use any GL types or defines in Clutter
Some of the Clutter code was using GL types for the primitive types such as GLint and GLubyte and then passing these to Cogl. This doesn't make much sense because the Cogl functions directly take native C types. This patch just replaces them with either a native C type or a glib type. Some of the cogl conformance tests are trying to directly call GL for example to test creating a foreign texture. These tests have been changed to manually define the GL enum values instead of relying on a GL header to define them. This is necessary because Cogl may soon stop including a GL header from its public headers. Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
This commit is contained in:
parent
04f2be34b2
commit
c9a81f035e
@ -132,7 +132,7 @@ typedef struct _ShaderUniform
|
|||||||
gchar *name;
|
gchar *name;
|
||||||
GType type;
|
GType type;
|
||||||
GValue value;
|
GValue value;
|
||||||
GLint location;
|
int location;
|
||||||
} ShaderUniform;
|
} ShaderUniform;
|
||||||
|
|
||||||
struct _ClutterShaderEffectPrivate
|
struct _ClutterShaderEffectPrivate
|
||||||
@ -229,7 +229,7 @@ clutter_shader_effect_update_uniforms (ClutterShaderEffect *effect)
|
|||||||
|
|
||||||
if (CLUTTER_VALUE_HOLDS_SHADER_FLOAT (&uniform->value))
|
if (CLUTTER_VALUE_HOLDS_SHADER_FLOAT (&uniform->value))
|
||||||
{
|
{
|
||||||
const GLfloat *floats;
|
const float *floats;
|
||||||
|
|
||||||
floats = clutter_value_get_shader_float (&uniform->value, &size);
|
floats = clutter_value_get_shader_float (&uniform->value, &size);
|
||||||
cogl_program_set_uniform_float (priv->program, uniform->location,
|
cogl_program_set_uniform_float (priv->program, uniform->location,
|
||||||
@ -238,7 +238,7 @@ clutter_shader_effect_update_uniforms (ClutterShaderEffect *effect)
|
|||||||
}
|
}
|
||||||
else if (CLUTTER_VALUE_HOLDS_SHADER_INT (&uniform->value))
|
else if (CLUTTER_VALUE_HOLDS_SHADER_INT (&uniform->value))
|
||||||
{
|
{
|
||||||
const GLint *ints;
|
const int *ints;
|
||||||
|
|
||||||
ints = clutter_value_get_shader_int (&uniform->value, &size);
|
ints = clutter_value_get_shader_int (&uniform->value, &size);
|
||||||
cogl_program_set_uniform_int (priv->program, uniform->location,
|
cogl_program_set_uniform_int (priv->program, uniform->location,
|
||||||
@ -247,7 +247,7 @@ clutter_shader_effect_update_uniforms (ClutterShaderEffect *effect)
|
|||||||
}
|
}
|
||||||
else if (CLUTTER_VALUE_HOLDS_SHADER_MATRIX (&uniform->value))
|
else if (CLUTTER_VALUE_HOLDS_SHADER_MATRIX (&uniform->value))
|
||||||
{
|
{
|
||||||
const GLfloat *matrix;
|
const float *matrix;
|
||||||
|
|
||||||
matrix = clutter_value_get_shader_matrix (&uniform->value, &size);
|
matrix = clutter_value_get_shader_matrix (&uniform->value, &size);
|
||||||
cogl_program_set_uniform_matrix (priv->program, uniform->location,
|
cogl_program_set_uniform_matrix (priv->program, uniform->location,
|
||||||
@ -257,7 +257,7 @@ clutter_shader_effect_update_uniforms (ClutterShaderEffect *effect)
|
|||||||
}
|
}
|
||||||
else if (G_VALUE_HOLDS_FLOAT (&uniform->value))
|
else if (G_VALUE_HOLDS_FLOAT (&uniform->value))
|
||||||
{
|
{
|
||||||
const GLfloat float_val = g_value_get_float (&uniform->value);
|
const float float_val = g_value_get_float (&uniform->value);
|
||||||
|
|
||||||
cogl_program_set_uniform_float (priv->program, uniform->location,
|
cogl_program_set_uniform_float (priv->program, uniform->location,
|
||||||
1, 1,
|
1, 1,
|
||||||
@ -265,8 +265,8 @@ clutter_shader_effect_update_uniforms (ClutterShaderEffect *effect)
|
|||||||
}
|
}
|
||||||
else if (G_VALUE_HOLDS_DOUBLE (&uniform->value))
|
else if (G_VALUE_HOLDS_DOUBLE (&uniform->value))
|
||||||
{
|
{
|
||||||
const GLfloat float_val =
|
const float float_val =
|
||||||
(GLfloat) g_value_get_double (&uniform->value);
|
(float) g_value_get_double (&uniform->value);
|
||||||
|
|
||||||
cogl_program_set_uniform_float (priv->program, uniform->location,
|
cogl_program_set_uniform_float (priv->program, uniform->location,
|
||||||
1, 1,
|
1, 1,
|
||||||
@ -274,7 +274,7 @@ clutter_shader_effect_update_uniforms (ClutterShaderEffect *effect)
|
|||||||
}
|
}
|
||||||
else if (G_VALUE_HOLDS_INT (&uniform->value))
|
else if (G_VALUE_HOLDS_INT (&uniform->value))
|
||||||
{
|
{
|
||||||
const GLint int_val = g_value_get_int (&uniform->value);
|
const int int_val = g_value_get_int (&uniform->value);
|
||||||
|
|
||||||
cogl_program_set_uniform_int (priv->program, uniform->location,
|
cogl_program_set_uniform_int (priv->program, uniform->location,
|
||||||
1, 1,
|
1, 1,
|
||||||
|
@ -82,19 +82,19 @@ static GTypeFundamentalInfo shader_matrix_finfo = { 0, };
|
|||||||
struct _ClutterShaderFloat
|
struct _ClutterShaderFloat
|
||||||
{
|
{
|
||||||
gint size;
|
gint size;
|
||||||
GLfloat value[4];
|
float value[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _ClutterShaderInt
|
struct _ClutterShaderInt
|
||||||
{
|
{
|
||||||
gint size;
|
gint size;
|
||||||
GLint value[4];
|
int value[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _ClutterShaderMatrix
|
struct _ClutterShaderMatrix
|
||||||
{
|
{
|
||||||
gint size;
|
gint size;
|
||||||
GLfloat value[16];
|
float value[16];
|
||||||
};
|
};
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
@ -436,7 +436,7 @@ clutter_value_set_shader_int (GValue *value,
|
|||||||
shader_int->size = size;
|
shader_int->size = size;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
shader_int->value[i] = (GLint) ints[i];
|
shader_int->value[i] = ints[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1368,7 +1368,7 @@ read_pixels_to_file (char *filename_stem,
|
|||||||
int width,
|
int width,
|
||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
GLubyte *data;
|
guint8 *data;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
static int read_count = 0;
|
static int read_count = 0;
|
||||||
char *filename = g_strdup_printf ("%s-%05d.png",
|
char *filename = g_strdup_printf ("%s-%05d.png",
|
||||||
|
@ -766,7 +766,7 @@ clutter_shader_set_uniform (ClutterShader *shader,
|
|||||||
const GValue *value)
|
const GValue *value)
|
||||||
{
|
{
|
||||||
ClutterShaderPrivate *priv;
|
ClutterShaderPrivate *priv;
|
||||||
GLint location = 0;
|
int location = 0;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_SHADER (shader));
|
g_return_if_fail (CLUTTER_IS_SHADER (shader));
|
||||||
@ -785,7 +785,7 @@ clutter_shader_set_uniform (ClutterShader *shader,
|
|||||||
|
|
||||||
if (CLUTTER_VALUE_HOLDS_SHADER_FLOAT (value))
|
if (CLUTTER_VALUE_HOLDS_SHADER_FLOAT (value))
|
||||||
{
|
{
|
||||||
const GLfloat *floats;
|
const float *floats;
|
||||||
|
|
||||||
floats = clutter_value_get_shader_float (value, &size);
|
floats = clutter_value_get_shader_float (value, &size);
|
||||||
cogl_program_set_uniform_float (priv->program,
|
cogl_program_set_uniform_float (priv->program,
|
||||||
@ -801,7 +801,7 @@ clutter_shader_set_uniform (ClutterShader *shader,
|
|||||||
}
|
}
|
||||||
else if (CLUTTER_VALUE_HOLDS_SHADER_MATRIX (value))
|
else if (CLUTTER_VALUE_HOLDS_SHADER_MATRIX (value))
|
||||||
{
|
{
|
||||||
const GLfloat *matrix;
|
const float *matrix;
|
||||||
|
|
||||||
matrix = clutter_value_get_shader_matrix (value, &size);
|
matrix = clutter_value_get_shader_matrix (value, &size);
|
||||||
cogl_program_set_uniform_matrix (priv->program,
|
cogl_program_set_uniform_matrix (priv->program,
|
||||||
@ -809,7 +809,7 @@ clutter_shader_set_uniform (ClutterShader *shader,
|
|||||||
}
|
}
|
||||||
else if (G_VALUE_HOLDS_FLOAT (value))
|
else if (G_VALUE_HOLDS_FLOAT (value))
|
||||||
{
|
{
|
||||||
GLfloat float_val = g_value_get_float (value);
|
float float_val = g_value_get_float (value);
|
||||||
|
|
||||||
cogl_program_set_uniform_float (priv->program,
|
cogl_program_set_uniform_float (priv->program,
|
||||||
location, 1, 1, &float_val);
|
location, 1, 1, &float_val);
|
||||||
|
@ -30,6 +30,20 @@ static TestConformGLFunctions gl_functions;
|
|||||||
#define MASK_BLUE(COLOR) ((COLOR & 0xff00) >> 8)
|
#define MASK_BLUE(COLOR) ((COLOR & 0xff00) >> 8)
|
||||||
#define MASK_ALPHA(COLOR) (COLOR & 0xff)
|
#define MASK_ALPHA(COLOR) (COLOR & 0xff)
|
||||||
|
|
||||||
|
#ifndef GL_VERSION
|
||||||
|
#define GL_VERSION 0x1F02
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GL_MAX_TEXTURE_IMAGE_UNITS
|
||||||
|
#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
|
||||||
|
#endif
|
||||||
|
#ifndef GL_MAX_VERTEX_ATTRIBS
|
||||||
|
#define GL_MAX_VERTEX_ATTRIBS 0x8869
|
||||||
|
#endif
|
||||||
|
#ifndef GL_MAX_TEXTURE_UNITS
|
||||||
|
#define GL_MAX_TEXTURE_UNITS 0x84E2
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct _TestState
|
typedef struct _TestState
|
||||||
{
|
{
|
||||||
ClutterGeometry stage_geom;
|
ClutterGeometry stage_geom;
|
||||||
@ -39,9 +53,9 @@ typedef struct _TestState
|
|||||||
static void
|
static void
|
||||||
check_pixel (TestState *state, int x, int y, guint32 color)
|
check_pixel (TestState *state, int x, int y, guint32 color)
|
||||||
{
|
{
|
||||||
GLint y_off;
|
int y_off;
|
||||||
GLint x_off;
|
int x_off;
|
||||||
GLubyte pixel[4];
|
guint8 pixel[4];
|
||||||
guint8 r = MASK_RED (color);
|
guint8 r = MASK_RED (color);
|
||||||
guint8 g = MASK_GREEN (color);
|
guint8 g = MASK_GREEN (color);
|
||||||
guint8 b = MASK_BLUE (color);
|
guint8 b = MASK_BLUE (color);
|
||||||
@ -163,7 +177,7 @@ test_using_all_layers (TestState *state, int x, int y)
|
|||||||
guint8 red_pixel[] = { 0xff, 0x00, 0x00, 0xff };
|
guint8 red_pixel[] = { 0xff, 0x00, 0x00, 0xff };
|
||||||
CoglHandle white_texture;
|
CoglHandle white_texture;
|
||||||
CoglHandle red_texture;
|
CoglHandle red_texture;
|
||||||
GLint n_layers;
|
int n_layers;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Create a material that uses the maximum number of layers. All but
|
/* Create a material that uses the maximum number of layers. All but
|
||||||
@ -185,7 +199,7 @@ test_using_all_layers (TestState *state, int x, int y)
|
|||||||
#ifdef COGL_HAS_GLES2
|
#ifdef COGL_HAS_GLES2
|
||||||
if (using_gles2_driver ())
|
if (using_gles2_driver ())
|
||||||
{
|
{
|
||||||
GLint n_image_units, n_attribs;
|
int n_image_units, n_attribs;
|
||||||
/* GLES 2 doesn't have GL_MAX_TEXTURE_UNITS and it uses
|
/* GLES 2 doesn't have GL_MAX_TEXTURE_UNITS and it uses
|
||||||
GL_MAX_TEXTURE_IMAGE_UNITS instead */
|
GL_MAX_TEXTURE_IMAGE_UNITS instead */
|
||||||
gl_functions.glGetIntegerv (GL_MAX_TEXTURE_IMAGE_UNITS, &n_image_units);
|
gl_functions.glGetIntegerv (GL_MAX_TEXTURE_IMAGE_UNITS, &n_image_units);
|
||||||
|
@ -27,7 +27,7 @@ typedef struct _TestState
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_pixel (GLubyte *pixel, guint32 color)
|
check_pixel (guint8 *pixel, guint32 color)
|
||||||
{
|
{
|
||||||
guint8 r = MASK_RED (color);
|
guint8 r = MASK_RED (color);
|
||||||
guint8 g = MASK_GREEN (color);
|
guint8 g = MASK_GREEN (color);
|
||||||
|
@ -12,20 +12,49 @@ typedef struct _TestState
|
|||||||
ClutterActor *stage;
|
ClutterActor *stage;
|
||||||
} TestState;
|
} TestState;
|
||||||
|
|
||||||
|
#ifndef GL_EXTENSIONS
|
||||||
|
#define GL_EXTENSIONS 0x1F03
|
||||||
|
#endif
|
||||||
|
#ifndef GL_TEXTURE_RECTANGLE_ARB
|
||||||
|
#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
|
||||||
|
#endif
|
||||||
|
#ifndef GL_UNPACK_ROW_LENGTH
|
||||||
|
#define GL_UNPACK_ROW_LENGTH 0x0CF2
|
||||||
|
#endif
|
||||||
|
#ifndef GL_UNPACK_ALIGNMENT
|
||||||
|
#define GL_UNPACK_ALIGNMENT 0x0CF5
|
||||||
|
#endif
|
||||||
|
#ifndef GL_UNPACK_SKIP_ROWS
|
||||||
|
#define GL_UNPACK_SKIP_ROWS 0x0CF3
|
||||||
|
#endif
|
||||||
|
#ifndef GL_UNPACK_SKIP_PIXELS
|
||||||
|
#define GL_UNPACK_SKIP_PIXELS 0x0CF4
|
||||||
|
#endif
|
||||||
|
#ifndef GL_RGBA
|
||||||
|
#define GL_RGBA 0x1908
|
||||||
|
#endif
|
||||||
|
#ifndef GL_UNSIGNED_BYTE
|
||||||
|
#define GL_UNSIGNED_BYTE 0x1401
|
||||||
|
#endif
|
||||||
|
#ifndef GL_NO_ERROR
|
||||||
|
#define GL_NO_ERROR 0x0
|
||||||
|
#endif
|
||||||
|
#ifndef GL_TEXTURE_BINDING_RECTANGLE_ARB
|
||||||
|
#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6
|
||||||
|
#endif
|
||||||
|
|
||||||
static CoglHandle
|
static CoglHandle
|
||||||
create_source_rect (void)
|
create_source_rect (void)
|
||||||
{
|
{
|
||||||
#ifdef GL_TEXTURE_RECTANGLE_ARB
|
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
GLint prev_unpack_row_length;
|
int prev_unpack_row_length;
|
||||||
GLint prev_unpack_alignment;
|
int prev_unpack_alignment;
|
||||||
GLint prev_unpack_skip_rows;
|
int prev_unpack_skip_rows;
|
||||||
GLint prev_unpack_skip_pixles;
|
int prev_unpack_skip_pixles;
|
||||||
GLint prev_rectangle_binding;
|
int prev_rectangle_binding;
|
||||||
guint8 *data = g_malloc (256 * 256 * 4), *p = data;
|
guint8 *data = g_malloc (256 * 256 * 4), *p = data;
|
||||||
CoglHandle tex;
|
CoglHandle tex;
|
||||||
GLuint gl_tex;
|
guint gl_tex;
|
||||||
|
|
||||||
for (y = 0; y < 256; y++)
|
for (y = 0; y < 256; y++)
|
||||||
for (x = 0; x < 256; x++)
|
for (x = 0; x < 256; x++)
|
||||||
@ -78,12 +107,6 @@ create_source_rect (void)
|
|||||||
COGL_PIXEL_FORMAT_RGBA_8888);
|
COGL_PIXEL_FORMAT_RGBA_8888);
|
||||||
|
|
||||||
return tex;
|
return tex;
|
||||||
|
|
||||||
#else /* GL_TEXTURE_RECTANGLE_ARB */
|
|
||||||
|
|
||||||
return COGL_INVALID_HANDLE;
|
|
||||||
|
|
||||||
#endif /* GL_TEXTURE_RECTANGLE_ARB */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static CoglHandle
|
static CoglHandle
|
||||||
@ -116,7 +139,7 @@ create_source_2d (void)
|
|||||||
static void
|
static void
|
||||||
draw_frame (TestState *state)
|
draw_frame (TestState *state)
|
||||||
{
|
{
|
||||||
GLuint gl_tex;
|
guint gl_tex;
|
||||||
CoglHandle tex_rect = create_source_rect ();
|
CoglHandle tex_rect = create_source_rect ();
|
||||||
CoglHandle material_rect = cogl_material_new ();
|
CoglHandle material_rect = cogl_material_new ();
|
||||||
CoglHandle tex_2d = create_source_2d ();
|
CoglHandle tex_2d = create_source_2d ();
|
||||||
|
@ -26,8 +26,8 @@ typedef struct _TestState
|
|||||||
static void
|
static void
|
||||||
validate_result (TestState *state)
|
validate_result (TestState *state)
|
||||||
{
|
{
|
||||||
GLubyte pixel[4];
|
guint8 pixel[4];
|
||||||
GLint y_off = 90;
|
int y_off = 90;
|
||||||
|
|
||||||
if (g_test_verbose ())
|
if (g_test_verbose ())
|
||||||
g_print ("y_off = %d\n", y_off);
|
g_print ("y_off = %d\n", y_off);
|
||||||
@ -102,7 +102,7 @@ on_paint (ClutterActor *actor, TestState *state)
|
|||||||
cogl_vertex_buffer_enable (state->buffer, "gl_Color::blue");
|
cogl_vertex_buffer_enable (state->buffer, "gl_Color::blue");
|
||||||
cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff);
|
cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff);
|
||||||
cogl_vertex_buffer_draw (state->buffer,
|
cogl_vertex_buffer_draw (state->buffer,
|
||||||
GL_TRIANGLE_STRIP, /* mode */
|
COGL_VERTICES_MODE_TRIANGLE_STRIP, /* mode */
|
||||||
0, /* first */
|
0, /* first */
|
||||||
3); /* count */
|
3); /* count */
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ on_paint (ClutterActor *actor, TestState *state)
|
|||||||
cogl_vertex_buffer_disable (state->buffer, "gl_Color::blue");
|
cogl_vertex_buffer_disable (state->buffer, "gl_Color::blue");
|
||||||
cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff);
|
cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff);
|
||||||
cogl_vertex_buffer_draw (state->buffer,
|
cogl_vertex_buffer_draw (state->buffer,
|
||||||
GL_TRIANGLE_STRIP, /* mode */
|
COGL_VERTICES_MODE_TRIANGLE_STRIP, /* mode */
|
||||||
0, /* first */
|
0, /* first */
|
||||||
3); /* count */
|
3); /* count */
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ on_paint (ClutterActor *actor, TestState *state)
|
|||||||
cogl_vertex_buffer_enable (state->buffer, "gl_Color::blue");
|
cogl_vertex_buffer_enable (state->buffer, "gl_Color::blue");
|
||||||
cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff);
|
cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff);
|
||||||
cogl_vertex_buffer_draw (state->buffer,
|
cogl_vertex_buffer_draw (state->buffer,
|
||||||
GL_TRIANGLE_STRIP, /* mode */
|
COGL_VERTICES_MODE_TRIANGLE_STRIP, /* mode */
|
||||||
0, /* first */
|
0, /* first */
|
||||||
3); /* count */
|
3); /* count */
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ on_paint (ClutterActor *actor, TestState *state)
|
|||||||
cogl_set_source (state->material);
|
cogl_set_source (state->material);
|
||||||
cogl_material_set_color4ub (state->material, 0xff, 0xff, 0xff, 0xff);
|
cogl_material_set_color4ub (state->material, 0xff, 0xff, 0xff, 0xff);
|
||||||
cogl_vertex_buffer_draw (state->buffer,
|
cogl_vertex_buffer_draw (state->buffer,
|
||||||
GL_TRIANGLE_STRIP, /* mode */
|
COGL_VERTICES_MODE_TRIANGLE_STRIP, /* mode */
|
||||||
0, /* first */
|
0, /* first */
|
||||||
3); /* count */
|
3); /* count */
|
||||||
|
|
||||||
@ -197,19 +197,19 @@ test_cogl_vertex_buffer_contiguous (TestConformSimpleFixture *fixture,
|
|||||||
cogl_material_set_layer (state.material, 0, state.texture);
|
cogl_material_set_layer (state.material, 0, state.texture);
|
||||||
|
|
||||||
{
|
{
|
||||||
GLfloat triangle_verts[3][2] =
|
float triangle_verts[3][2] =
|
||||||
{
|
{
|
||||||
{0.0, 0.0},
|
{0.0, 0.0},
|
||||||
{100.0, 100.0},
|
{100.0, 100.0},
|
||||||
{0.0, 100.0}
|
{0.0, 100.0}
|
||||||
};
|
};
|
||||||
GLbyte triangle_colors[3][4] =
|
guint8 triangle_colors[3][4] =
|
||||||
{
|
{
|
||||||
{0x00, 0x00, 0xff, 0xff}, /* blue */
|
{0x00, 0x00, 0xff, 0xff}, /* blue */
|
||||||
{0x00, 0x00, 0xff, 0x00}, /* transparent blue */
|
{0x00, 0x00, 0xff, 0x00}, /* transparent blue */
|
||||||
{0x00, 0x00, 0xff, 0x00} /* transparent blue */
|
{0x00, 0x00, 0xff, 0x00} /* transparent blue */
|
||||||
};
|
};
|
||||||
GLfloat triangle_tex_coords[3][2] =
|
float triangle_tex_coords[3][2] =
|
||||||
{
|
{
|
||||||
{0.0, 0.0},
|
{0.0, 0.0},
|
||||||
{1.0, 1.0},
|
{1.0, 1.0},
|
||||||
@ -219,21 +219,21 @@ test_cogl_vertex_buffer_contiguous (TestConformSimpleFixture *fixture,
|
|||||||
cogl_vertex_buffer_add (state.buffer,
|
cogl_vertex_buffer_add (state.buffer,
|
||||||
"gl_Vertex",
|
"gl_Vertex",
|
||||||
2, /* n components */
|
2, /* n components */
|
||||||
GL_FLOAT,
|
COGL_ATTRIBUTE_TYPE_FLOAT,
|
||||||
FALSE, /* normalized */
|
FALSE, /* normalized */
|
||||||
0, /* stride */
|
0, /* stride */
|
||||||
triangle_verts);
|
triangle_verts);
|
||||||
cogl_vertex_buffer_add (state.buffer,
|
cogl_vertex_buffer_add (state.buffer,
|
||||||
"gl_Color::blue",
|
"gl_Color::blue",
|
||||||
4, /* n components */
|
4, /* n components */
|
||||||
GL_UNSIGNED_BYTE,
|
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE,
|
||||||
FALSE, /* normalized */
|
FALSE, /* normalized */
|
||||||
0, /* stride */
|
0, /* stride */
|
||||||
triangle_colors);
|
triangle_colors);
|
||||||
cogl_vertex_buffer_add (state.buffer,
|
cogl_vertex_buffer_add (state.buffer,
|
||||||
"gl_MultiTexCoord0",
|
"gl_MultiTexCoord0",
|
||||||
2, /* n components */
|
2, /* n components */
|
||||||
GL_FLOAT,
|
COGL_ATTRIBUTE_TYPE_FLOAT,
|
||||||
FALSE, /* normalized */
|
FALSE, /* normalized */
|
||||||
0, /* stride */
|
0, /* stride */
|
||||||
triangle_tex_coords);
|
triangle_tex_coords);
|
||||||
|
@ -20,21 +20,16 @@ typedef struct _TestState
|
|||||||
|
|
||||||
typedef struct _InterlevedVertex
|
typedef struct _InterlevedVertex
|
||||||
{
|
{
|
||||||
GLfloat x;
|
float x, y;
|
||||||
GLfloat y;
|
guint8 r, g, b, a;
|
||||||
|
|
||||||
GLubyte r;
|
|
||||||
GLubyte g;
|
|
||||||
GLubyte b;
|
|
||||||
GLubyte a;
|
|
||||||
} InterlevedVertex;
|
} InterlevedVertex;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
validate_result (TestState *state)
|
validate_result (TestState *state)
|
||||||
{
|
{
|
||||||
GLubyte pixel[4];
|
guint8 pixel[4];
|
||||||
GLint y_off = 90;
|
int y_off = 90;
|
||||||
|
|
||||||
/* NB: We ignore the alpha, since we don't know if our render target is
|
/* NB: We ignore the alpha, since we don't know if our render target is
|
||||||
* RGB or RGBA */
|
* RGB or RGBA */
|
||||||
@ -67,7 +62,7 @@ on_paint (ClutterActor *actor, TestState *state)
|
|||||||
{
|
{
|
||||||
/* Draw a faded blue triangle */
|
/* Draw a faded blue triangle */
|
||||||
cogl_vertex_buffer_draw (state->buffer,
|
cogl_vertex_buffer_draw (state->buffer,
|
||||||
GL_TRIANGLE_STRIP, /* mode */
|
COGL_VERTICES_MODE_TRIANGLE_STRIP, /* mode */
|
||||||
0, /* first */
|
0, /* first */
|
||||||
3); /* count */
|
3); /* count */
|
||||||
|
|
||||||
@ -134,14 +129,14 @@ test_cogl_vertex_buffer_interleved (TestConformSimpleFixture *fixture,
|
|||||||
cogl_vertex_buffer_add (state.buffer,
|
cogl_vertex_buffer_add (state.buffer,
|
||||||
"gl_Vertex",
|
"gl_Vertex",
|
||||||
2, /* n components */
|
2, /* n components */
|
||||||
GL_FLOAT,
|
COGL_ATTRIBUTE_TYPE_FLOAT,
|
||||||
FALSE, /* normalized */
|
FALSE, /* normalized */
|
||||||
12, /* stride */
|
12, /* stride */
|
||||||
&verts[0].x);
|
&verts[0].x);
|
||||||
cogl_vertex_buffer_add (state.buffer,
|
cogl_vertex_buffer_add (state.buffer,
|
||||||
"gl_Color",
|
"gl_Color",
|
||||||
4, /* n components */
|
4, /* n components */
|
||||||
GL_UNSIGNED_BYTE,
|
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE,
|
||||||
FALSE, /* normalized */
|
FALSE, /* normalized */
|
||||||
12, /* stride */
|
12, /* stride */
|
||||||
&verts[0].r);
|
&verts[0].r);
|
||||||
|
@ -20,8 +20,8 @@ typedef struct _TestState
|
|||||||
static void
|
static void
|
||||||
validate_result (TestState *state)
|
validate_result (TestState *state)
|
||||||
{
|
{
|
||||||
GLubyte pixel[4];
|
guint8 pixel[4];
|
||||||
GLint y_off = 90;
|
int y_off = 90;
|
||||||
|
|
||||||
/* NB: We ignore the alpha, since we don't know if our render target is
|
/* NB: We ignore the alpha, since we don't know if our render target is
|
||||||
* RGB or RGBA */
|
* RGB or RGBA */
|
||||||
@ -61,13 +61,13 @@ validate_result (TestState *state)
|
|||||||
static void
|
static void
|
||||||
on_paint (ClutterActor *actor, TestState *state)
|
on_paint (ClutterActor *actor, TestState *state)
|
||||||
{
|
{
|
||||||
GLfloat triangle_verts[3][2] =
|
float triangle_verts[3][2] =
|
||||||
{
|
{
|
||||||
{100.0, 0.0},
|
{100.0, 0.0},
|
||||||
{200.0, 100.0},
|
{200.0, 100.0},
|
||||||
{100.0, 100.0}
|
{100.0, 100.0}
|
||||||
};
|
};
|
||||||
GLbyte triangle_colors[3][4] =
|
guint8 triangle_colors[3][4] =
|
||||||
{
|
{
|
||||||
{0x00, 0xff, 0x00, 0xff}, /* blue */
|
{0x00, 0xff, 0x00, 0xff}, /* blue */
|
||||||
{0x00, 0xff, 0x00, 0x00}, /* transparent blue */
|
{0x00, 0xff, 0x00, 0x00}, /* transparent blue */
|
||||||
@ -83,7 +83,7 @@ on_paint (ClutterActor *actor, TestState *state)
|
|||||||
cogl_vertex_buffer_add (state->buffer,
|
cogl_vertex_buffer_add (state->buffer,
|
||||||
"gl_Vertex",
|
"gl_Vertex",
|
||||||
2, /* n components */
|
2, /* n components */
|
||||||
GL_FLOAT,
|
COGL_ATTRIBUTE_TYPE_FLOAT,
|
||||||
FALSE, /* normalized */
|
FALSE, /* normalized */
|
||||||
0, /* stride */
|
0, /* stride */
|
||||||
triangle_verts);
|
triangle_verts);
|
||||||
@ -91,7 +91,7 @@ on_paint (ClutterActor *actor, TestState *state)
|
|||||||
cogl_vertex_buffer_submit (state->buffer);
|
cogl_vertex_buffer_submit (state->buffer);
|
||||||
|
|
||||||
cogl_vertex_buffer_draw (state->buffer,
|
cogl_vertex_buffer_draw (state->buffer,
|
||||||
GL_TRIANGLE_STRIP, /* mode */
|
COGL_VERTICES_MODE_TRIANGLE_STRIP, /* mode */
|
||||||
0, /* first */
|
0, /* first */
|
||||||
3); /* count */
|
3); /* count */
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ on_paint (ClutterActor *actor, TestState *state)
|
|||||||
cogl_vertex_buffer_add (state->buffer,
|
cogl_vertex_buffer_add (state->buffer,
|
||||||
"gl_Color",
|
"gl_Color",
|
||||||
4, /* n components */
|
4, /* n components */
|
||||||
GL_UNSIGNED_BYTE,
|
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE,
|
||||||
FALSE, /* normalized */
|
FALSE, /* normalized */
|
||||||
0, /* stride */
|
0, /* stride */
|
||||||
triangle_colors);
|
triangle_colors);
|
||||||
@ -110,7 +110,7 @@ on_paint (ClutterActor *actor, TestState *state)
|
|||||||
|
|
||||||
cogl_translate (100, 0, 0);
|
cogl_translate (100, 0, 0);
|
||||||
cogl_vertex_buffer_draw (state->buffer,
|
cogl_vertex_buffer_draw (state->buffer,
|
||||||
GL_TRIANGLE_STRIP, /* mode */
|
COGL_VERTICES_MODE_TRIANGLE_STRIP, /* mode */
|
||||||
0, /* first */
|
0, /* first */
|
||||||
3); /* count */
|
3); /* count */
|
||||||
|
|
||||||
@ -154,13 +154,13 @@ test_cogl_vertex_buffer_mutability (TestConformSimpleFixture *fixture,
|
|||||||
g_signal_connect (group, "paint", G_CALLBACK (on_paint), &state);
|
g_signal_connect (group, "paint", G_CALLBACK (on_paint), &state);
|
||||||
|
|
||||||
{
|
{
|
||||||
GLfloat triangle_verts[3][2] =
|
float triangle_verts[3][2] =
|
||||||
{
|
{
|
||||||
{0.0, 0.0},
|
{0.0, 0.0},
|
||||||
{100.0, 100.0},
|
{100.0, 100.0},
|
||||||
{0.0, 100.0}
|
{0.0, 100.0}
|
||||||
};
|
};
|
||||||
GLbyte triangle_colors[3][4] =
|
guint8 triangle_colors[3][4] =
|
||||||
{
|
{
|
||||||
{0x00, 0x00, 0xff, 0xff}, /* blue */
|
{0x00, 0x00, 0xff, 0xff}, /* blue */
|
||||||
{0x00, 0x00, 0xff, 0x00}, /* transparent blue */
|
{0x00, 0x00, 0xff, 0x00}, /* transparent blue */
|
||||||
@ -170,14 +170,14 @@ test_cogl_vertex_buffer_mutability (TestConformSimpleFixture *fixture,
|
|||||||
cogl_vertex_buffer_add (state.buffer,
|
cogl_vertex_buffer_add (state.buffer,
|
||||||
"gl_Vertex",
|
"gl_Vertex",
|
||||||
2, /* n components */
|
2, /* n components */
|
||||||
GL_FLOAT,
|
COGL_ATTRIBUTE_TYPE_FLOAT,
|
||||||
FALSE, /* normalized */
|
FALSE, /* normalized */
|
||||||
0, /* stride */
|
0, /* stride */
|
||||||
triangle_verts);
|
triangle_verts);
|
||||||
cogl_vertex_buffer_add (state.buffer,
|
cogl_vertex_buffer_add (state.buffer,
|
||||||
"gl_Color",
|
"gl_Color",
|
||||||
4, /* n components */
|
4, /* n components */
|
||||||
GL_UNSIGNED_BYTE,
|
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE,
|
||||||
FALSE, /* normalized */
|
FALSE, /* normalized */
|
||||||
0, /* stride */
|
0, /* stride */
|
||||||
triangle_colors);
|
triangle_colors);
|
||||||
|
@ -27,19 +27,19 @@ typedef struct _TestConformTodo
|
|||||||
|
|
||||||
typedef struct _TestConformGLFunctions
|
typedef struct _TestConformGLFunctions
|
||||||
{
|
{
|
||||||
const GLubyte * (* glGetString) (GLenum name);
|
const guint8 * (* glGetString) (guint name);
|
||||||
void (* glGetIntegerv) (GLenum pname, GLint *params);
|
void (* glGetIntegerv) (guint pname, int *params);
|
||||||
void (* glPixelStorei) (GLenum pname, GLint param);
|
void (* glPixelStorei) (guint pname, int param);
|
||||||
void (* glBindTexture) (GLenum target, GLuint texture);
|
void (* glBindTexture) (guint target, guint texture);
|
||||||
void (* glGenTextures) (GLsizei n, GLuint *textures);
|
void (* glGenTextures) (int n, guint *textures);
|
||||||
GLenum (* glGetError) (void);
|
guint (* glGetError) (void);
|
||||||
void (* glDeleteTextures) (GLsizei n, const GLuint *textures);
|
void (* glDeleteTextures) (int n, const guint *textures);
|
||||||
void (* glTexImage2D) (GLenum target, GLint level,
|
void (* glTexImage2D) (guint target, int level,
|
||||||
GLint internalFormat,
|
int internalFormat,
|
||||||
GLsizei width, GLsizei height,
|
int width, int height,
|
||||||
GLint border, GLenum format, GLenum type,
|
int border, guint format, guint type,
|
||||||
const GLvoid *pixels);
|
const void *pixels);
|
||||||
void (* glTexParameteri) (GLenum target, GLenum pname, GLint param);
|
void (* glTexParameteri) (guint target, guint pname, int param);
|
||||||
} TestConformGLFunctions;
|
} TestConformGLFunctions;
|
||||||
|
|
||||||
void test_conform_get_gl_functions (TestConformGLFunctions *functions);
|
void test_conform_get_gl_functions (TestConformGLFunctions *functions);
|
||||||
|
@ -4,6 +4,31 @@
|
|||||||
#include <clutter/clutter.h>
|
#include <clutter/clutter.h>
|
||||||
#include <cogl/cogl.h>
|
#include <cogl/cogl.h>
|
||||||
|
|
||||||
|
#ifndef GL_UNPACK_ALIGNMENT
|
||||||
|
#define GL_UNPACK_ALIGNMENT 0x0CF5
|
||||||
|
#endif
|
||||||
|
#ifndef GL_TEXTURE_BINDING_2D
|
||||||
|
#define GL_TEXTURE_BINDING_2D 0x8069
|
||||||
|
#endif
|
||||||
|
#ifndef GL_TEXTURE_2D
|
||||||
|
#define GL_TEXTURE_2D 0x0DE1
|
||||||
|
#endif
|
||||||
|
#ifndef GL_RGB
|
||||||
|
#define GL_RGB 0x1907
|
||||||
|
#endif
|
||||||
|
#ifndef GL_UNSIGNED_BYTE
|
||||||
|
#define GL_UNSIGNED_BYTE 0x1401
|
||||||
|
#endif
|
||||||
|
#ifndef GL_TEXTURE_MAG_FILTER
|
||||||
|
#define GL_TEXTURE_MAG_FILTER 0x2800
|
||||||
|
#endif
|
||||||
|
#ifndef GL_LINEAR
|
||||||
|
#define GL_LINEAR 0x1208
|
||||||
|
#endif
|
||||||
|
#ifndef GL_TEXTURE_MIN_FILTER
|
||||||
|
#define GL_TEXTURE_MIN_FILTER 0x2801
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Coglbox declaration
|
/* Coglbox declaration
|
||||||
*--------------------------------------------------*/
|
*--------------------------------------------------*/
|
||||||
|
|
||||||
@ -68,27 +93,27 @@ G_DEFINE_TYPE (TestCoglbox, test_coglbox, CLUTTER_TYPE_ACTOR);
|
|||||||
|
|
||||||
struct _TestCoglboxPrivate
|
struct _TestCoglboxPrivate
|
||||||
{
|
{
|
||||||
GLuint gl_handle;
|
guint gl_handle;
|
||||||
CoglHandle cogl_handle;
|
CoglHandle cogl_handle;
|
||||||
|
|
||||||
void
|
void
|
||||||
(* glGetIntegerv) (GLenum pname, GLint *params);
|
(* glGetIntegerv) (guint pname, int *params);
|
||||||
void
|
void
|
||||||
(* glPixelStorei) (GLenum pname, GLint param);
|
(* glPixelStorei) (guint pname, int param);
|
||||||
void
|
void
|
||||||
(* glTexParameteri) (GLenum target, GLenum pname, GLint param);
|
(* glTexParameteri) (guint target, guint pname, int param);
|
||||||
void
|
void
|
||||||
(* glTexImage2D) (GLenum target, GLint level,
|
(* glTexImage2D) (guint target, int level,
|
||||||
GLint internalFormat,
|
int internalFormat,
|
||||||
GLsizei width, GLsizei height,
|
int width, int height,
|
||||||
GLint border, GLenum format, GLenum type,
|
int border, guint format, guint type,
|
||||||
const GLvoid *pixels);
|
const void *pixels);
|
||||||
void
|
void
|
||||||
(* glGenTextures) (GLsizei n, GLuint *textures);
|
(* glGenTextures) (int n, guint *textures);
|
||||||
void
|
void
|
||||||
(* glDeleteTextures) (GLsizei n, const GLuint *textures);
|
(* glDeleteTextures) (int n, const guint *textures);
|
||||||
void
|
void
|
||||||
(* glBindTexture) (GLenum target, GLuint texture);
|
(* glBindTexture) (guint target, guint texture);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Coglbox implementation
|
/* Coglbox implementation
|
||||||
@ -140,8 +165,8 @@ test_coglbox_init (TestCoglbox *self)
|
|||||||
{
|
{
|
||||||
TestCoglboxPrivate *priv;
|
TestCoglboxPrivate *priv;
|
||||||
guchar data[12];
|
guchar data[12];
|
||||||
GLint prev_unpack_alignment;
|
int prev_unpack_alignment;
|
||||||
GLint prev_2d_texture_binding;
|
int prev_2d_texture_binding;
|
||||||
|
|
||||||
self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self);
|
self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self);
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ typedef struct _TestState
|
|||||||
ClutterActor *dummy;
|
ClutterActor *dummy;
|
||||||
CoglHandle buffer;
|
CoglHandle buffer;
|
||||||
float *quad_mesh_verts;
|
float *quad_mesh_verts;
|
||||||
GLubyte *quad_mesh_colors;
|
guint8 *quad_mesh_colors;
|
||||||
GLushort *static_indices;
|
guint16 *static_indices;
|
||||||
guint n_static_indices;
|
guint n_static_indices;
|
||||||
CoglHandle indices;
|
CoglHandle indices;
|
||||||
ClutterTimeline *timeline;
|
ClutterTimeline *timeline;
|
||||||
@ -86,7 +86,7 @@ frame_cb (ClutterTimeline *timeline,
|
|||||||
float ripple_sin = sinf (ripple_angle);
|
float ripple_sin = sinf (ripple_angle);
|
||||||
|
|
||||||
float h, s, l;
|
float h, s, l;
|
||||||
GLubyte *color;
|
guint8 *color;
|
||||||
|
|
||||||
vert[2] = (wave_sin * WAVE_DEPTH) + (ripple_sin * RIPPLE_DEPTH);
|
vert[2] = (wave_sin * WAVE_DEPTH) + (ripple_sin * RIPPLE_DEPTH);
|
||||||
|
|
||||||
@ -110,14 +110,14 @@ frame_cb (ClutterTimeline *timeline,
|
|||||||
cogl_vertex_buffer_add (state->buffer,
|
cogl_vertex_buffer_add (state->buffer,
|
||||||
"gl_Vertex",
|
"gl_Vertex",
|
||||||
3, /* n components */
|
3, /* n components */
|
||||||
GL_FLOAT,
|
COGL_ATTRIBUTE_TYPE_FLOAT,
|
||||||
FALSE, /* normalized */
|
FALSE, /* normalized */
|
||||||
0, /* stride */
|
0, /* stride */
|
||||||
state->quad_mesh_verts);
|
state->quad_mesh_verts);
|
||||||
cogl_vertex_buffer_add (state->buffer,
|
cogl_vertex_buffer_add (state->buffer,
|
||||||
"gl_Color",
|
"gl_Color",
|
||||||
4, /* n components */
|
4, /* n components */
|
||||||
GL_UNSIGNED_BYTE,
|
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE,
|
||||||
FALSE, /* normalized */
|
FALSE, /* normalized */
|
||||||
0, /* stride */
|
0, /* stride */
|
||||||
state->quad_mesh_colors);
|
state->quad_mesh_colors);
|
||||||
@ -157,7 +157,7 @@ init_static_index_arrays (TestState *state)
|
|||||||
{
|
{
|
||||||
guint n_indices;
|
guint n_indices;
|
||||||
int x, y;
|
int x, y;
|
||||||
GLushort *i;
|
guint16 *i;
|
||||||
guint dir;
|
guint dir;
|
||||||
|
|
||||||
/* - Each row takes (2 + 2 * MESH_WIDTH indices)
|
/* - Each row takes (2 + 2 * MESH_WIDTH indices)
|
||||||
@ -167,7 +167,7 @@ init_static_index_arrays (TestState *state)
|
|||||||
* - It takes one extra index for linking between rows (MESH_HEIGHT - 1)
|
* - It takes one extra index for linking between rows (MESH_HEIGHT - 1)
|
||||||
* - A 2 x 3 mesh == 20 indices... */
|
* - A 2 x 3 mesh == 20 indices... */
|
||||||
n_indices = (2 + 2 * MESH_WIDTH) * MESH_HEIGHT + (MESH_HEIGHT - 1);
|
n_indices = (2 + 2 * MESH_WIDTH) * MESH_HEIGHT + (MESH_HEIGHT - 1);
|
||||||
state->static_indices = g_malloc (sizeof (GLushort) * n_indices);
|
state->static_indices = g_malloc (sizeof (guint16) * n_indices);
|
||||||
state->n_static_indices = n_indices;
|
state->n_static_indices = n_indices;
|
||||||
|
|
||||||
#define MESH_INDEX(X, Y) (Y) * (MESH_WIDTH + 1) + (X)
|
#define MESH_INDEX(X, Y) (Y) * (MESH_WIDTH + 1) + (X)
|
||||||
@ -258,7 +258,7 @@ init_quad_mesh (TestState *state)
|
|||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
float *vert;
|
float *vert;
|
||||||
GLubyte *color;
|
guint8 *color;
|
||||||
|
|
||||||
/* Note: we maintain the minimum number of vertices possible. This minimizes
|
/* Note: we maintain the minimum number of vertices possible. This minimizes
|
||||||
* the work required when we come to morph the geometry.
|
* the work required when we come to morph the geometry.
|
||||||
@ -271,7 +271,7 @@ init_quad_mesh (TestState *state)
|
|||||||
g_malloc0 (sizeof (float) * 3 * (MESH_WIDTH + 1) * (MESH_HEIGHT + 1));
|
g_malloc0 (sizeof (float) * 3 * (MESH_WIDTH + 1) * (MESH_HEIGHT + 1));
|
||||||
|
|
||||||
state->quad_mesh_colors =
|
state->quad_mesh_colors =
|
||||||
g_malloc0 (sizeof (GLubyte) * 4 * (MESH_WIDTH + 1) * (MESH_HEIGHT + 1));
|
g_malloc0 (sizeof (guint8) * 4 * (MESH_WIDTH + 1) * (MESH_HEIGHT + 1));
|
||||||
|
|
||||||
vert = state->quad_mesh_verts;
|
vert = state->quad_mesh_verts;
|
||||||
color = state->quad_mesh_colors;
|
color = state->quad_mesh_colors;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user