gchar *name;
GType type;
GValue value;
- GLint location;
+ int location;
} ShaderUniform;
struct _ClutterShaderEffectPrivate
if (CLUTTER_VALUE_HOLDS_SHADER_FLOAT (&uniform->value))
{
- const GLfloat *floats;
+ const float *floats;
floats = clutter_value_get_shader_float (&uniform->value, &size);
cogl_program_set_uniform_float (priv->program, uniform->location,
}
else if (CLUTTER_VALUE_HOLDS_SHADER_INT (&uniform->value))
{
- const GLint *ints;
+ const int *ints;
ints = clutter_value_get_shader_int (&uniform->value, &size);
cogl_program_set_uniform_int (priv->program, uniform->location,
}
else if (CLUTTER_VALUE_HOLDS_SHADER_MATRIX (&uniform->value))
{
- const GLfloat *matrix;
+ const float *matrix;
matrix = clutter_value_get_shader_matrix (&uniform->value, &size);
cogl_program_set_uniform_matrix (priv->program, uniform->location,
}
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,
1, 1,
}
else if (G_VALUE_HOLDS_DOUBLE (&uniform->value))
{
- const GLfloat float_val =
- (GLfloat) g_value_get_double (&uniform->value);
+ const float float_val =
+ (float) g_value_get_double (&uniform->value);
cogl_program_set_uniform_float (priv->program, uniform->location,
1, 1,
}
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,
1, 1,
struct _ClutterShaderFloat
{
gint size;
- GLfloat value[4];
+ float value[4];
};
struct _ClutterShaderInt
{
gint size;
- GLint value[4];
+ int value[4];
};
struct _ClutterShaderMatrix
{
gint size;
- GLfloat value[16];
+ float value[16];
};
static gpointer
shader_int->size = size;
for (i = 0; i < size; i++)
- shader_int->value[i] = (GLint) ints[i];
+ shader_int->value[i] = ints[i];
}
/**
int width,
int height)
{
- GLubyte *data;
+ guint8 *data;
cairo_surface_t *surface;
static int read_count = 0;
char *filename = g_strdup_printf ("%s-%05d.png",
const GValue *value)
{
ClutterShaderPrivate *priv;
- GLint location = 0;
+ int location = 0;
gsize size;
g_return_if_fail (CLUTTER_IS_SHADER (shader));
if (CLUTTER_VALUE_HOLDS_SHADER_FLOAT (value))
{
- const GLfloat *floats;
+ const float *floats;
floats = clutter_value_get_shader_float (value, &size);
cogl_program_set_uniform_float (priv->program,
}
else if (CLUTTER_VALUE_HOLDS_SHADER_MATRIX (value))
{
- const GLfloat *matrix;
+ const float *matrix;
matrix = clutter_value_get_shader_matrix (value, &size);
cogl_program_set_uniform_matrix (priv->program,
}
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,
location, 1, 1, &float_val);
#define MASK_BLUE(COLOR) ((COLOR & 0xff00) >> 8)
#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
{
ClutterGeometry stage_geom;
static void
check_pixel (TestState *state, int x, int y, guint32 color)
{
- GLint y_off;
- GLint x_off;
- GLubyte pixel[4];
+ int y_off;
+ int x_off;
+ guint8 pixel[4];
guint8 r = MASK_RED (color);
guint8 g = MASK_GREEN (color);
guint8 b = MASK_BLUE (color);
guint8 red_pixel[] = { 0xff, 0x00, 0x00, 0xff };
CoglHandle white_texture;
CoglHandle red_texture;
- GLint n_layers;
+ int n_layers;
int i;
/* Create a material that uses the maximum number of layers. All but
#ifdef COGL_HAS_GLES2
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
GL_MAX_TEXTURE_IMAGE_UNITS instead */
gl_functions.glGetIntegerv (GL_MAX_TEXTURE_IMAGE_UNITS, &n_image_units);
static void
-check_pixel (GLubyte *pixel, guint32 color)
+check_pixel (guint8 *pixel, guint32 color)
{
guint8 r = MASK_RED (color);
guint8 g = MASK_GREEN (color);
ClutterActor *stage;
} 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
create_source_rect (void)
{
-#ifdef GL_TEXTURE_RECTANGLE_ARB
-
int x, y;
- GLint prev_unpack_row_length;
- GLint prev_unpack_alignment;
- GLint prev_unpack_skip_rows;
- GLint prev_unpack_skip_pixles;
- GLint prev_rectangle_binding;
+ int prev_unpack_row_length;
+ int prev_unpack_alignment;
+ int prev_unpack_skip_rows;
+ int prev_unpack_skip_pixles;
+ int prev_rectangle_binding;
guint8 *data = g_malloc (256 * 256 * 4), *p = data;
CoglHandle tex;
- GLuint gl_tex;
+ guint gl_tex;
for (y = 0; y < 256; y++)
for (x = 0; x < 256; x++)
COGL_PIXEL_FORMAT_RGBA_8888);
return tex;
-
-#else /* GL_TEXTURE_RECTANGLE_ARB */
-
- return COGL_INVALID_HANDLE;
-
-#endif /* GL_TEXTURE_RECTANGLE_ARB */
}
static CoglHandle
static void
draw_frame (TestState *state)
{
- GLuint gl_tex;
+ guint gl_tex;
CoglHandle tex_rect = create_source_rect ();
CoglHandle material_rect = cogl_material_new ();
CoglHandle tex_2d = create_source_2d ();
static void
validate_result (TestState *state)
{
- GLubyte pixel[4];
- GLint y_off = 90;
+ guint8 pixel[4];
+ int y_off = 90;
if (g_test_verbose ())
g_print ("y_off = %d\n", y_off);
cogl_vertex_buffer_enable (state->buffer, "gl_Color::blue");
cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff);
cogl_vertex_buffer_draw (state->buffer,
- GL_TRIANGLE_STRIP, /* mode */
+ COGL_VERTICES_MODE_TRIANGLE_STRIP, /* mode */
0, /* first */
3); /* count */
cogl_vertex_buffer_disable (state->buffer, "gl_Color::blue");
cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff);
cogl_vertex_buffer_draw (state->buffer,
- GL_TRIANGLE_STRIP, /* mode */
+ COGL_VERTICES_MODE_TRIANGLE_STRIP, /* mode */
0, /* first */
3); /* count */
cogl_vertex_buffer_enable (state->buffer, "gl_Color::blue");
cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff);
cogl_vertex_buffer_draw (state->buffer,
- GL_TRIANGLE_STRIP, /* mode */
+ COGL_VERTICES_MODE_TRIANGLE_STRIP, /* mode */
0, /* first */
3); /* count */
cogl_set_source (state->material);
cogl_material_set_color4ub (state->material, 0xff, 0xff, 0xff, 0xff);
cogl_vertex_buffer_draw (state->buffer,
- GL_TRIANGLE_STRIP, /* mode */
+ COGL_VERTICES_MODE_TRIANGLE_STRIP, /* mode */
0, /* first */
3); /* count */
cogl_material_set_layer (state.material, 0, state.texture);
{
- GLfloat triangle_verts[3][2] =
+ float triangle_verts[3][2] =
{
{0.0, 0.0},
{100.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, 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},
{1.0, 1.0},
cogl_vertex_buffer_add (state.buffer,
"gl_Vertex",
2, /* n components */
- GL_FLOAT,
+ COGL_ATTRIBUTE_TYPE_FLOAT,
FALSE, /* normalized */
0, /* stride */
triangle_verts);
cogl_vertex_buffer_add (state.buffer,
"gl_Color::blue",
4, /* n components */
- GL_UNSIGNED_BYTE,
+ COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE,
FALSE, /* normalized */
0, /* stride */
triangle_colors);
cogl_vertex_buffer_add (state.buffer,
"gl_MultiTexCoord0",
2, /* n components */
- GL_FLOAT,
+ COGL_ATTRIBUTE_TYPE_FLOAT,
FALSE, /* normalized */
0, /* stride */
triangle_tex_coords);
typedef struct _InterlevedVertex
{
- GLfloat x;
- GLfloat y;
-
- GLubyte r;
- GLubyte g;
- GLubyte b;
- GLubyte a;
+ float x, y;
+ guint8 r, g, b, a;
} InterlevedVertex;
static void
validate_result (TestState *state)
{
- GLubyte pixel[4];
- GLint y_off = 90;
+ guint8 pixel[4];
+ int y_off = 90;
/* NB: We ignore the alpha, since we don't know if our render target is
* RGB or RGBA */
{
/* Draw a faded blue triangle */
cogl_vertex_buffer_draw (state->buffer,
- GL_TRIANGLE_STRIP, /* mode */
+ COGL_VERTICES_MODE_TRIANGLE_STRIP, /* mode */
0, /* first */
3); /* count */
cogl_vertex_buffer_add (state.buffer,
"gl_Vertex",
2, /* n components */
- GL_FLOAT,
+ COGL_ATTRIBUTE_TYPE_FLOAT,
FALSE, /* normalized */
12, /* stride */
&verts[0].x);
cogl_vertex_buffer_add (state.buffer,
"gl_Color",
4, /* n components */
- GL_UNSIGNED_BYTE,
+ COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE,
FALSE, /* normalized */
12, /* stride */
&verts[0].r);
static void
validate_result (TestState *state)
{
- GLubyte pixel[4];
- GLint y_off = 90;
+ guint8 pixel[4];
+ int y_off = 90;
/* NB: We ignore the alpha, since we don't know if our render target is
* RGB or RGBA */
static void
on_paint (ClutterActor *actor, TestState *state)
{
- GLfloat triangle_verts[3][2] =
+ float triangle_verts[3][2] =
{
{100.0, 0.0},
{200.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, 0x00}, /* transparent blue */
cogl_vertex_buffer_add (state->buffer,
"gl_Vertex",
2, /* n components */
- GL_FLOAT,
+ COGL_ATTRIBUTE_TYPE_FLOAT,
FALSE, /* normalized */
0, /* stride */
triangle_verts);
cogl_vertex_buffer_submit (state->buffer);
cogl_vertex_buffer_draw (state->buffer,
- GL_TRIANGLE_STRIP, /* mode */
+ COGL_VERTICES_MODE_TRIANGLE_STRIP, /* mode */
0, /* first */
3); /* count */
cogl_vertex_buffer_add (state->buffer,
"gl_Color",
4, /* n components */
- GL_UNSIGNED_BYTE,
+ COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE,
FALSE, /* normalized */
0, /* stride */
triangle_colors);
cogl_translate (100, 0, 0);
cogl_vertex_buffer_draw (state->buffer,
- GL_TRIANGLE_STRIP, /* mode */
+ COGL_VERTICES_MODE_TRIANGLE_STRIP, /* mode */
0, /* first */
3); /* count */
g_signal_connect (group, "paint", G_CALLBACK (on_paint), &state);
{
- GLfloat triangle_verts[3][2] =
+ float triangle_verts[3][2] =
{
{0.0, 0.0},
{100.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, 0x00}, /* transparent blue */
cogl_vertex_buffer_add (state.buffer,
"gl_Vertex",
2, /* n components */
- GL_FLOAT,
+ COGL_ATTRIBUTE_TYPE_FLOAT,
FALSE, /* normalized */
0, /* stride */
triangle_verts);
cogl_vertex_buffer_add (state.buffer,
"gl_Color",
4, /* n components */
- GL_UNSIGNED_BYTE,
+ COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE,
FALSE, /* normalized */
0, /* stride */
triangle_colors);
typedef struct _TestConformGLFunctions
{
- const GLubyte * (* glGetString) (GLenum name);
- void (* glGetIntegerv) (GLenum pname, GLint *params);
- void (* glPixelStorei) (GLenum pname, GLint param);
- void (* glBindTexture) (GLenum target, GLuint texture);
- void (* glGenTextures) (GLsizei n, GLuint *textures);
- GLenum (* glGetError) (void);
- void (* glDeleteTextures) (GLsizei n, const GLuint *textures);
- void (* glTexImage2D) (GLenum target, GLint level,
- GLint internalFormat,
- GLsizei width, GLsizei height,
- GLint border, GLenum format, GLenum type,
- const GLvoid *pixels);
- void (* glTexParameteri) (GLenum target, GLenum pname, GLint param);
+ const guint8 * (* glGetString) (guint name);
+ void (* glGetIntegerv) (guint pname, int *params);
+ void (* glPixelStorei) (guint pname, int param);
+ void (* glBindTexture) (guint target, guint texture);
+ void (* glGenTextures) (int n, guint *textures);
+ guint (* glGetError) (void);
+ void (* glDeleteTextures) (int n, const guint *textures);
+ void (* glTexImage2D) (guint target, int level,
+ int internalFormat,
+ int width, int height,
+ int border, guint format, guint type,
+ const void *pixels);
+ void (* glTexParameteri) (guint target, guint pname, int param);
} TestConformGLFunctions;
void test_conform_get_gl_functions (TestConformGLFunctions *functions);
#include <clutter/clutter.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
*--------------------------------------------------*/
struct _TestCoglboxPrivate
{
- GLuint gl_handle;
+ guint gl_handle;
CoglHandle cogl_handle;
void
- (* glGetIntegerv) (GLenum pname, GLint *params);
+ (* glGetIntegerv) (guint pname, int *params);
void
- (* glPixelStorei) (GLenum pname, GLint param);
+ (* glPixelStorei) (guint pname, int param);
void
- (* glTexParameteri) (GLenum target, GLenum pname, GLint param);
+ (* glTexParameteri) (guint target, guint pname, int param);
void
- (* glTexImage2D) (GLenum target, GLint level,
- GLint internalFormat,
- GLsizei width, GLsizei height,
- GLint border, GLenum format, GLenum type,
- const GLvoid *pixels);
+ (* glTexImage2D) (guint target, int level,
+ int internalFormat,
+ int width, int height,
+ int border, guint format, guint type,
+ const void *pixels);
void
- (* glGenTextures) (GLsizei n, GLuint *textures);
+ (* glGenTextures) (int n, guint *textures);
void
- (* glDeleteTextures) (GLsizei n, const GLuint *textures);
+ (* glDeleteTextures) (int n, const guint *textures);
void
- (* glBindTexture) (GLenum target, GLuint texture);
+ (* glBindTexture) (guint target, guint texture);
};
/* Coglbox implementation
{
TestCoglboxPrivate *priv;
guchar data[12];
- GLint prev_unpack_alignment;
- GLint prev_2d_texture_binding;
+ int prev_unpack_alignment;
+ int prev_2d_texture_binding;
self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self);
ClutterActor *dummy;
CoglHandle buffer;
float *quad_mesh_verts;
- GLubyte *quad_mesh_colors;
- GLushort *static_indices;
+ guint8 *quad_mesh_colors;
+ guint16 *static_indices;
guint n_static_indices;
CoglHandle indices;
ClutterTimeline *timeline;
float ripple_sin = sinf (ripple_angle);
float h, s, l;
- GLubyte *color;
+ guint8 *color;
vert[2] = (wave_sin * WAVE_DEPTH) + (ripple_sin * RIPPLE_DEPTH);
cogl_vertex_buffer_add (state->buffer,
"gl_Vertex",
3, /* n components */
- GL_FLOAT,
+ COGL_ATTRIBUTE_TYPE_FLOAT,
FALSE, /* normalized */
0, /* stride */
state->quad_mesh_verts);
cogl_vertex_buffer_add (state->buffer,
"gl_Color",
4, /* n components */
- GL_UNSIGNED_BYTE,
+ COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE,
FALSE, /* normalized */
0, /* stride */
state->quad_mesh_colors);
{
guint n_indices;
int x, y;
- GLushort *i;
+ guint16 *i;
guint dir;
/* - Each row takes (2 + 2 * MESH_WIDTH indices)
* - It takes one extra index for linking between rows (MESH_HEIGHT - 1)
* - A 2 x 3 mesh == 20 indices... */
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;
#define MESH_INDEX(X, Y) (Y) * (MESH_WIDTH + 1) + (X)
{
int x, y;
float *vert;
- GLubyte *color;
+ guint8 *color;
/* Note: we maintain the minimum number of vertices possible. This minimizes
* the work required when we come to morph the geometry.
g_malloc0 (sizeof (float) * 3 * (MESH_WIDTH + 1) * (MESH_HEIGHT + 1));
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;
color = state->quad_mesh_colors;