2006-07-24 17:15:19 -04: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 07:56:10 -05:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
2006-07-24 17:15:19 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:clutter-feature
|
2010-01-15 12:06:56 -05:00
|
|
|
* @short_description: Run-time detection of Clutter features
|
2006-07-24 17:15:19 -04:00
|
|
|
*
|
2010-01-15 12:06:56 -05: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 17:15:19 -04:00
|
|
|
*/
|
|
|
|
|
2007-10-12 04:17:00 -04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2006-07-24 17:15:19 -04:00
|
|
|
#include "config.h"
|
2007-10-12 04:17:00 -04:00
|
|
|
#endif
|
2006-07-24 17:15:19 -04:00
|
|
|
|
2006-11-15 16:19:01 -05: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 16:27:53 -05:00
|
|
|
|
2010-10-21 06:49:37 -04: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 16:27:53 -05:00
|
|
|
#include "clutter-feature.h"
|
|
|
|
#include "clutter-main.h"
|
|
|
|
#include "clutter-private.h"
|
|
|
|
#include "clutter-debug.h"
|
2006-11-15 16:19:01 -05:00
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
#include "cogl/cogl.h"
|
2006-11-15 16:19:01 -05:00
|
|
|
|
|
|
|
typedef struct ClutterFeatures
|
|
|
|
{
|
|
|
|
ClutterFeatureFlags flags;
|
2006-12-04 14:19:53 -05:00
|
|
|
guint features_set : 1;
|
2006-11-15 16:19:01 -05:00
|
|
|
} ClutterFeatures;
|
|
|
|
|
|
|
|
static ClutterFeatures* __features = NULL;
|
|
|
|
|
2012-03-07 07:34:06 -05:00
|
|
|
static ClutterFeatureFlags
|
|
|
|
clutter_features_from_cogl (guint cogl_flags)
|
2008-04-25 09:37:36 -04: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 13:28:20 -04:00
|
|
|
gboolean
|
|
|
|
_clutter_feature_init (GError **error)
|
2006-07-24 17:15:19 -04:00
|
|
|
{
|
2007-05-16 05:08:30 -04:00
|
|
|
ClutterMainContext *context;
|
2007-10-12 04:17:00 -04:00
|
|
|
|
2006-12-04 14:19:53 -05:00
|
|
|
CLUTTER_NOTE (MISC, "checking features");
|
2006-11-15 16:19:01 -05:00
|
|
|
|
2006-12-04 14:19:53 -05:00
|
|
|
if (!__features)
|
2006-07-27 13:10:33 -04:00
|
|
|
{
|
2006-12-04 14:19:53 -05: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 13:10:33 -04:00
|
|
|
}
|
2006-07-24 17:15:19 -04:00
|
|
|
|
2006-12-04 14:19:53 -05:00
|
|
|
if (__features->features_set)
|
2010-03-17 13:28:20 -04:00
|
|
|
return TRUE;
|
2006-11-15 16:19:01 -05:00
|
|
|
|
2009-06-17 12:59:54 -04:00
|
|
|
context = _clutter_context_get_default ();
|
2006-11-15 16:19:01 -05:00
|
|
|
|
2009-12-03 15:48:55 -05:00
|
|
|
/* makes sure we have a GL context; if we have, this is a no-op */
|
2010-03-17 13:28:20 -04:00
|
|
|
if (!_clutter_backend_create_context (context->backend, error))
|
|
|
|
return FALSE;
|
2009-12-03 15:48:55 -05:00
|
|
|
|
2012-03-07 07:34:06 -05:00
|
|
|
__features->flags = (clutter_features_from_cogl (cogl_get_features ())
|
2009-06-17 12:59:54 -04:00
|
|
|
| _clutter_backend_get_features (context->backend));
|
2006-12-04 14:19:53 -05:00
|
|
|
|
|
|
|
__features->features_set = TRUE;
|
|
|
|
|
2007-05-16 05:08:30 -04:00
|
|
|
CLUTTER_NOTE (MISC, "features checked");
|
2010-03-17 13:28:20 -04:00
|
|
|
|
|
|
|
return TRUE;
|
2006-07-27 12:09:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_feature_available:
|
|
|
|
* @feature: a #ClutterFeatureFlags
|
|
|
|
*
|
|
|
|
* Checks whether @feature is available. @feature can be a logical
|
|
|
|
* OR of #ClutterFeatureFlags.
|
2007-10-12 04:17:00 -04:00
|
|
|
*
|
2006-07-27 12:09:25 -04:00
|
|
|
* Return value: %TRUE if a feature is available
|
|
|
|
*
|
2015-03-03 10:53:04 -05:00
|
|
|
* Since: 0.2
|
2006-07-27 12:09:25 -04:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
clutter_feature_available (ClutterFeatureFlags feature)
|
|
|
|
{
|
2007-05-16 11:00:41 -04:00
|
|
|
if (G_UNLIKELY (!__features))
|
2010-03-18 10:15:33 -04:00
|
|
|
{
|
|
|
|
g_critical ("Unable to check features. Have you initialized Clutter?");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-05-16 11:00:41 -04:00
|
|
|
|
|
|
|
return (__features->flags & feature);
|
2006-07-27 12:09:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2006-11-15 18:37:53 -05:00
|
|
|
* clutter_feature_get_all:
|
2006-07-27 12:09:25 -04:00
|
|
|
*
|
2006-12-04 14:19:53 -05:00
|
|
|
* Returns all the supported features.
|
2006-07-27 12:09:25 -04:00
|
|
|
*
|
|
|
|
* Return value: a logical OR of all the supported features.
|
|
|
|
*
|
2015-03-03 10:53:04 -05:00
|
|
|
* Since: 0.2
|
2006-07-27 12:09:25 -04:00
|
|
|
*/
|
|
|
|
ClutterFeatureFlags
|
2006-11-15 18:37:53 -05:00
|
|
|
clutter_feature_get_all (void)
|
2006-07-27 12:09:25 -04:00
|
|
|
{
|
2010-03-18 10:15:33 -04:00
|
|
|
if (G_UNLIKELY (!__features))
|
|
|
|
{
|
|
|
|
g_critical ("Unable to check features. Have you initialized Clutter?");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-11-15 16:19:01 -05:00
|
|
|
return __features->flags;
|
|
|
|
}
|
|
|
|
|