cogl: expose the semantic differences of gl/gles2 npot textures

This adds three new feature flags COGL_FEATURE_TEXTURE_NPOT_BASIC,
COGL_FEATURE_TEXTURE_NPOT_MIPMAP and COGL_FEATURE_TEXTURE_NPOT_REPEAT
that can tell you if your hardware supports non power of two textures,
npot textures + mipmaps and npot textures + wrap modes other than
CLAMP_TO_EDGE.

The pre-existing COGL_FEATURE_TEXTURE_NPOT feature implies all of the
above.

By default GLES 2 core supports npot textures but mipmaps and repeat
modes can only be used with power of two textures. This patch also makes
GLES check for the GL_OES_texture_npot extension to determine if mipmaps
and repeating are supported with npot textures.
This commit is contained in:
Robert Bragg 2010-07-06 02:01:24 +01:00
parent c243086f44
commit 7571cc1923
4 changed files with 36 additions and 3 deletions

View File

@ -219,7 +219,10 @@ typedef enum { /*< prefix=COGL_PIXEL_FORMAT >*/
/** /**
* CoglFeatureFlags: * CoglFeatureFlags:
* @COGL_FEATURE_TEXTURE_RECTANGLE: ARB_texture_rectangle support * @COGL_FEATURE_TEXTURE_RECTANGLE: ARB_texture_rectangle support
* @COGL_FEATURE_TEXTURE_NPOT: ARB_texture_non_power_of_two support * @COGL_FEATURE_TEXTURE_NPOT: Non power of two textures are supported
* by the hardware. This is a equivalent to the
* %COGL_FEATURE_TEXTURE_NPOT_BASIC, %COGL_FEATURE_TEXTURE_NPOT_MIPMAP
* and %COGL_FEATURE_TEXTURE_NPOT_REPEAT features combined.
* @COGL_FEATURE_TEXTURE_YUV: ycbcr conversion support * @COGL_FEATURE_TEXTURE_YUV: ycbcr conversion support
* @COGL_FEATURE_TEXTURE_READ_PIXELS: glReadPixels() support * @COGL_FEATURE_TEXTURE_READ_PIXELS: glReadPixels() support
* @COGL_FEATURE_SHADERS_GLSL: GLSL support * @COGL_FEATURE_SHADERS_GLSL: GLSL support
@ -234,6 +237,17 @@ typedef enum { /*< prefix=COGL_PIXEL_FORMAT >*/
* %COGL_INDICES_TYPE_UNSIGNED_INT is supported in * %COGL_INDICES_TYPE_UNSIGNED_INT is supported in
* cogl_vertex_buffer_indices_new(). * cogl_vertex_buffer_indices_new().
* @COGL_FEATURE_DEPTH_RANGE: cogl_material_set_depth_range() support * @COGL_FEATURE_DEPTH_RANGE: cogl_material_set_depth_range() support
* @COGL_FEATURE_TEXTURE_NPOT_BASIC: The hardware supports non power
* of two textures, but you also need to check the
* %COGL_FEATURE_TEXTURE_NPOT_MIPMAP and %COGL_FEATURE_TEXTURE_NPOT_REPEAT
* features to know if the hardware supports npot texture mipmaps
* or repeat modes other than
* %COGL_MATERIAL_WRAP_MODE_CLAMP_TO_EDGE respectively.
* @COGL_FEATURE_TEXTURE_NPOT_MIPMAP: Mipmapping is supported in
* conjuntion with non power of two textures.
* @COGL_FEATURE_TEXTURE_NPOT_REPEAT: Repeat modes other than
* %COGL_MATERIAL_WRAP_MODE_CLAMP_TO_EDGE are supported by the
* hardware.
* *
* Flags for the supported features. * Flags for the supported features.
* *
@ -254,7 +268,10 @@ typedef enum
COGL_FEATURE_VBOS = (1 << 11), COGL_FEATURE_VBOS = (1 << 11),
COGL_FEATURE_PBOS = (1 << 12), COGL_FEATURE_PBOS = (1 << 12),
COGL_FEATURE_UNSIGNED_INT_INDICES = (1 << 13), COGL_FEATURE_UNSIGNED_INT_INDICES = (1 << 13),
COGL_FEATURE_DEPTH_RANGE = (1 << 14) COGL_FEATURE_DEPTH_RANGE = (1 << 14),
COGL_FEATURE_TEXTURE_NPOT_BASIC = (1 << 15),
COGL_FEATURE_TEXTURE_NPOT_MIPMAP = (1 << 16),
COGL_FEATURE_TEXTURE_NPOT_REPEAT = (1 << 17)
} CoglFeatureFlags; } CoglFeatureFlags;
/** /**

View File

@ -199,7 +199,10 @@ _cogl_features_init (void)
#ifdef HAVE_CLUTTER_OSX #ifdef HAVE_CLUTTER_OSX
if (really_enable_npot ()) if (really_enable_npot ())
#endif #endif
flags |= COGL_FEATURE_TEXTURE_NPOT; flags |= COGL_FEATURE_TEXTURE_NPOT
| COGL_FEATURE_TEXTURE_NPOT_BASIC
| COGL_FEATURE_TEXTURE_NPOT_MIPMAP
| COGL_FEATURE_TEXTURE_NPOT_REPEAT;
} }
#ifdef GL_YCBCR_MESA #ifdef GL_YCBCR_MESA

View File

@ -80,3 +80,13 @@ COGL_FEATURE_BEGIN (element_index_uint, 255, 255,
COGL_FEATURE_UNSIGNED_INT_INDICES, COGL_FEATURE_UNSIGNED_INT_INDICES,
0) 0)
COGL_FEATURE_END () COGL_FEATURE_END ()
COGL_FEATURE_BEGIN (texture_npot, 255, 255,
"OES\0",
"texture_npot\0",
COGL_FEATURE_TEXTURE_NPOT |
COGL_FEATURE_TEXTURE_NPOT_BASIC |
COGL_FEATURE_TEXTURE_NPOT_MIPMAP |
COGL_FEATURE_TEXTURE_NPOT_REPEAT,
0)
COGL_FEATURE_END ()

View File

@ -100,6 +100,9 @@ _cogl_features_init (void)
#ifdef HAVE_COGL_GLES2 #ifdef HAVE_COGL_GLES2
flags |= COGL_FEATURE_SHADERS_GLSL | COGL_FEATURE_OFFSCREEN; flags |= COGL_FEATURE_SHADERS_GLSL | COGL_FEATURE_OFFSCREEN;
/* Note GLES 2 core doesn't support mipmaps for npot textures or
* repeat modes other than CLAMP_TO_EDGE. */
flags |= COGL_FEATURE_TEXTURE_NPOT_BASIC;
#endif #endif
flags |= COGL_FEATURE_VBOS; flags |= COGL_FEATURE_VBOS;