diff --git a/cogl-texture.h b/cogl-texture.h index 3ca0d8137..cee2f439e 100644 --- a/cogl-texture.h +++ b/cogl-texture.h @@ -134,6 +134,26 @@ CoglHandle cogl_texture_new_from_foreign (GLuint gl_handle, GLuint y_pot_waste, CoglPixelFormat format); +/** + * cogl_texture_new_from_bitmap: + * @handle: handle of the preloaded texture. + * @max_waste: maximum extra horizontal and|or vertical margin pixels to make + * texture fit GPU limitations. + * @auto_mipmap: enable or disable automatic generation of mipmap pyramid + * from the base level image whenever it is updated. + * @internal_format: the #CoglPixelFormat to use for the GPU storage of the + * texture. + * + * Create a cogl texture from a #CoglBitmap. + * + * Returns: a #CoglHandle to the newly created texture or COGL_INVALID_HANDLE + * if creating the texture failed. + */ +CoglHandle cogl_texture_new_from_bitmap (CoglBitmap *bitmap, + gint max_waste, + gboolean auto_mipmap, + CoglPixelFormat internal_format); + /** * cogl_is_texture: * @handle: A CoglHandle @@ -385,6 +405,45 @@ void cogl_texture_polygon (CoglHandle handle, CoglTextureVertex *vertices, gboolean use_color); +/** + * cogl_bitmap_new_from_file: + * @filename: the file to load. + * @error: a #GError or %NULL. + * + * 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. @@ -401,7 +460,7 @@ void cogl_texture_polygon (CoglHandle handle, * parameters x1, y1, x2, y2, tx1, ty1, tx2 and ty2 and have the same * meaning as in cogl_texture_rectangle(). * - * Since: 1.0 + * Since: 0.8.6 */ void cogl_texture_multiple_rectangles (CoglHandle handle, diff --git a/cogl-types.h b/cogl-types.h index 4fb69953a..ece3270b7 100644 --- a/cogl-types.h +++ b/cogl-types.h @@ -28,6 +28,13 @@ G_BEGIN_DECLS +/** + * CoglBitmap: + * + * Type used for storing image data. + */ +typedef struct _CoglBitmap CoglBitmap; + /** * CoglHandle: * @@ -86,27 +93,29 @@ typedef struct _CoglTextureVertex CoglTextureVertex; /** * CoglPixelFormat: - * @COGL_PIXEL_FORMAT_ANY: - * @COGL_PIXEL_FORMAT_A_8: - * @COGL_PIXEL_FORMAT_RGB_888: - * @COGL_PIXEL_FORMAT_BGR_888: - * @COGL_PIXEL_FORMAT_RGBA_8888: - * @COGL_PIXEL_FORMAT_BGRA_8888: - * @COGL_PIXEL_FORMAT_ARGB_8888: - * @COGL_PIXEL_FORMAT_ABGR_8888: - * @COGL_PIXEL_FORMAT_RGBA_8888_PRE: - * @COGL_PIXEL_FORMAT_BGRA_8888_PRE: - * @COGL_PIXEL_FORMAT_ARGB_8888_PRE: - * @COGL_PIXEL_FORMAT_ABGR_8888_PRE: - * @COGL_PIXEL_FORMAT_RGB_565: - * @COGL_PIXEL_FORMAT_RGBA_4444: - * @COGL_PIXEL_FORMAT_RGBA_5551: - * @COGL_PIXEL_FORMAT_RGBA_4444_PRE: - * @COGL_PIXEL_FORMAT_RGBA_5551_PRE: - * @COGL_PIXEL_FORMAT_YUV: - * @COGL_PIXEL_FORMAT_G_8: + * @COGL_PIXEL_FORMAT_ANY: Any format + * @COGL_PIXEL_FORMAT_A_8: 8 bits alpha mask + * @COGL_PIXEL_FORMAT_RGB_565: RGB, 16 bits + * @COGL_PIXEL_FORMAT_RGBA_4444: RGBA, 16 bits + * @COGL_PIXEL_FORMAT_RGBA_5551: RGBA, 16 bits + * @COGL_PIXEL_FORMAT_YUV: FIXME + * @COGL_PIXEL_FORMAT_G_8: FIXME + * @COGL_PIXEL_FORMAT_RGB_888: RGB, 24 bits + * @COGL_PIXEL_FORMAT_BGR_888: BGR, 24 bits + * @COGL_PIXEL_FORMAT_RGBA_8888: RGBA, 32 bits + * @COGL_PIXEL_FORMAT_BGRA_8888: BGRA, 32 bits + * @COGL_PIXEL_FORMAT_ARGB_8888: ARGB, 32 bits + * @COGL_PIXEL_FORMAT_ABGR_8888: ABGR, 32 bits + * @COGL_PIXEL_FORMAT_RGBA_8888_PRE: Premultiplied RGBA, 32 bits + * @COGL_PIXEL_FORMAT_BGRA_8888_PRE: Premultiplied BGRA, 32 bits + * @COGL_PIXEL_FORMAT_ARGB_8888_PRE: Premultiplied ARGB, 32 bits + * @COGL_PIXEL_FORMAT_ABGR_8888_PRE: Premultiplied ABGR, 32 bits + * @COGL_PIXEL_FORMAT_RGBA_4444_PRE: Premultiplied RGBA, 16 bits + * @COGL_PIXEL_FORMAT_RGBA_5551_PRE: Premultiplied RGBA, 16 bits * * Pixel formats used by COGL. + * + * Since: 0.8 */ typedef enum { @@ -173,19 +182,21 @@ typedef enum /** * CoglFeatureFlags: - * @COGL_FEATURE_TEXTURE_RECTANGLE: - * @COGL_FEATURE_TEXTURE_NPOT: - * @COGL_FEATURE_TEXTURE_YUV: - * @COGL_FEATURE_TEXTURE_READ_PIXELS: - * @COGL_FEATURE_SHADERS_GLSL: - * @COGL_FEATURE_OFFSCREEN: - * @COGL_FEATURE_OFFSCREEN_MULTISAMPLE: - * @COGL_FEATURE_OFFSCREEN_BLIT: - * @COGL_FEATURE_FOUR_CLIP_PLANES: - * @COGL_FEATURE_STENCIL_BUFFER: - * @COGL_FEATURE_VBOS: + * @COGL_FEATURE_TEXTURE_RECTANGLE: ARB_texture_rectangle support + * @COGL_FEATURE_TEXTURE_NPOT: ARB_texture_non_power_of_two support + * @COGL_FEATURE_TEXTURE_YUV: ycbcr conversion support + * @COGL_FEATURE_TEXTURE_READ_PIXELS: glReadPixels() support + * @COGL_FEATURE_SHADERS_GLSL: GLSL support + * @COGL_FEATURE_OFFSCREEN: FBO support + * @COGL_FEATURE_OFFSCREEN_MULTISAMPLE: Multisample support on FBOs + * @COGL_FEATURE_OFFSCREEN_BLIT: Blit support on FBOs + * @COGL_FEATURE_FOUR_CLIP_PLANES: At least 4 clip planes available + * @COGL_FEATURE_STENCIL_BUFFER: Stencil buffer support + * @COGL_FEATURE_VBOS: VBO support * * Flags for the supported features. + * + * Since: 0.8 */ typedef enum { @@ -204,11 +215,13 @@ typedef enum /** * CoglBufferTarget: - * @COGL_WINDOW_BUFFER: - * @COGL_MASK_BUFFER: - * @COGL_OFFSCREEN_BUFFER: + * @COGL_WINDOW_BUFFER: FIXME + * @COGL_MASK_BUFFER: FIXME + * @COGL_OFFSCREEN_BUFFER: FIXME * + * Target flags for FBOs. * + * Since: 0.8 */ typedef enum { diff --git a/common/Makefile.am b/common/Makefile.am index db0f0b42d..fb2adf28f 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -5,6 +5,7 @@ INCLUDES = \ -I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \ -I$(top_builddir)/clutter \ -I$(top_builddir)/clutter/cogl \ + -DG_LOG_DOMAIN=\"Cogl-Common\" \ -DCLUTTER_COMPILATION \ $(CLUTTER_CFLAGS) \ $(CLUTTER_DEBUG_CFLAGS) \ diff --git a/common/cogl-bitmap-pixbuf.c b/common/cogl-bitmap-pixbuf.c index 77316dff5..8d86d94e4 100644 --- a/common/cogl-bitmap-pixbuf.c +++ b/common/cogl-bitmap-pixbuf.c @@ -84,6 +84,20 @@ cogl_bitmap_error_quark (void) return g_quark_from_static_string ("cogl-bitmap-error-quark"); } +gboolean +_cogl_bitmap_get_size_from_file (const gchar *filename, + gint *width, + gint *height) +{ + if (width) + *width = 0; + + if (height) + *height = 0; + + return TRUE; +} + /* the error does not contain the filename as the caller already has it */ gboolean _cogl_bitmap_from_file (CoglBitmap *bmp, @@ -177,9 +191,22 @@ _cogl_bitmap_from_file (CoglBitmap *bmp, #elif defined(USE_GDKPIXBUF) gboolean -_cogl_bitmap_from_file (CoglBitmap *bmp, - const gchar *filename, - GError **error) +_cogl_bitmap_get_size_from_file (const gchar *filename, + gint *width, + gint *height) +{ + g_return_val_if_fail (filename != NULL, FALSE); + + if (gdk_pixbuf_get_file_info (filename, width, height) != NULL) + return TRUE; + + return FALSE; +} + +gboolean +_cogl_bitmap_from_file (CoglBitmap *bmp, + const gchar *filename, + GError **error) { GdkPixbuf *pixbuf; gboolean has_alpha; @@ -198,11 +225,13 @@ _cogl_bitmap_from_file (CoglBitmap *bmp, g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (bmp == NULL) return FALSE; - + if (bmp == NULL) + return FALSE; + /* Load from file using GdkPixbuf */ pixbuf = gdk_pixbuf_new_from_file (filename, error); - if (pixbuf == NULL) return FALSE; + if (pixbuf == NULL) + return FALSE; /* Get pixbuf properties */ has_alpha = gdk_pixbuf_get_has_alpha (pixbuf); @@ -278,6 +307,20 @@ _cogl_bitmap_from_file (CoglBitmap *bmp, #include "stb_image.c" +gboolean +_cogl_bitmap_get_size_from_file (const gchar *filename, + gint *width, + gint *height) +{ + if (width) + *width = 0; + + if (height) + *height = 0; + + return TRUE; +} + gboolean _cogl_bitmap_from_file (CoglBitmap *bmp, const gchar *filename, @@ -290,11 +333,15 @@ _cogl_bitmap_from_file (CoglBitmap *bmp, g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (bmp == NULL) return FALSE; + if (bmp == NULL) + return FALSE; /* Load from file using stb */ - pixels = stbi_load (filename, &width, &height, &stb_pixel_format, STBI_rgb_alpha); - if (pixels == NULL) return FALSE; + pixels = stbi_load (filename, + &width, &height, &stb_pixel_format, + STBI_rgb_alpha); + if (pixels == NULL) + return FALSE; /* Store bitmap info */ bmp->data = g_memdup (pixels, height * width * 4); diff --git a/common/cogl-bitmap.c b/common/cogl-bitmap.c index 39341e0b0..b0a3b7138 100644 --- a/common/cogl-bitmap.c +++ b/common/cogl-bitmap.c @@ -148,3 +148,42 @@ _cogl_bitmap_copy_subregion (CoglBitmap *src, dstdata += dst->rowstride; } } + +gboolean +cogl_bitmap_get_size_from_file (const gchar *filename, + gint *width, + gint *height) +{ + return _cogl_bitmap_get_size_from_file (filename, width, height); +} + +CoglBitmap * +cogl_bitmap_new_from_file (const gchar *filename, + GError **error) +{ + CoglBitmap bmp; + + g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE); + + /* Try loading with imaging backend */ + if (!_cogl_bitmap_from_file (&bmp, filename, error)) + { + /* Try fallback */ + if (!_cogl_bitmap_fallback_from_file (&bmp, filename)) + return NULL; + else if (error && *error) + { + g_error_free (*error); + *error = NULL; + } + } + + return (CoglBitmap *) g_memdup (&bmp, sizeof (CoglBitmap)); +} + +void +cogl_bitmap_free (CoglBitmap *bmp) +{ + g_free (bmp->data); + g_free (bmp); +} diff --git a/common/cogl-bitmap.h b/common/cogl-bitmap.h index ca9f8a9c3..953ac5a32 100644 --- a/common/cogl-bitmap.h +++ b/common/cogl-bitmap.h @@ -28,8 +28,6 @@ #include -typedef struct _CoglBitmap CoglBitmap; - struct _CoglBitmap { guchar *data; @@ -92,4 +90,9 @@ _cogl_bitmap_copy_subregion (CoglBitmap *src, gint width, gint height); +gboolean +_cogl_bitmap_get_size_from_file (const gchar *filename, + gint *width, + gint *height); + #endif /* __COGL_BITMAP_H */ diff --git a/common/cogl-mesh.c b/common/cogl-mesh.c index 88a0ba473..f7287f953 100644 --- a/common/cogl-mesh.c +++ b/common/cogl-mesh.c @@ -209,6 +209,8 @@ COGL_HANDLE_DEFINE (Mesh, mesh, mesh_handles); * * This creates a Cogl handle for a new mesh that you can then start to add * attributes too. + * + * Return value: a new #CoglHandle */ CoglHandle cogl_mesh_new (guint n_vertices) diff --git a/gl/Makefile.am b/gl/Makefile.am index 2d90ba9c0..7635b1b90 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -20,6 +20,7 @@ INCLUDES = \ -I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \ -I$(top_builddir)/clutter \ -I$(top_builddir)/clutter/cogl \ + -DG_LOG_DOMAIN=\"Cogl-GL\" \ -DCLUTTER_COMPILATION \ $(CLUTTER_CFLAGS) \ $(CLUTTER_DEBUG_CFLAGS) \ diff --git a/gl/cogl-texture.c b/gl/cogl-texture.c index a27a8b253..4c30639a9 100644 --- a/gl/cogl-texture.c +++ b/gl/cogl-texture.c @@ -1323,30 +1323,13 @@ cogl_texture_new_from_data (guint width, } CoglHandle -cogl_texture_new_from_file (const gchar *filename, - gint max_waste, - gboolean auto_mipmap, - CoglPixelFormat internal_format, - GError **error) +cogl_texture_new_from_bitmap (CoglBitmap *bmp, + gint max_waste, + gboolean auto_mipmap, + CoglPixelFormat internal_format) { - CoglBitmap bmp; CoglTexture *tex; - g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE); - - /* Try loading with imaging backend */ - if (!_cogl_bitmap_from_file (&bmp, filename, error)) - { - /* Try fallback */ - if (!_cogl_bitmap_fallback_from_file (&bmp, filename)) - return COGL_INVALID_HANDLE; - else if (error && *error) - { - g_error_free (*error); - *error = NULL; - } - } - /* Create new texture and fill with loaded data */ tex = (CoglTexture*) g_malloc ( sizeof (CoglTexture)); @@ -1356,8 +1339,9 @@ cogl_texture_new_from_file (const gchar *filename, tex->is_foreign = FALSE; tex->auto_mipmap = auto_mipmap; - tex->bitmap = bmp; + tex->bitmap = *bmp; tex->bitmap_owner = TRUE; + bmp->data = NULL; tex->slice_x_spans = NULL; tex->slice_y_spans = NULL; @@ -1398,6 +1382,30 @@ cogl_texture_new_from_file (const gchar *filename, return _cogl_texture_handle_new (tex); } +CoglHandle +cogl_texture_new_from_file (const gchar *filename, + gint max_waste, + gboolean auto_mipmap, + CoglPixelFormat internal_format, + GError **error) +{ + CoglBitmap *bmp; + CoglHandle handle; + + g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE); + + if (!(bmp = cogl_bitmap_new_from_file (filename, error))) + return COGL_INVALID_HANDLE; + + handle = cogl_texture_new_from_bitmap (bmp, + max_waste, + auto_mipmap, + internal_format); + cogl_bitmap_free (bmp); + + return handle; +} + CoglHandle cogl_texture_new_from_foreign (GLuint gl_handle, GLenum gl_target, diff --git a/gles/Makefile.am b/gles/Makefile.am index 19cf0a0d7..1731d2cb5 100644 --- a/gles/Makefile.am +++ b/gles/Makefile.am @@ -20,6 +20,7 @@ INCLUDES = \ -I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \ -I$(top_builddir)/clutter \ -I$(top_builddir)/clutter/cogl \ + -DG_LOG_DOMAIN=\"Cogl-GLES\" \ -DCLUTTER_COMPILATION \ $(CLUTTER_CFLAGS) \ $(CLUTTER_DEBUG_CFLAGS) \ diff --git a/gles/cogl-context.h b/gles/cogl-context.h index 5d835712a..92b8b96a2 100644 --- a/gles/cogl-context.h +++ b/gles/cogl-context.h @@ -72,6 +72,7 @@ typedef struct can be flushed */ GLuint texture_current; GLenum texture_target; + GLenum texture_format; /* Framebuffer objects */ GArray *fbo_handles; diff --git a/gles/cogl-gles2-wrapper.c b/gles/cogl-gles2-wrapper.c index fea76500e..d43ad21da 100644 --- a/gles/cogl-gles2-wrapper.c +++ b/gles/cogl-gles2-wrapper.c @@ -891,8 +891,8 @@ cogl_gles2_do_set_uniform (GLint location, CoglBoxedValue *value) } } -void -cogl_wrap_glDrawArrays (GLenum mode, GLint first, GLsizei count) +static void +cogl_wrap_prepare_for_draw (void) { CoglGles2WrapperProgram *program; @@ -999,9 +999,25 @@ cogl_wrap_glDrawArrays (GLenum mode, GLint first, GLsizei count) w->dirty_custom_uniforms = 0; } +} + +void +cogl_wrap_glDrawArrays (GLenum mode, GLint first, GLsizei count) +{ + cogl_wrap_prepare_for_draw (); + glDrawArrays (mode, first, count); } +void +cogl_wrap_glDrawElements (GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices) +{ + cogl_wrap_prepare_for_draw (); + + glDrawElements (mode, count, type, indices); +} + void cogl_gles2_wrapper_bind_texture (GLenum target, GLuint texture, GLenum internal_format) diff --git a/gles/cogl-gles2-wrapper.h b/gles/cogl-gles2-wrapper.h index 514b89cc4..05f7c600f 100644 --- a/gles/cogl-gles2-wrapper.h +++ b/gles/cogl-gles2-wrapper.h @@ -250,7 +250,8 @@ void cogl_wrap_glFogx (GLenum pname, GLfixed param); void cogl_wrap_glFogxv (GLenum pname, const GLfixed *params); void cogl_wrap_glDrawArrays (GLenum mode, GLint first, GLsizei count); - +void cogl_wrap_glDrawElements (GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices); void cogl_wrap_glTexParameteri (GLenum target, GLenum pname, GLfloat param); void cogl_gles2_wrapper_bind_texture (GLenum target, GLuint texture, @@ -274,6 +275,7 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program); #define cogl_wrap_glClearColorx glClearColor #define cogl_wrap_glDrawArrays glDrawArrays +#define cogl_wrap_glDrawElements glDrawElements #define cogl_wrap_glPushMatrix glPushMatrix #define cogl_wrap_glPopMatrix glPopMatrix #define cogl_wrap_glMatrixMode glMatrixMode diff --git a/gles/cogl-texture.c b/gles/cogl-texture.c index 915e82b23..7de709507 100644 --- a/gles/cogl-texture.c +++ b/gles/cogl-texture.c @@ -44,6 +44,7 @@ #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 /* @@ -1446,30 +1447,13 @@ cogl_texture_new_from_data (guint width, } CoglHandle -cogl_texture_new_from_file (const gchar *filename, - gint max_waste, - gboolean auto_mipmap, - CoglPixelFormat internal_format, - GError **error) +cogl_texture_new_from_bitmap (CoglBitmap *bmp, + gint max_waste, + gboolean auto_mipmap, + CoglPixelFormat internal_format) { - CoglBitmap bmp; CoglTexture *tex; - - g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE); - /* Try loading with imaging backend */ - if (!_cogl_bitmap_from_file (&bmp, filename, error)) - { - /* Try fallback */ - if (!_cogl_bitmap_fallback_from_file (&bmp, filename)) - return COGL_INVALID_HANDLE; - else if (error && *error) - { - g_error_free (*error); - *error = NULL; - } - } - /* Create new texture and fill with loaded data */ tex = (CoglTexture*) g_malloc ( sizeof (CoglTexture)); @@ -1479,8 +1463,9 @@ cogl_texture_new_from_file (const gchar *filename, tex->is_foreign = FALSE; tex->auto_mipmap = auto_mipmap; - tex->bitmap = bmp; + tex->bitmap = *bmp; tex->bitmap_owner = TRUE; + bmp->data = NULL; tex->slice_x_spans = NULL; tex->slice_y_spans = NULL; @@ -1521,6 +1506,30 @@ cogl_texture_new_from_file (const gchar *filename, return _cogl_texture_handle_new (tex); } +CoglHandle +cogl_texture_new_from_file (const gchar *filename, + gint max_waste, + gboolean auto_mipmap, + CoglPixelFormat internal_format, + GError **error) +{ + CoglBitmap *bmp; + CoglHandle handle; + + g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE); + + if (!(bmp = cogl_bitmap_new_from_file (filename, error))) + return COGL_INVALID_HANDLE; + + handle = cogl_texture_new_from_bitmap (bmp, + max_waste, + auto_mipmap, + internal_format); + cogl_bitmap_free (bmp); + + return handle; +} + CoglHandle cogl_texture_new_from_foreign (GLuint gl_handle, GLenum gl_target, @@ -2094,7 +2103,9 @@ _cogl_texture_flush_vertices (void) GE( glTexCoordPointer (2, GL_FLOAT, sizeof (CoglTextureGLVertex), p->t ) ); - GE( glBindTexture (ctx->texture_target, ctx->texture_current) ); + GE( cogl_gles2_wrapper_bind_texture (ctx->texture_target, + ctx->texture_current, + ctx->texture_format) ); GE( glDrawElements (GL_TRIANGLES, needed_indices, GL_UNSIGNED_SHORT, @@ -2284,6 +2295,7 @@ _cogl_texture_quad_sw (CoglTexture *tex, _cogl_texture_flush_vertices (); ctx->texture_target = tex->gl_target; ctx->texture_current = gl_handle; + ctx->texture_format = tex->gl_intformat; _cogl_texture_add_quad_vertices (COGL_FIXED_TO_FLOAT (slice_qx1), COGL_FIXED_TO_FLOAT (slice_qy1), @@ -2328,6 +2340,7 @@ _cogl_texture_quad_hw (CoglTexture *tex, _cogl_texture_flush_vertices (); ctx->texture_target = tex->gl_target; ctx->texture_current = gl_handle; + ctx->texture_format = tex->gl_intformat; /* Don't include the waste in the texture coordinates */ x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, 0);