tex_height = cogl_texture_get_height (cogl_texture);
if (priv->repeat_x && tex_width > 0)
- t_w = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (x_2 - x_1),
- COGL_FIXED_FROM_INT (tex_width));
+ t_w = CLUTTER_FIXED_DIV ((float)(x_2 - x_1),
+ (float)(tex_width));
else
- t_w = COGL_FIXED_1;
+ t_w = 1.0;
if (priv->repeat_y && tex_height > 0)
- t_h = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (y_2 - y_1),
- COGL_FIXED_FROM_INT (tex_height));
+ t_h = CLUTTER_FIXED_DIV ((float)(y_2 - y_1),
+ (float)(tex_height));
else
- t_h = COGL_FIXED_1;
+ t_h = 1.0;
+#if USE_COGL_MATERIAL
+ cogl_set_source (cogl_material);
+
+ tex_coords[0] = 0;
+ tex_coords[1] = 0;
+ tex_coords[2] = t_w;
+ tex_coords[3] = t_h;
+ cogl_material_rectangle (0, 0,
+ COGL_FIXED_FROM_INT (x_2 - x_1),
+ COGL_FIXED_FROM_INT (y_2 - y_1),
+ 0,
+ tex_coords);
+#else
/* Parent paint translated us into position */
cogl_texture_rectangle (cogl_texture, 0, 0,
- COGL_FIXED_FROM_INT (x_2 - x_1),
- COGL_FIXED_FROM_INT (y_2 - y_1),
+ (float)(x_2 - x_1),
+ (float)(y_2 - y_1),
0, 0, t_w, t_h);
+#endif
}
static void
PROP_REPEAT_X,
PROP_FILTER_QUALITY,
PROP_COGL_TEXTURE,
+#if USE_COGL_MATERIAL
+ PROP_COGL_MATERIAL,
+#endif
PROP_FILENAME,
- PROP_KEEP_ASPECT_RATIO
+ PROP_KEEP_ASPECT_RATIO,
+ PROP_LOAD_ASYNC
};
enum
if (priv->fbo_source)
{
+ CoglTextureFlags flags = COGL_TEXTURE_NONE;
+ gint max_waste = -1;
+
/* Handle FBO's */
- if (priv->texture != COGL_INVALID_HANDLE)
- cogl_texture_unref (priv->texture);
+ if (priv->fbo_texture != COGL_INVALID_HANDLE)
+ cogl_texture_unref (priv->fbo_texture);
- priv->fbo_texture
- = cogl_texture_new_with_size
- (priv->width,
- priv->height,
- priv->no_slice ? -1 : priv->max_tile_waste,
- priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH,
- COGL_PIXEL_FORMAT_RGBA_8888);
+ if (!priv->no_slice)
+ max_waste = priv->max_tile_waste;
+
+ if (priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH)
+ flags |= COGL_TEXTURE_AUTO_MIPMAP;
+
- priv->texture =
++ priv->fbo_texture =
+ cogl_texture_new_with_size (priv->width,
+ priv->height,
+ max_waste, flags,
+ COGL_PIXEL_FORMAT_RGBA_8888);
- cogl_texture_set_filters (priv->texture,
+ cogl_texture_set_filters (priv->fbo_texture,
clutter_texture_quality_to_cogl_min_filter (priv->filter_quality),
clutter_texture_quality_to_cogl_mag_filter (priv->filter_quality));
clutter_actor_get_opacity (self));
if (priv->repeat_x && priv->width > 0)
- t_w = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (x_2 - x_1),
- COGL_FIXED_FROM_INT (priv->width));
+ t_w = CLUTTER_FIXED_DIV ((float)(x_2 - x_1),
+ (float)(priv->width));
else
- t_w = COGL_FIXED_1;
+ t_w = 1.0;
if (priv->repeat_y && priv->height > 0)
- t_h = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (y_2 - y_1),
- COGL_FIXED_FROM_INT (priv->height));
+ t_h = CLUTTER_FIXED_DIV ((float)(y_2 - y_1),
+ (float)(priv->height));
else
- t_h = COGL_FIXED_1;
+ t_h = 1.0;
/* Paint will have translated us */
- COGL_FIXED_FROM_INT (x_2 - x_1),
- COGL_FIXED_FROM_INT (y_2 - y_1),
+#if USE_COGL_MATERIAL
+ cogl_set_source (priv->material);
+
+ tex_coords[0] = 0;
+ tex_coords[1] = 0;
+ tex_coords[2] = t_w;
+ tex_coords[3] = t_h;
+ cogl_material_rectangle (0, 0,
++ (float)(x_2 - x_1),
++ (float)(y_2 - y_1),
+ 4,
+ tex_coords);
+#else
cogl_texture_rectangle (priv->texture, 0, 0,
- COGL_FIXED_FROM_INT (x_2 - x_1),
- COGL_FIXED_FROM_INT (y_2 - y_1),
- 0, 0, t_w, t_h);
+ (float)(x_2 - x_1),
+ (float)(y_2 - y_1),
+ 0, 0, t_w, t_h);
+#endif
}
+ /*
+ * clutter_texture_async_load_cancel:
+ * @texture: a #ClutterTexture
+ *
+ * Cancels an asynchronous loading operation, whether done
+ * with threads enabled or just using the main loop
+ */
+ static void
+ clutter_texture_async_load_cancel (ClutterTexture *texture)
+ {
+ ClutterTexturePrivate *priv = texture->priv;
+
+ if (priv->load_thread)
+ {
+ g_thread_join (priv->load_thread);
+ priv->load_thread = NULL;
+ }
+
+ if (priv->load_idle)
+ {
+ g_source_remove (priv->load_idle);
+ priv->load_idle = 0;
+ }
+
+ if (priv->load_error)
+ {
+ g_error_free (priv->load_error);
+ priv->load_error = NULL;
+ }
+
+ if (priv->load_bitmap)
+ {
+ cogl_bitmap_free (priv->load_bitmap);
+ priv->load_bitmap = NULL;
+ }
+
+ g_free (priv->load_filename);
+ }
+
static void
clutter_texture_dispose (GObject *object)
{
texture_free_gl_resources (texture);
- priv->width = w;
- priv->height = h;
+ priv->width = w;
+ priv->height = h;
+
+ if (priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH)
+ flags |= COGL_TEXTURE_AUTO_MIPMAP;
- priv->fbo_texture = cogl_texture_new_with_size (MAX (priv->width, 1),
- MAX (priv->height, 1),
- -1,
- priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH,
- priv->texture = cogl_texture_new_with_size (MAX (priv->width, 1),
- MAX (priv->height, 1),
- -1,
- flags,
-- COGL_PIXEL_FORMAT_RGBA_8888);
++ priv->fdo_texture =
++ cogl_texture_new_with_size (MAX (priv->width, 1),
++ MAX (priv->height, 1),
++ -1,
++ flags,
++ COGL_PIXEL_FORMAT_RGBA_8888);
- cogl_texture_set_filters (priv->texture,
+ cogl_texture_set_filters (priv->fbo_texture,
clutter_texture_quality_to_cogl_min_filter (priv->filter_quality),
clutter_texture_quality_to_cogl_mag_filter (priv->filter_quality));
gboolean use_color);
/**
- * Load an image file from disk. This function can be safely called from
+ * cogl_material_rectangle:
+ * @x1: x coordinate upper left on screen.
+ * @y1: y coordinate upper left on screen.
+ * @x2: x coordinate lower right on screen.
+ * @y2: y coordinate lower right on screen.
+ * @tex_coords_len: The length of the tex_coords array. (e.g. for one layer
+ * and one group of texture coordinates, this would be 4)
+ * @tex_coords: An array containing groups of 4 CoglFixed values:
+ * [tx1, ty1, tx2, ty2] that are interpreted as two texture coordinates; one
+ * for the upper left texel, and one for the lower right texel. Each value
+ * should be between 0.0 and 1.0, where the coordinate (0.0, 0.0) represents
+ * the top left of the texture, and (1.0, 1.0) the bottom right.
+ *
+ * This function draws a rectangle using the current source material to
+ * texture or fill with. Since a material may contain multiple texture
+ * layers the interface lets you supply corresponding sets of texture
+ * coordinates.
+ *
+ * The first pair of coordinates are for the first layer (with the smallest
+ * layer index) and if you supply less texture coordinates than there are
+ * layers in the current source material then default texture coordinates
+ * [0.0, 0.0, 1.0, 1.0] are generated.
+ */
+void cogl_material_rectangle (CoglFixed x1,
+ CoglFixed y1,
+ CoglFixed x2,
+ CoglFixed y2,
+ gint tex_coords_len,
+ const CoglFixed *tex_coords);
+
+/**
+ * cogl_bitmap_new_from_file:
+ * @filename: the file to load.
+ * @error: a #GError or %NULL.
+ *
- * Returns: A #CoglBitmap to the new loaded image data, or %NULL if loading
++ * Load an image file from disk. This function can be safely called from
+ * within a thread.
+ *
++ * Returns: A #CoglBitmap to the new loaded image data, or %NULL if loading
+ * the image failed.
+ *
+ * Since: 1.0
+ */
+ CoglBitmap * cogl_bitmap_new_from_file (const gchar *filename,
+ GError **error);
+
+ /**
+ * cogl_bitmap_get_size_from_file:
+ * @filename: the file to check
+ * @width: return location for the bitmap width
+ * @height: return location for the bitmap height
+ *
+ * Parses an image file enough to extract the width and height
+ * of the bitmap.
+ *
+ * Since: 1.0
+ */
+ gboolean cogl_bitmap_get_size_from_file (const gchar *filename,
+ gint *width,
+ gint *height);
+
+ /**
+ * cogl_bitmap_free:
+ * @bmp: a #CoglBitmap.
+ *
+ * Frees a #CoglBitmap.
+ */
+ void cogl_bitmap_free (CoglBitmap *bmp);
+
+ /**
* cogl_texture_multiple_rectangles:
* @handle: a @CoglHandle.
* @verts: an array of vertices
#include <cogl/cogl-defines-@CLUTTER_COGL@.h>
+#include <cogl/cogl-mesh.h>
+#include <cogl/cogl-matrix.h>
+ #include <cogl/cogl-vertex-buffer.h>
#include <cogl/cogl-fixed.h>
#include <cogl/cogl-color.h>
#include <cogl/cogl-offscreen.h>
cogl-clip-stack.c \
cogl-fixed.c \
cogl-color.c \
- cogl-mesh.c \
- cogl-vertex-buffer-private.h \
- cogl-vertex-buffer.c
++ cogl-vertex-buffer-private.h \
++ cogl-vertex-buffer.c \
+ cogl-matrix.c \
+ cogl-material.c
$(top_builddir)/clutter/cogl/cogl-shader.h \
$(top_builddir)/clutter/cogl/cogl-texture.h \
$(top_builddir)/clutter/cogl/cogl-types.h \
- $(top_builddir)/clutter/cogl/cogl-mesh.h \
- $(top_builddir)/clutter/cogl/cogl-vertex-buffer.h
++ $(top_builddir)/clutter/cogl/cogl-vertex-buffer.h \
+ $(top_builddir)/clutter/cogl/cogl-material.h \
+ $(top_builddir)/clutter/cogl/cogl-matrix.h
INCLUDES = \
-I$(top_srcdir) \
$(top_builddir)/clutter/cogl/cogl-shader.h \
$(top_builddir)/clutter/cogl/cogl-texture.h \
$(top_builddir)/clutter/cogl/cogl-types.h \
- $(top_builddir)/clutter/cogl/cogl-mesh.h \
- $(top_builddir)/clutter/cogl/cogl-vertex-buffer.h
++ $(top_builddir)/clutter/cogl/cogl-vertex-buffer.h \
+ $(top_builddir)/clutter/cogl/cogl-material.h \
+ $(top_builddir)/clutter/cogl/cogl-matrix.h
INCLUDES = \
-I$(top_srcdir) \
can be flushed */
GLuint texture_current;
GLenum texture_target;
+ GLenum texture_format;
+ /* Materials */
+ GArray *material_handles;
+ GArray *material_layer_handles;
+ CoglHandle source_material;
+
/* Framebuffer objects */
GArray *fbo_handles;
CoglBufferTarget draw_buffer;
cogl_wrap_glMatrixMode (GL_MODELVIEW);
cogl_wrap_glLoadIdentity ();
+ wrapper->texture_units =
+ g_array_new (FALSE, FALSE, sizeof (CoglGles2WrapperTextureUnit *));
+
+ /* The gl*ActiveTexture wrappers will initialise the texture
+ * stack for the texture unit when it's first activated */
+ cogl_wrap_glActiveTexture (GL_TEXTURE0);
+ cogl_wrap_glClientActiveTexture (GL_TEXTURE0);
+
/* Initialize the fogging options */
cogl_wrap_glDisable (GL_FOG);
- cogl_wrap_glFogx (GL_FOG_MODE, GL_LINEAR);
- cogl_wrap_glFogx (GL_FOG_DENSITY, COGL_FIXED_1);
- cogl_wrap_glFogx (GL_FOG_START, 0);
- cogl_wrap_glFogx (GL_FOG_END, 1);
- cogl_wrap_glFogxv (GL_FOG_COLOR, default_fog_color);
+ cogl_wrap_glFogf (GL_FOG_MODE, GL_LINEAR);
+ cogl_wrap_glFogf (GL_FOG_DENSITY, 1.0);
+ cogl_wrap_glFogf (GL_FOG_START, 0);
+ cogl_wrap_glFogf (GL_FOG_END, 1);
+ cogl_wrap_glFogfv (GL_FOG_COLOR, default_fog_color);
/* Initialize alpha testing */
cogl_wrap_glDisable (GL_ALPHA_TEST);
}
void
- cogl_wrap_glRotatex (GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
+ cogl_wrap_glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
{
float matrix[16];
- float xf = COGL_FIXED_TO_FLOAT (x);
- float yf = COGL_FIXED_TO_FLOAT (y);
- float zf = COGL_FIXED_TO_FLOAT (z);
- float anglef = COGL_FIXED_TO_FLOAT (angle) * G_PI / 180.0f;
+ float xf = (x);
+ float yf = (y);
+ float zf = (z);
+ float anglef = (angle) * G_PI / 180.0f;
float c = cosf (anglef);
float s = sinf (anglef);
-
+
matrix[0] = xf * xf * (1.0f - c) + c;
matrix[1] = yf * xf * (1.0f - c) + zf * s;
matrix[2] = xf * zf * (1.0f - c) - yf * s;
w->dirty_custom_uniforms = 0;
}
+ if (w->dirty_attribute_pointers
+ & COGL_GLES2_DIRTY_TEX_COORD_VERTEX_ATTRIB)
+ {
+ int i;
+
+ /* TODO - coverage test */
+ for (i = 0; i < w->settings.n_texture_units; i++)
+ {
+ GLint tex_coord_var_index;
+ CoglGles2WrapperTextureUnit *texture_unit;
+
+ if (!w->settings.texture_units[i].enabled)
+ continue;
+
+ texture_unit = g_array_index (w->texture_units,
+ CoglGles2WrapperTextureUnit *,
+ w->active_texture_unit);
+ if (!texture_unit->texture_coords_enabled)
+ continue;
+
+ /* TODO - we should probably have a per unit dirty flag too */
+
+ /* TODO - coverage test */
+ tex_coord_var_index =
+ g_array_index (program->attributes.multi_texture_coords,
+ GLint, i);
+ glVertexAttribPointer (tex_coord_var_index,
+ texture_unit->texture_coords_size,
+ texture_unit->texture_coords_type,
+ GL_FALSE,
+ texture_unit->texture_coords_stride,
+ texture_unit->texture_coords_pointer);
+ }
+ }
+
+ if (w->dirty_vertex_attrib_enables)
+ {
+ int i;
+
+ /* TODO - coverage test */
+
+ /* TODO - we should probably have a per unit dirty flag too */
+
+ for (i = 0; i < w->texture_units->len; i++)
+ {
+ CoglGles2WrapperTextureUnit *texture_unit =
+ g_array_index (w->texture_units,
+ CoglGles2WrapperTextureUnit *,
+ w->active_texture_unit);
+ if (texture_unit->texture_coords_enabled)
+ glEnableVertexAttribArray (
+ g_array_index (program->attributes.multi_texture_coords,
+ GLint, i));
+ else
+ glDisableVertexAttribArray (
+ g_array_index (program->attributes.multi_texture_coords,
+ GLint, i));
+ w->dirty_vertex_attrib_enables = 0;
+ }
+ }
+ }
+
+ void
+ cogl_wrap_glDrawArrays (GLenum mode, GLint first, GLsizei count)
+ {
+ cogl_wrap_prepare_for_draw ();
+
glDrawArrays (mode, first, count);
}
case GL_FOG_MODE:
_COGL_GLES2_CHANGE_SETTING (w, fog_mode, param);
break;
-
+
case GL_FOG_DENSITY:
_COGL_GLES2_CHANGE_UNIFORM (w, FOG_DENSITY, fog_density,
- COGL_FIXED_TO_FLOAT (param));
+ (param));
break;
case GL_FOG_START:
void cogl_wrap_glNormalPointer (GLenum type, GLsizei stride,
const GLvoid *pointer);
- void cogl_wrap_glTexEnvx (GLenum target, GLenum pname, GLfixed param);
+ void cogl_wrap_glTexEnvf (GLenum target, GLenum pname, GLfloat param);
+void cogl_wrap_glClientActiveTexture (GLenum texture);
+void cogl_wrap_glActiveTexture (GLenum texture);
+
void cogl_wrap_glEnableClientState (GLenum array);
void cogl_wrap_glDisableClientState (GLenum array);
#define cogl_wrap_glVertexPointer glVertexPointer
#define cogl_wrap_glColorPointer glColorPointer
#define cogl_wrap_glNormalPointer glNormalPointer
- #define cogl_wrap_glTexEnvx glTexEnvx
+ #define cogl_wrap_glTexEnvf glTexEnvf
+#define cogl_wrap_glActiveTexture glActiveTexture
#define cogl_wrap_glEnableClientState glEnableClientState
#define cogl_wrap_glDisableClientState glDisableClientState
#define cogl_wrap_glAlphaFunc glAlphaFunc
#include <string.h>
#include <stdlib.h>
+ #include <math.h>
+#if HAVE_COGL_GLES2
#define glVertexPointer cogl_wrap_glVertexPointer
#define glTexCoordPointer cogl_wrap_glTexCoordPointer
#define glColorPointer cogl_wrap_glColorPointer
#define glDrawArrays cogl_wrap_glDrawArrays
+ #define glDrawElements cogl_wrap_glDrawElements
#define glTexParameteri cogl_wrap_glTexParameteri
+#define glClientActiveTexture cogl_wrap_glClientActiveTexture
+#define glActiveTexture cogl_wrap_glActiveTexture
+#define glEnable cogl_wrap_glEnable
+#define glEnableClientState cogl_wrap_glEnableClientState
+#define glDisable cogl_wrap_glDisable
+#define glDisableClientState cogl_wrap_glDisableClientState
+#endif
/*
#define COGL_DEBUG 1
</SECTION>
<SECTION>
- <FILE>cogl-mesh</FILE>
- <TITLE>Mesh API</TITLE>
- cogl_mesh_new
- cogl_mesh_ref
- cogl_mesh_unref
- CoglMeshAttributeFlags
- cogl_mesh_add_attribute
- cogl_mesh_delete_attribute
- cogl_mesh_enable_attribute
- cogl_mesh_disable_attribute
- cogl_mesh_draw_arrays
- cogl_mesh_draw_range_elements
- cogl_mesh_submit
+ <FILE>cogl-vertex-buffer</FILE>
+ <TITLE>Vertex Buffers</TITLE>
+ CoglVertexBufferAttribFlags
+ COGL_VERTEX_BUFFER_ATTRIB_FLAG_GL_TYPE_MASK
+ COGL_VERTEX_BUFFER_ATTRIB_FLAG_TYPE_MASK
+ cogl_vertex_buffer_new
+ cogl_vertex_buffer_ref
+ cogl_vertex_buffer_unref
+ cogl_vertex_buffer_add
+ cogl_vertex_buffer_delete
+ cogl_vertex_buffer_enable
+ cogl_vertex_buffer_disable
+ cogl_vertex_buffer_submit
+ cogl_vertex_buffer_draw
+ cogl_vertex_buffer_draw_range_elements
</SECTION>
+<SECTION>
+<FILE>cogl-matrix</FILE>
+<TITLE>Matrices</TITLE>
+CoglMatrix
+cogl_matrix_init_identity
+cogl_matrix_multiply
+cogl_matrix_rotate
+cogl_matrix_translate
+cogl_matrix_scale
+</SECTION>
+
+<SECTION>
+<FILE>cogl-material</FILE>
+<TITLE>Materials</TITLE>
+cogl_material_new
+cogl_material_ref
+cogl_material_unref
+cogl_material_set_diffuse
+cogl_material_set_ambient
+cogl_material_set_ambient_and_diffuse
+cogl_material_set_specular
+cogl_material_set_shininess
+cogl_material_set_emission
+cogl_set_source
+CoglMaterialAlphaFunc
+cogl_material_set_alpha_test_function
+CoglMaterialBlendFactor
+cogl_material_set_blend_factors
+cogl_material_set_layer
+cogl_material_remove_layer
+CoglMaterialLayerCombineFunc
+cogl_material_set_layer_combine_function
+CoglMaterialLayerCombineChannels
+CoglMaterialLayerCombineSrc
+cogl_material_set_layer_combine_arg_src
+CoglMaterialLayerCombineOp
+cogl_material_set_layer_combine_arg_op
+cogl_material_set_layer_matrix
+cogl_material_get_cogl_enable_flags
+cogl_material_flush_gl_material_state
+cogl_material_flush_gl_alpha_func
+cogl_material_flush_gl_blend_func
+cogl_material_get_layers
+CoglMaterialLayerType
+cogl_material_layer_get_type
+cogl_material_layer_get_texture
+cogl_material_layer_flush_gl_sampler_state
+</SECTION>
+