features: Support more than 32 features!

Currently features are represented as bits in a 32bit mask so we
obviously can't have more than 32 features with that approach. The new
approach is to use the COGL_FLAGS_ macros which lets us handle bitmasks
without a size limit and we change the public api to accept individual
feature enums instead of a mask. This way there is no limit on the
number of features we can add to Cogl.

Instead of using cogl_features_available() there is a new
cogl_has_feature() function and for checking multiple features there is
cogl_has_features() which takes a zero terminated vararg list of
features.

In addition to being able to check for individual features this also
adds a way to query all the features currently available via
cogl_foreach_feature() which will call a callback for each feature.

Since the new functions take an explicit context pointer there is also
no longer any ambiguity over when users can first start to query
features.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
Robert Bragg
2011-10-12 22:31:12 +01:00
parent c86f698eb9
commit 426c8b8f41
27 changed files with 353 additions and 64 deletions

View File

@@ -687,8 +687,8 @@ get_max_activateable_texture_units (void)
defines the number of texture coordinates that can be
uploaded (but doesn't necessarily relate to how many texture
images can be sampled) */
if (cogl_features_available (COGL_FEATURE_SHADERS_GLSL) ||
cogl_features_available (COGL_FEATURE_SHADERS_ARBFP))
if (cogl_has_feature (ctx, COGL_FEATURE_ID_GLSL) ||
cogl_has_feature (ctx, COGL_FEATURE_ID_ARBFP))
/* Previously this code subtracted the value by one but there
was no explanation for why it did this and it doesn't seem
to make sense so it has been removed */
@@ -697,7 +697,7 @@ get_max_activateable_texture_units (void)
/* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS is defined for GLSL but
not ARBfp */
if (cogl_features_available (COGL_FEATURE_SHADERS_GLSL))
if (cogl_has_feature (ctx, COGL_FEATURE_ID_GLSL))
GE (ctx, glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
values + n_values++));
}