2006-07-24 21:15:19 +00:00
|
|
|
/*
|
|
|
|
* 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
|
2010-03-01 12:56:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
2006-07-24 21:15:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:clutter-feature
|
2010-01-15 17:06:56 +00:00
|
|
|
* @short_description: Run-time detection of Clutter features
|
2006-07-24 21:15:19 +00:00
|
|
|
*
|
2010-01-15 17:06:56 +00:00
|
|
|
* Parts of Clutter depend on the underlying platform, including the
|
|
|
|
* capabilities of the backend used and the OpenGL features exposed through the
|
|
|
|
* Clutter and COGL API.
|
|
|
|
*
|
|
|
|
* It is possible to ask whether Clutter has support for specific features at
|
|
|
|
* run-time.
|
|
|
|
*
|
|
|
|
* See also cogl_get_features() and #CoglFeatureFlags
|
2006-07-24 21:15:19 +00:00
|
|
|
*/
|
|
|
|
|
2007-10-12 08:17:00 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2006-07-24 21:15:19 +00:00
|
|
|
#include "config.h"
|
2007-10-12 08:17:00 +00:00
|
|
|
#endif
|
2006-07-24 21:15:19 +00:00
|
|
|
|
2006-11-15 21:19:01 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
2006-11-21 Emmanuele Bassi <ebassi@openedhand.com>
* configure.ac: Enable debug messages also when
--enable-debug is set to "minimum".
* clutter/Makefile.am:
* clutter/clutter-debug.h: Move all debugging macros inside
this private header; make all debug macros depend on the
CLUTTER_ENABLE_DEBUG compile time define, controlled by
the --enable-debug configure switch; add G_LOG_DOMAIN define.
* clutter/clutter-main.c: Clean up the debug stuff; add
command line argument parsing using GOption; the debug
messages now are triggered like this:
CLUTTER_DEBUG=section:section:... clutter-app
or like this:
clutter-app --clutter-debug=section:section:...
where "section" is one of the sections listed in clutter-main.c,
or "all", for all sections; each section is bound to a flag,
which can be used to define a domain when adding a debug note
using the CLUTTER_NOTE() macro; the old CLUTTER_DBG() macro is
just a wrapper around that, under the CLUTTER_DEBUG_MISC domain;
CLUTTER_NOTE() is used like this:
CLUTTER_NOTE (DOMAIN, log-function);
where log function is g_printerr(), g_message(), g_warning(),
g_critical() or directly g_log() - for instance:
CLUTTER_NOTE (PANGO, g_warning ("Cache miss: %d", glyph));
will print the warning only if the "pango" flag has been
set to the CLUTTER_DEBUG envvar or passed to the --clutter-debug
command line argument.
similar to CLUTTER_SHOW_FPS, there's also the --clutter-show-fps
command line switch; also, the --display and --screen command
line switches have been added: the first overrides the DISPLAY
envvar and the second controls the X screen used by Clutter to
get the root window on the display.
* clutter/clutter-main.h:
* clutter/clutter-main.c: Add extended support for GOption
in Clutter; use clutter_init_with_args() to let Clutter
parse your own command line arguments; use instead
clutter_get_option_group() to get the GOptionGroup used by
Clutter if you want to do the parsing yourself with
g_option_context_parse(). The init sequence has been verified,
updated and moved into common functions where possible.
* clutter/pango/pangoclutter-render.c:
* clutter/*.c: Include "clutter-debug.h" where needed; use
CLUTTER_NOTE() instead of CLUTTER_DBG().
* examples/super-oh.c: Use the new clutter_init_with_args()
function, and add a --num-hands command line switch to
the SuperOH example code controlling the number of hands at
runtime.
2006-11-21 21:27:53 +00:00
|
|
|
|
2010-10-21 10:49:37 +00:00
|
|
|
#include "clutter-backend-private.h"
|
2006-11-21 Emmanuele Bassi <ebassi@openedhand.com>
* configure.ac: Enable debug messages also when
--enable-debug is set to "minimum".
* clutter/Makefile.am:
* clutter/clutter-debug.h: Move all debugging macros inside
this private header; make all debug macros depend on the
CLUTTER_ENABLE_DEBUG compile time define, controlled by
the --enable-debug configure switch; add G_LOG_DOMAIN define.
* clutter/clutter-main.c: Clean up the debug stuff; add
command line argument parsing using GOption; the debug
messages now are triggered like this:
CLUTTER_DEBUG=section:section:... clutter-app
or like this:
clutter-app --clutter-debug=section:section:...
where "section" is one of the sections listed in clutter-main.c,
or "all", for all sections; each section is bound to a flag,
which can be used to define a domain when adding a debug note
using the CLUTTER_NOTE() macro; the old CLUTTER_DBG() macro is
just a wrapper around that, under the CLUTTER_DEBUG_MISC domain;
CLUTTER_NOTE() is used like this:
CLUTTER_NOTE (DOMAIN, log-function);
where log function is g_printerr(), g_message(), g_warning(),
g_critical() or directly g_log() - for instance:
CLUTTER_NOTE (PANGO, g_warning ("Cache miss: %d", glyph));
will print the warning only if the "pango" flag has been
set to the CLUTTER_DEBUG envvar or passed to the --clutter-debug
command line argument.
similar to CLUTTER_SHOW_FPS, there's also the --clutter-show-fps
command line switch; also, the --display and --screen command
line switches have been added: the first overrides the DISPLAY
envvar and the second controls the X screen used by Clutter to
get the root window on the display.
* clutter/clutter-main.h:
* clutter/clutter-main.c: Add extended support for GOption
in Clutter; use clutter_init_with_args() to let Clutter
parse your own command line arguments; use instead
clutter_get_option_group() to get the GOptionGroup used by
Clutter if you want to do the parsing yourself with
g_option_context_parse(). The init sequence has been verified,
updated and moved into common functions where possible.
* clutter/pango/pangoclutter-render.c:
* clutter/*.c: Include "clutter-debug.h" where needed; use
CLUTTER_NOTE() instead of CLUTTER_DBG().
* examples/super-oh.c: Use the new clutter_init_with_args()
function, and add a --num-hands command line switch to
the SuperOH example code controlling the number of hands at
runtime.
2006-11-21 21:27:53 +00:00
|
|
|
#include "clutter-feature.h"
|
|
|
|
#include "clutter-main.h"
|
|
|
|
#include "clutter-private.h"
|
|
|
|
#include "clutter-debug.h"
|
2006-11-15 21:19:01 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
#include "cogl/cogl.h"
|
2006-11-15 21:19:01 +00:00
|
|
|
|
|
|
|
typedef struct ClutterFeatures
|
|
|
|
{
|
|
|
|
ClutterFeatureFlags flags;
|
2006-12-04 19:19:53 +00:00
|
|
|
guint features_set : 1;
|
2006-11-15 21:19:01 +00:00
|
|
|
} ClutterFeatures;
|
|
|
|
|
|
|
|
static ClutterFeatures* __features = NULL;
|
|
|
|
|
2012-03-07 12:34:06 +00:00
|
|
|
static ClutterFeatureFlags
|
|
|
|
clutter_features_from_cogl (guint cogl_flags)
|
2008-04-25 13:37:36 +00:00
|
|
|
{
|
|
|
|
ClutterFeatureFlags clutter_flags = 0;
|
|
|
|
|
|
|
|
if (cogl_flags & COGL_FEATURE_TEXTURE_NPOT)
|
|
|
|
clutter_flags |= CLUTTER_FEATURE_TEXTURE_NPOT;
|
|
|
|
|
|
|
|
if (cogl_flags & COGL_FEATURE_TEXTURE_YUV)
|
|
|
|
clutter_flags |= CLUTTER_FEATURE_TEXTURE_YUV;
|
|
|
|
|
|
|
|
if (cogl_flags & COGL_FEATURE_TEXTURE_READ_PIXELS)
|
|
|
|
clutter_flags |= CLUTTER_FEATURE_TEXTURE_READ_PIXELS;
|
|
|
|
|
|
|
|
if (cogl_flags & COGL_FEATURE_SHADERS_GLSL)
|
|
|
|
clutter_flags |= CLUTTER_FEATURE_SHADERS_GLSL;
|
|
|
|
|
|
|
|
if (cogl_flags & COGL_FEATURE_OFFSCREEN)
|
|
|
|
clutter_flags |= CLUTTER_FEATURE_OFFSCREEN;
|
|
|
|
|
|
|
|
return clutter_flags;
|
|
|
|
}
|
|
|
|
|
2010-03-17 17:28:20 +00:00
|
|
|
gboolean
|
|
|
|
_clutter_feature_init (GError **error)
|
2006-07-24 21:15:19 +00:00
|
|
|
{
|
2007-05-16 09:08:30 +00:00
|
|
|
ClutterMainContext *context;
|
2007-10-12 08:17:00 +00:00
|
|
|
|
2006-12-04 19:19:53 +00:00
|
|
|
CLUTTER_NOTE (MISC, "checking features");
|
2006-11-15 21:19:01 +00:00
|
|
|
|
2006-12-04 19:19:53 +00:00
|
|
|
if (!__features)
|
2006-07-27 17:10:33 +00:00
|
|
|
{
|
2006-12-04 19:19:53 +00:00
|
|
|
CLUTTER_NOTE (MISC, "allocating features data");
|
|
|
|
__features = g_new0 (ClutterFeatures, 1);
|
|
|
|
__features->features_set = FALSE; /* don't rely on zero-ing */
|
2006-07-27 17:10:33 +00:00
|
|
|
}
|
2006-07-24 21:15:19 +00:00
|
|
|
|
2006-12-04 19:19:53 +00:00
|
|
|
if (__features->features_set)
|
2010-03-17 17:28:20 +00:00
|
|
|
return TRUE;
|
2006-11-15 21:19:01 +00:00
|
|
|
|
2009-06-17 16:59:54 +00:00
|
|
|
context = _clutter_context_get_default ();
|
2006-11-15 21:19:01 +00:00
|
|
|
|
2009-12-03 20:48:55 +00:00
|
|
|
/* makes sure we have a GL context; if we have, this is a no-op */
|
2010-03-17 17:28:20 +00:00
|
|
|
if (!_clutter_backend_create_context (context->backend, error))
|
|
|
|
return FALSE;
|
2009-12-03 20:48:55 +00:00
|
|
|
|
2012-03-07 12:34:06 +00:00
|
|
|
__features->flags = (clutter_features_from_cogl (cogl_get_features ())
|
2009-06-17 16:59:54 +00:00
|
|
|
| _clutter_backend_get_features (context->backend));
|
2006-12-04 19:19:53 +00:00
|
|
|
|
|
|
|
__features->features_set = TRUE;
|
|
|
|
|
2007-05-16 09:08:30 +00:00
|
|
|
CLUTTER_NOTE (MISC, "features checked");
|
2010-03-17 17:28:20 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2006-07-27 16:09:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_feature_available:
|
|
|
|
* @feature: a #ClutterFeatureFlags
|
|
|
|
*
|
|
|
|
* Checks whether @feature is available. @feature can be a logical
|
|
|
|
* OR of #ClutterFeatureFlags.
|
2007-10-12 08:17:00 +00:00
|
|
|
*
|
2006-07-27 16:09:25 +00:00
|
|
|
* Return value: %TRUE if a feature is available
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
*
|
2006-07-27 16:09:25 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
clutter_feature_available (ClutterFeatureFlags feature)
|
|
|
|
{
|
2007-05-16 15:00:41 +00:00
|
|
|
if (G_UNLIKELY (!__features))
|
2010-03-18 14:15:33 +00:00
|
|
|
{
|
|
|
|
g_critical ("Unable to check features. Have you initialized Clutter?");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-05-16 15:00:41 +00:00
|
|
|
|
|
|
|
return (__features->flags & feature);
|
2006-07-27 16:09:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2006-11-15 23:37:53 +00:00
|
|
|
* clutter_feature_get_all:
|
2006-07-27 16:09:25 +00:00
|
|
|
*
|
2006-12-04 19:19:53 +00:00
|
|
|
* Returns all the supported features.
|
2006-07-27 16:09:25 +00:00
|
|
|
*
|
|
|
|
* Return value: a logical OR of all the supported features.
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
*
|
2006-07-27 16:09:25 +00:00
|
|
|
*/
|
|
|
|
ClutterFeatureFlags
|
2006-11-15 23:37:53 +00:00
|
|
|
clutter_feature_get_all (void)
|
2006-07-27 16:09:25 +00:00
|
|
|
{
|
2010-03-18 14:15:33 +00:00
|
|
|
if (G_UNLIKELY (!__features))
|
|
|
|
{
|
|
|
|
g_critical ("Unable to check features. Have you initialized Clutter?");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-11-15 21:19:01 +00:00
|
|
|
return __features->flags;
|
|
|
|
}
|
|
|
|
|