* 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)
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)
{
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;
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) );
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,
#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
* identify when alpha only textures are bound.
#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,
GLenum gl_intformat)
#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,