summaryrefslogtreecommitdiff
path: root/clutter/clutter-feature.c
diff options
context:
space:
mode:
authorMatthew Allum <mallum@openedhand.com>2006-07-24 21:15:19 +0000
committerMatthew Allum <mallum@openedhand.com>2006-07-24 21:15:19 +0000
commitecccec75cb4769f479e64e5bdb7526c9cbf97e35 (patch)
tree97b82581cc30dcdda74c9b4bc94c88af26ad36f1 /clutter/clutter-feature.c
parent55f9adeb413d951e7856911363ef74c0366e5af6 (diff)
downloadclutter-ecccec75cb4769f479e64e5bdb7526c9cbf97e35.tar.gz
2006-07-24 Matthew Allum <mallum@openedhand.com>
* clutter/Makefile.am: * clutter/clutter-feature.c: * clutter/clutter-feature.h: Add new funcs for checking for available runtime GL extensions. * clutter/clutter-clone-texture.c: * clutter/clutter-texture.c: Add support for non power of two textures if GL_TEXTURE_RECTANGLE_ARB extension available ( at runtime ). Should lower texture memory needs a little.
Diffstat (limited to 'clutter/clutter-feature.c')
-rw-r--r--clutter/clutter-feature.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/clutter/clutter-feature.c b/clutter/clutter-feature.c
new file mode 100644
index 000000000..e1aa05572
--- /dev/null
+++ b/clutter/clutter-feature.c
@@ -0,0 +1,91 @@
+/*
+ * Clutter.
+ *
+ * An OpenGL based 'interactive canvas' library.
+ *
+ * Authored By Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright (C) 2006 OpenedHand
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * SECTION:clutter-feature
+ * @short_description: functions to query available GL features ay runtime
+ *
+ * Functions to query available GL features ay runtime
+ */
+
+#include "config.h"
+#include "clutter-feature.h"
+#include "string.h"
+
+static gulong __features;
+
+/* Note must be called after context created */
+static gboolean
+check_gl_extension (const gchar *name)
+{
+ const gchar *ext;
+ gchar *end;
+ gint name_len, n;
+
+ ext = (const gchar*)glGetString(GL_EXTENSIONS);
+
+ 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;
+}
+
+gboolean
+clutter_feature_available (gulong query)
+{
+ return (__features & query);
+}
+
+gulong
+clutter_feature_all (void)
+{
+ return __features;
+}
+
+void
+clutter_feature_init (void)
+{
+ if (__features)
+ return;
+
+ __features = 0;
+
+ if (check_gl_extension ("GL_ARB_texture_rectangle"))
+ __features |= CLUTTER_FEATURE_TEXTURE_RECTANGLE;
+
+}