summaryrefslogtreecommitdiff
path: root/cogl/cogl.h
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2011-10-12 22:31:12 +0100
committerRobert Bragg <robert@linux.intel.com>2011-11-01 12:03:01 +0000
commit426c8b8f41626527bcf764bc275d46ffe8c2e84b (patch)
tree1516ef2cacb1d7f4379154694b5dcf5ac50f4b1a /cogl/cogl.h
parentc86f698eb9088db0d3dd32497d29a56a9e144143 (diff)
downloadcogl-426c8b8f41626527bcf764bc275d46ffe8c2e84b.tar.gz
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>
Diffstat (limited to 'cogl/cogl.h')
-rw-r--r--cogl/cogl.h150
1 files changed, 150 insertions, 0 deletions
diff --git a/cogl/cogl.h b/cogl/cogl.h
index 08f44026..1f738a7c 100644
--- a/cogl/cogl.h
+++ b/cogl/cogl.h
@@ -157,6 +157,156 @@ cogl_get_features (void);
gboolean
cogl_features_available (CoglFeatureFlags features);
+/* XXX: not guarded by the EXPERIMENTAL_2_0_API defines to avoid
+ * upsetting glib-mkenums, but this can still be considered implicitly
+ * experimental since it's only useable with experimental API... */
+/**
+ * CoglFeatureID:
+ * @COGL_FEATURE_ID_TEXTURE_NPOT_BASIC: The hardware supports non power
+ * of two textures, but you also need to check the
+ * %COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP and %COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT
+ * features to know if the hardware supports npot texture mipmaps
+ * or repeat modes other than
+ * %COGL_RENDERER_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE respectively.
+ * @COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP: Mipmapping is supported in
+ * conjuntion with non power of two textures.
+ * @COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT: Repeat modes other than
+ * %COGL_RENDERER_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE are supported by the
+ * hardware.
+ * @COGL_FEATURE_ID_TEXTURE_NPOT: Non power of two textures are supported
+ * by the hardware. This is a equivalent to the
+ * %COGL_FEATURE_ID_TEXTURE_NPOT_BASIC, %COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP
+ * and %COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT features combined.
+ * @COGL_FEATURE_ID_TEXTURE_RECTANGLE: Support for rectangular
+ * textures with non-normalized texture coordinates.
+ * @COGL_FEATURE_ID_TEXTURE_3D: 3D texture support
+ * @COGL_FEATURE_ID_OFFSCREEN: Offscreen rendering support
+ * @COGL_FEATURE_ID_OFFSCREEN_MULTISAMPLE: Multisample support for
+ * offscreen framebuffers
+ * @COGL_FEATURE_ID_ONSCREEN_MULTIPLE: Multiple onscreen framebuffers
+ * supported.
+ * @COGL_FEATURE_ID_GLSL: GLSL support
+ * @COGL_FEATURE_ID_ARBFP: ARBFP support
+ * @COGL_FEATURE_ID_UNSIGNED_INT_INDICES: Set if
+ * %COGL_RENDERER_INDICES_TYPE_UNSIGNED_INT is supported in
+ * cogl_indices_new().
+ * @COGL_FEATURE_ID_DEPTH_RANGE: cogl_pipeline_set_depth_range() support
+ * @COGL_FEATURE_ID_POINT_SPRITE: Whether
+ * cogl_pipeline_set_layer_point_sprite_coords_enabled() is supported.
+ * @COGL_FEATURE_ID_MAP_BUFFER_FOR_READ: Whether cogl_buffer_map() is
+ * supported with CoglBufferAccess including read support.
+ * @COGL_FEATURE_ID_MAP_BUFFER_FOR_WRITE: Whether cogl_buffer_map() is
+ * supported with CoglBufferAccess including write support.
+ *
+ *
+ * All the capabilities that can vary between different GPUs supported
+ * by Cogl. Applications that depend on any of these features should explicitly
+ * check for them using cogl_has_feature() or cogl_has_features().
+ *
+ * Since: 1.10
+ */
+typedef enum _CoglFeatureID
+{
+ COGL_FEATURE_ID_TEXTURE_NPOT_BASIC = 1,
+ COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP,
+ COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT,
+ COGL_FEATURE_ID_TEXTURE_NPOT,
+ COGL_FEATURE_ID_TEXTURE_RECTANGLE,
+ COGL_FEATURE_ID_TEXTURE_3D,
+ COGL_FEATURE_ID_GLSL,
+ COGL_FEATURE_ID_ARBFP,
+ COGL_FEATURE_ID_OFFSCREEN,
+ COGL_FEATURE_ID_OFFSCREEN_MULTISAMPLE,
+ COGL_FEATURE_ID_ONSCREEN_MULTIPLE,
+ COGL_FEATURE_ID_UNSIGNED_INT_INDICES,
+ COGL_FEATURE_ID_DEPTH_RANGE,
+ COGL_FEATURE_ID_POINT_SPRITE,
+ COGL_FEATURE_ID_MAP_BUFFER_FOR_READ,
+ COGL_FEATURE_ID_MAP_BUFFER_FOR_WRITE,
+
+ /*< private > */
+ _COGL_N_FEATURE_IDS
+} CoglFeatureID;
+
+
+#ifdef COGL_ENABLE_EXPERIMENTAL_2_0_API
+
+#define cogl_has_feature cogl_has_feature_EXP
+/**
+ * cogl_has_feature:
+ * @context: A #CoglContext pointer
+ * @feature: A #CoglFeatureID
+ *
+ * Checks if a given @feature is currently available
+ *
+ * Cogl does not aim to be a lowest common denominator API, it aims to
+ * expose all the interesting features of GPUs to application which
+ * means applications have some responsibility to explicitly check
+ * that certain features are available before depending on them.
+ *
+ * Returns: %TRUE if the @feature is currently supported or %FALSE if
+ * not.
+ *
+ * Since: 1.10
+ * Stability: unstable
+ */
+gboolean
+cogl_has_feature (CoglContext *context, CoglFeatureID feature);
+
+#define cogl_has_features cogl_has_features_EXP
+/**
+ * cogl_has_features:
+ * @context: A #CoglContext pointer
+ * @...: A 0 terminated list of CoglFeatureID<!-- -->s
+ *
+ * Checks if a list of features are all currently available.
+ *
+ * This checks all of the listed features using cogl_has_feature() and
+ * returns %TRUE if all the features are available or %FALSE
+ * otherwise.
+ *
+ * Return value: %TRUE if all the features are available, %FALSE
+ * otherwise.
+ *
+ * Since: 1.10
+ * Stability: unstable
+ */
+gboolean
+cogl_has_features (CoglContext *context, ...);
+
+/**
+ * CoglFeatureCallback:
+ * @feature: A single feature currently supported by Cogl
+ * @user_data: A private pointer passed to cogl_foreach_feature().
+ *
+ * A callback used with cogl_foreach_feature() for enumerating all
+ * context level features supported by Cogl.
+ *
+ * Since: 1.10
+ * Stability: unstable
+ */
+typedef void (*CoglFeatureCallback) (CoglFeatureID feature, void *user_data);
+
+#define cogl_foreach_feature cogl_foreach_feature_EXP
+/**
+ * cogl_foreach_feature:
+ * @context: A #CoglContext pointer
+ * @callback: A #CoglFeatureCallback called for each supported feature
+ * @user_data: Private data to pass to the callback
+ *
+ * Iterates through all the context level features currently supported
+ * for a given @context and for each feature @callback is called.
+ *
+ * Since: 1.10
+ * Stability: unstable
+ */
+void
+cogl_foreach_feature (CoglContext *context,
+ CoglFeatureCallback callback,
+ void *user_data);
+
+#endif /* COGL_ENABLE_EXPERIMENTAL_2_0_API */
+
/**
* cogl_get_proc_address:
* @name: the name of the function.