diff --git a/ChangeLog b/ChangeLog index 06126664a..7ab5578cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-05-28 Neil Roberts + + * clutter/cogl/gles/cogl-texture.c: Use the wrapper for + glTexParameteri. Call glGenerateMipmap after every change to the + texture image data. + + * clutter/cogl/gles/cogl-gles2-wrapper.h: + * clutter/cogl/gles/cogl-gles2-wrapper.c: Added a wrapper for + glTexParameteri so that it can ignore requests to set + GL_GENERATE_MIPMAP. Added a wrapper for glGenerateMipmap that does + nothing on GLES 1 + 2008-05-28 Emmanuele Bassi * clutter/clutter-script.c: diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.c b/clutter/cogl/gles/cogl-gles2-wrapper.c index 8151d961b..267528cba 100644 --- a/clutter/cogl/gles/cogl-gles2-wrapper.c +++ b/clutter/cogl/gles/cogl-gles2-wrapper.c @@ -630,3 +630,10 @@ cogl_wrap_glFogxv (GLenum pname, const GLfixed *params) { /* FIXME */ } + +void +cogl_wrap_glTexParameteri (GLenum target, GLenum pname, GLfloat param) +{ + if (pname != GL_GENERATE_MIPMAP) + glTexParameteri (target, pname, param); +} diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.h b/clutter/cogl/gles/cogl-gles2-wrapper.h index 2e3f750f3..81d4495d5 100644 --- a/clutter/cogl/gles/cogl-gles2-wrapper.h +++ b/clutter/cogl/gles/cogl-gles2-wrapper.h @@ -148,9 +148,14 @@ void cogl_wrap_glFogxv (GLenum pname, const GLfixed *params); void cogl_wrap_glDrawArrays (GLenum mode, GLint first, GLsizei count); +void cogl_wrap_glTexParameteri (GLenum target, GLenum pname, GLfloat param); + void cogl_gles2_wrapper_bind_texture (GLenum target, GLuint texture, GLenum internal_format); +/* This function is only available on GLES 2 */ +#define cogl_wrap_glGenerateMipmap glGenerateMipmap + #else /* HAVE_COGL_GLES2 */ /* If we're not using GL ES 2 then just use the GL functions @@ -181,12 +186,17 @@ void cogl_gles2_wrapper_bind_texture (GLenum target, GLuint texture, #define cogl_wrap_glGetFixedv glGetFixedv #define cogl_wrap_glFogx glFogx #define cogl_wrap_glFogxv glFogxv +#define cogl_wrap_glTexParameteri glTexParameteri /* The extra third parameter of the bind texture wrapper isn't needed so we can just directly call glBindTexture */ #define cogl_gles2_wrapper_bind_texture(target, texture, internal_format) \ glBindTexture ((target), (texture)) +/* COGL uses the automatic mipmap generation for GLES 1 so + glGenerateMipmap doesn't need to do anything */ +#define cogl_wrap_glGenerateMipmap(x) ((void) 0) + #endif /* HAVE_COGL_GLES2 */ G_END_DECLS diff --git a/clutter/cogl/gles/cogl-texture.c b/clutter/cogl/gles/cogl-texture.c index 7b4ad2158..70362239e 100644 --- a/clutter/cogl/gles/cogl-texture.c +++ b/clutter/cogl/gles/cogl-texture.c @@ -232,6 +232,9 @@ _cogl_texture_upload_to_gl (CoglTexture *tex) slice_bmp.height, tex->gl_format, tex->gl_type, slice_bmp.data) ); + + if (tex->auto_mipmap) + cogl_wrap_glGenerateMipmap (tex->gl_target); /* Free temp bitmap */ g_free (slice_bmp.data); @@ -603,6 +606,9 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, source_gl_type, slice_bmp.data) ); + if (tex->auto_mipmap) + cogl_wrap_glGenerateMipmap (tex->gl_target); + /* Free temp bitmap */ g_free (slice_bmp.data); } @@ -816,13 +822,18 @@ _cogl_texture_slices_create (CoglTexture *tex) gl_handles[y * n_x_slices + x], tex->gl_intformat) ); - GE( glTexParameteri (tex->gl_target, GL_TEXTURE_MAG_FILTER, tex->mag_filter) ); - GE( glTexParameteri (tex->gl_target, GL_TEXTURE_MIN_FILTER, tex->min_filter) ); - GE( glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) ); - GE( glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) ); + GE( cogl_wrap_glTexParameteri (tex->gl_target, GL_TEXTURE_MAG_FILTER, + tex->mag_filter) ); + GE( cogl_wrap_glTexParameteri (tex->gl_target, GL_TEXTURE_MIN_FILTER, + tex->min_filter) ); + GE( cogl_wrap_glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_S, + GL_CLAMP_TO_EDGE) ); + GE( cogl_wrap_glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_T, + GL_CLAMP_TO_EDGE) ); if (tex->auto_mipmap) - GE( glTexParameteri (tex->gl_target, GL_GENERATE_MIPMAP, GL_TRUE) ); + GE( cogl_wrap_glTexParameteri (tex->gl_target, GL_GENERATE_MIPMAP, + GL_TRUE) ); /* Pass NULL data to init size and internal format */ GE( glTexImage2D (tex->gl_target, 0, tex->gl_intformat, @@ -1351,8 +1362,10 @@ cogl_texture_new_from_foreign (GLuint gl_handle, g_array_append_val (tex->slice_gl_handles, gl_handle); /* Force appropriate wrap parameter */ - GE( glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) ); - GE( glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) ); + GE( cogl_wrap_glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_S, + GL_CLAMP_TO_EDGE) ); + GE( cogl_wrap_glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_T, + GL_CLAMP_TO_EDGE) ); return _cogl_texture_handle_new (tex); } @@ -1554,8 +1567,10 @@ cogl_texture_set_filters (CoglHandle handle, { gl_handle = g_array_index (tex->slice_gl_handles, GLuint, i); GE( glBindTexture (tex->gl_target, gl_handle) ); - GE( glTexParameteri (tex->gl_target, GL_TEXTURE_MAG_FILTER, tex->mag_filter) ); - GE( glTexParameteri (tex->gl_target, GL_TEXTURE_MIN_FILTER, tex->min_filter) ); + GE( cogl_wrap_glTexParameteri (tex->gl_target, GL_TEXTURE_MAG_FILTER, + tex->mag_filter) ); + GE( cogl_wrap_glTexParameteri (tex->gl_target, GL_TEXTURE_MIN_FILTER, + tex->min_filter) ); } }