From 4c01df36e6e7ef71c3bb8b5f4f156155f83ace3f Mon Sep 17 00:00:00 2001 From: Matthew Allum Date: Wed, 16 May 2007 09:08:30 +0000 Subject: [PATCH] 2007-05-16 Matthew Allum * clutter/clutter-backend.c: * clutter/clutter-backend.h: * clutter/clutter-feature.c: * clutter/clutter-feature.h: * clutter/clutter-main.c: * clutter/clutter-main.h: * clutter/clutter-private.h: * clutter/clutter-stage.c: * clutter/cogl/cogl.h: * clutter/cogl/gl/cogl.c: * clutter/cogl/gles/cogl.c: * clutter/glx/clutter-backend-glx.c: * clutter/glx/clutter-backend-glx.h: * clutter/glx/clutter-glx.h: * clutter/glx/clutter-stage-glx.c: * clutter/glx/clutter-stage-glx.h: Rejig the features() foo, moving mostly into backends/cogl. --- cogl.h | 2 ++ gl/cogl.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++- gles/cogl.c | 8 ++++++- 3 files changed, 76 insertions(+), 2 deletions(-) diff --git a/cogl.h b/cogl.h index f787835aa..44b9d14a4 100644 --- a/cogl.h +++ b/cogl.h @@ -178,6 +178,8 @@ void cogl_alpha_func (COGLenum func, ClutterFixed ref); +ClutterFeatureFlags +cogl_get_features (); G_END_DECLS diff --git a/gl/cogl.c b/gl/cogl.c index abaa6b8dc..70ab95566 100644 --- a/gl/cogl.c +++ b/gl/cogl.c @@ -84,11 +84,56 @@ error_string(GLenum errorCode) #define GE(x) (x); #endif +static gboolean +check_gl_extension (const gchar *name, + const gchar *ext) +{ + gchar *end; + gint name_len, n; + + if (name == NULL || ext == NULL) + return FALSE; + + end = (gchar*)(ext + strlen(ext)); + + name_len = strlen(name); + + while (ext < end) + { + n = strcspn(ext, " "); + + if ((name_len == n) && (!strncmp(name, ext, n))) + return TRUE; + ext += (n + 1); + } + + return FALSE; +} + +static gboolean +is_gl_version_at_least_12 (void) +{ + /* FIXME: This likely needs to live elsewhere in features or cogl */ + return + (g_ascii_strtod ((const gchar*) glGetString (GL_VERSION), NULL) >= 1.2); + +#if 0 + /* At least GL 1.2 is needed for CLAMP_TO_EDGE */ + /* FIXME: move to cogl... */ + if (!is_gl_version_at_least_12 ()) + { + g_set_error (error, CLUTTER_INIT_ERROR, + CLUTTER_INIT_ERROR_BACKEND, + "Clutter needs at least version 1.2 of OpenGL"); + return FALSE; + } +#endif +} CoglFuncPtr cogl_get_proc_address (const gchar* name) { - return NULL; + /* FIXME */ } gboolean @@ -527,3 +572,24 @@ cogl_setup_viewport (guint width, 1.0f / width) ); GE( glTranslatef (0.0f, -1.0 * height, 0.0f) ); } + +ClutterFeatureFlags +cogl_get_features () +{ + ClutterFeatureFlags flags = 0; + const gchar *gl_extensions; + + flags = CLUTTER_FEATURE_TEXTURE_READ_PIXELS; + + gl_extensions = (const gchar*) glGetString (GL_EXTENSIONS); + + + if (check_gl_extension ("GL_ARB_texture_rectangle", gl_extensions) || + check_gl_extension ("GL_EXT_texture_rectangle", gl_extensions)) + { + flags |= CLUTTER_FEATURE_TEXTURE_RECTANGLE; + } + + return flags; +} + diff --git a/gles/cogl.c b/gles/cogl.c index 67483c3f5..0739a7b57 100644 --- a/gles/cogl.c +++ b/gles/cogl.c @@ -515,5 +515,11 @@ cogl_setup_viewport (guint w, CFX_ONE / width)); GE( glTranslatex (0, -CFX_ONE * height, 0) ); - +} + +ClutterFeatureFlags +cogl_get_features () +{ + /* Suck */ + return 0; }