summaryrefslogtreecommitdiff
path: root/cogl/cogl-debug.c
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2011-06-14 22:33:44 +0100
committerRobert Bragg <robert@linux.intel.com>2011-06-30 14:33:11 +0100
commita1234ee8d14a6f5d11bf9b5c67d95aac5d94256e (patch)
treeb1d2a00ff5fe401dc3ea61519370b48444feb434 /cogl/cogl-debug.c
parente5c4c1ce7c6bc1c06c6fce5d516cca2e76cc5620 (diff)
downloadcogl-a1234ee8d14a6f5d11bf9b5c67d95aac5d94256e.tar.gz
Add internal _cogl_init() function
This adds a _cogl_init function for Cogl that we expect to be the first thing called before anything else is done with Cogl. It's not a public API so it's expected that all entry points for Cogl that might be the first function used should call _cogl_init(). We currently call _cogl_init() in these functions: cogl_renderer_new cogl_display_new cogl_context_new cogl_android_set_native_window _cogl_init() can be called multiple times, and only the first call has any affect. For example _cogl_init() gives us a place check and parse the COGL_DEBUG environment variable. Since we don't have any need to parse command line arguments (we can always get user configuration options from the environment) our init function doesn't require argc/argv pointers. By saying up front that we aren't interested in command line arguments that means we can avoid the mess that is GOption based library initialization which is extremely fragile due to its lack of dependency tracking between modules. Signed-off-by: Neil Roberts <neil@linux.intel.com>
Diffstat (limited to 'cogl/cogl-debug.c')
-rw-r--r--cogl/cogl-debug.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/cogl/cogl-debug.c b/cogl/cogl-debug.c
index 46ab5b4d..51163486 100644
--- a/cogl/cogl-debug.c
+++ b/cogl/cogl-debug.c
@@ -28,10 +28,10 @@
#include <stdlib.h>
#include <glib/gi18n-lib.h>
+#include "cogl.h"
+#include "cogl-private.h"
#include "cogl-debug.h"
-#ifdef COGL_ENABLE_DEBUG
-
/* XXX: If you add a debug option, please also add an option
* definition to cogl-debug-options.h. This will enable us - for
* example - to emit a "help" description for the option.
@@ -176,6 +176,7 @@ _cogl_parse_debug_string (const char *value,
}
}
+#ifdef COGL_ENABLE_DEBUG
static gboolean
cogl_arg_debug_cb (const char *key,
const char *value,
@@ -209,13 +210,9 @@ static GOptionEntry cogl_args[] = {
{ NULL, },
};
-static gboolean
-pre_parse_hook (GOptionContext *context,
- GOptionGroup *group,
- gpointer data,
- GError **error)
+void
+_cogl_debug_check_environment (void)
{
-#ifdef COGL_ENABLE_DEBUG
const char *env_string;
env_string = g_getenv ("COGL_DEBUG");
@@ -226,11 +223,22 @@ pre_parse_hook (GOptionContext *context,
FALSE /* don't ignore help */);
env_string = NULL;
}
-#endif /* COGL_ENABLE_DEBUG */
+}
+
+static gboolean
+pre_parse_hook (GOptionContext *context,
+ GOptionGroup *group,
+ gpointer data,
+ GError **error)
+{
+ _cogl_init ();
return TRUE;
}
+/* XXX: GOption based library initialization is not reliable because the
+ * GOption API has no way to represent dependencies between libraries.
+ */
GOptionGroup *
cogl_get_option_group (void)
{