cogl-texture: for foreign textures; always trust user geom

We now never query the width and height of the given texture object
from OpenGL. The problem is that the user may be creating a Cogl
texture from a texture_from_pixmap object where glTexImage2D was
never called and the texture_from_pixmap spec doesn't clarify that
it's reliable to query the width from OpenGL.

This should address:
http://bugzilla.openedhand.com/show_bug.cgi?id=1502

Thanks to Johan Bilien for reporting
This commit is contained in:
Robert Bragg 2010-02-16 14:23:11 +00:00
parent 1d54ecb8a1
commit e96072c90a

View File

@ -1076,11 +1076,8 @@ _cogl_texture_2d_sliced_new_from_foreign (GLuint gl_handle,
CoglPixelFormat format) CoglPixelFormat format)
{ {
/* NOTE: width, height and internal format are not queriable /* NOTE: width, height and internal format are not queriable
in GLES, hence such a function prototype. However, for * in GLES, hence such a function prototype.
OpenGL they are still queried from the texture for improved */
robustness and for completeness in case one day GLES gains
support for them.
*/
GLenum gl_error = 0; GLenum gl_error = 0;
GLboolean gl_istexture; GLboolean gl_istexture;
@ -1132,19 +1129,16 @@ _cogl_texture_2d_sliced_new_from_foreign (GLuint gl_handle,
GE( glGetTexLevelParameteriv (gl_target, 0, GE( glGetTexLevelParameteriv (gl_target, 0,
GL_TEXTURE_INTERNAL_FORMAT, GL_TEXTURE_INTERNAL_FORMAT,
&gl_int_format) ); &gl_int_format) );
#endif
/* Note: We always trust the given width and height without querying
GE( glGetTexLevelParameteriv (gl_target, 0, * the texture object because the user may be creating a Cogl
GL_TEXTURE_WIDTH, * texture for a texture_from_pixmap object where glTexImage2D may
&gl_width) ); * not have been called and the texture_from_pixmap spec doesn't
* clarify that it is reliable to query back the size from OpenGL.
GE( glGetTexLevelParameteriv (gl_target, 0, */
GL_TEXTURE_HEIGHT,
&gl_height) );
#else
gl_width = width + x_pot_waste; gl_width = width + x_pot_waste;
gl_height = height + y_pot_waste; gl_height = height + y_pot_waste;
#endif
GE( glGetTexParameteriv (gl_target, GE( glGetTexParameteriv (gl_target,
GL_GENERATE_MIPMAP, GL_GENERATE_MIPMAP,