diff --git a/clutter/cogl/cogl/cogl-texture-2d-sliced.c b/clutter/cogl/cogl/cogl-texture-2d-sliced.c index 0cfef1f58..b7a7bd7af 100644 --- a/clutter/cogl/cogl/cogl-texture-2d-sliced.c +++ b/clutter/cogl/cogl/cogl-texture-2d-sliced.c @@ -829,8 +829,7 @@ _cogl_texture_2d_sliced_slices_create (CoglTexture2DSliced *tex_2ds, * re-binding between textures inside a set) */ gl_handles = (GLuint*) tex_2ds->slice_gl_handles->data; - GE( glGenTextures (n_slices, gl_handles) ); - + _cogl_texture_driver_gen (GL_TEXTURE_2D, n_slices, gl_handles); /* Init each GL texture object */ for (y = 0; y < n_y_slices; ++y) @@ -917,9 +916,9 @@ _cogl_texture_2d_sliced_upload_from_data tex_2ds->slice_y_spans = NULL; tex_2ds->slice_gl_handles = NULL; - /* Unknown filter */ - tex_2ds->min_filter = GL_FALSE; - tex_2ds->mag_filter = GL_FALSE; + /* We default to GL_LINEAR for both filters */ + tex_2ds->min_filter = GL_LINEAR; + tex_2ds->mag_filter = GL_LINEAR; if (bmp->data) { diff --git a/clutter/cogl/cogl/cogl-texture-2d.c b/clutter/cogl/cogl/cogl-texture-2d.c index 8d32e310e..b700eb19f 100644 --- a/clutter/cogl/cogl/cogl-texture-2d.c +++ b/clutter/cogl/cogl/cogl-texture-2d.c @@ -225,9 +225,9 @@ _cogl_texture_2d_create_base (unsigned int width, tex_2d->mipmaps_dirty = TRUE; tex_2d->auto_mipmap = (flags & COGL_TEXTURE_NO_AUTO_MIPMAP) == 0; - /* Unknown filter */ - tex_2d->min_filter = GL_FALSE; - tex_2d->mag_filter = GL_FALSE; + /* We default to GL_LINEAR for both filters */ + tex_2d->min_filter = GL_LINEAR; + tex_2d->mag_filter = GL_LINEAR; /* Wrap mode not yet set */ tex_2d->wrap_mode = GL_FALSE; @@ -263,6 +263,7 @@ _cogl_texture_2d_new_with_size (unsigned int width, tex_2d = _cogl_texture_2d_create_base (width, height, flags, internal_format); GE( glGenTextures (1, &tex_2d->gl_texture) ); + GE( glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) ); GE( glBindTexture (GL_TEXTURE_2D, tex_2d->gl_texture) ); GE( glTexImage2D (GL_TEXTURE_2D, 0, gl_intformat, width, height, 0, gl_format, gl_type, NULL) ); @@ -300,7 +301,7 @@ _cogl_texture_2d_new_from_bitmap (CoglHandle bmp_handle, flags, internal_format); - GE( glGenTextures (1, &tex_2d->gl_texture) ); + _cogl_texture_driver_gen (GL_TEXTURE_2D, 1, &tex_2d->gl_texture); _cogl_texture_driver_upload_to_gl (GL_TEXTURE_2D, tex_2d->gl_texture, &dst_bmp, diff --git a/clutter/cogl/cogl/cogl-texture-driver.h b/clutter/cogl/cogl/cogl-texture-driver.h index 6961659d8..5f08cfba9 100644 --- a/clutter/cogl/cogl/cogl-texture-driver.h +++ b/clutter/cogl/cogl/cogl-texture-driver.h @@ -24,6 +24,15 @@ #ifndef __COGL_TEXTURE_DRIVER_H #define __COGL_TEXTURE_DRIVER_H +/* + * A very small wrapper around glGenTextures() that ensures we default to + * non-mipmap filters when creating textures. This is to save some memory as + * the driver will not allocate room for the mipmap tree. + */ +void +_cogl_texture_driver_gen (GLenum gl_target, + GLsizei n, + GLuint *textures); /* * Basically just a wrapper around glBindTexture, but the GLES2 backend * for example also wants to know about the internal format so it can diff --git a/clutter/cogl/cogl/driver/gl/cogl-texture-driver.c b/clutter/cogl/cogl/driver/gl/cogl-texture-driver.c index f1fe59a2f..5d7c9f864 100644 --- a/clutter/cogl/cogl/driver/gl/cogl-texture-driver.c +++ b/clutter/cogl/cogl/driver/gl/cogl-texture-driver.c @@ -47,6 +47,33 @@ #define glGenerateMipmap ctx->drv.pf_glGenerateMipmap +void +_cogl_texture_driver_gen (GLenum gl_target, + GLsizei n, + GLuint *textures) +{ + guint i; + + GE (glGenTextures (n, textures)); + + for (i = 0; i < n; i++) + { + GE (glBindTexture (gl_target, textures[i])); + + switch (gl_target) + { + case GL_TEXTURE_2D: + /* GL_TEXTURE_MAG_FILTER defaults to GL_LINEAR, no need to set it */ + GE( glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) ); + break; + + default: + g_assert_not_reached(); + } + + } +} + void _cogl_texture_driver_bind (GLenum gl_target, GLuint gl_handle, diff --git a/clutter/cogl/cogl/driver/gles/cogl-texture-driver.c b/clutter/cogl/cogl/driver/gles/cogl-texture-driver.c index 62324f58c..41cc9a822 100644 --- a/clutter/cogl/cogl/driver/gles/cogl-texture-driver.c +++ b/clutter/cogl/cogl/driver/gles/cogl-texture-driver.c @@ -47,6 +47,33 @@ #include "cogl-gles2-wrapper.h" +void +_cogl_texture_driver_gen (GLenum gl_target, + GLsizei n, + GLuint *textures) +{ + guint i; + + GE (glGenTextures (n, textures)); + + for (i = 0; i < n; i++) + { + GE (glBindTexture (gl_target, textures[i])); + + switch (gl_target) + { + case GL_TEXTURE_2D: + /* GL_TEXTURE_MAG_FILTER defaults to GL_LINEAR, no need to set it */ + GE( glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) ); + break; + + default: + g_assert_not_reached(); + } + + } +} + void _cogl_texture_driver_bind (GLenum gl_target,