2009-11-17 13:52:40 +00:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
|
|
|
* An object oriented GL/GLES Abstraction/Utility Layer
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Intel Corporation.
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*
|
|
|
|
*
|
2009-11-17 13:52:40 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "cogl.h"
|
|
|
|
#include "cogl-context.h"
|
|
|
|
|
|
|
|
#include "cogl-feature-private.h"
|
|
|
|
|
|
|
|
gboolean
|
2010-06-02 16:55:56 +00:00
|
|
|
_cogl_feature_check (const char *driver_prefix,
|
|
|
|
const CoglFeatureData *data,
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-10 01:57:32 +00:00
|
|
|
unsigned int gl_major,
|
|
|
|
unsigned int gl_minor,
|
|
|
|
const char *extensions_string)
|
2009-11-17 13:52:40 +00:00
|
|
|
|
|
|
|
{
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-10 01:57:32 +00:00
|
|
|
const char *suffix = NULL;
|
2009-11-17 13:52:40 +00:00
|
|
|
int func_num;
|
|
|
|
|
|
|
|
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
|
|
|
|
|
|
/* First check whether the functions should be directly provided by
|
|
|
|
GL */
|
|
|
|
if (COGL_CHECK_GL_VERSION (gl_major, gl_minor,
|
|
|
|
data->min_gl_major, data->min_gl_minor))
|
|
|
|
suffix = "";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Otherwise try all of the extensions */
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-10 01:57:32 +00:00
|
|
|
const char *namespace, *namespace_suffix;
|
|
|
|
unsigned int namespace_len;
|
2009-11-17 13:52:40 +00:00
|
|
|
|
|
|
|
for (namespace = data->namespaces;
|
|
|
|
*namespace;
|
|
|
|
namespace += strlen (namespace) + 1)
|
|
|
|
{
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-10 01:57:32 +00:00
|
|
|
const char *extension;
|
2009-11-17 13:52:40 +00:00
|
|
|
GString *full_extension_name = g_string_new ("");
|
|
|
|
|
|
|
|
/* If the namespace part contains a ':' then the suffix for
|
|
|
|
the function names is different from the name space */
|
|
|
|
if ((namespace_suffix = strchr (namespace, ':')))
|
|
|
|
{
|
|
|
|
namespace_len = namespace_suffix - namespace;
|
|
|
|
namespace_suffix++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
namespace_len = strlen (namespace);
|
|
|
|
namespace_suffix = namespace;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (extension = data->extension_names;
|
|
|
|
*extension;
|
|
|
|
extension += strlen (extension) + 1)
|
|
|
|
{
|
2010-06-02 16:55:56 +00:00
|
|
|
g_string_assign (full_extension_name, driver_prefix);
|
|
|
|
g_string_append_c (full_extension_name, '_');
|
2009-11-17 13:52:40 +00:00
|
|
|
g_string_append_len (full_extension_name,
|
|
|
|
namespace, namespace_len);
|
|
|
|
g_string_append_c (full_extension_name, '_');
|
|
|
|
g_string_append (full_extension_name, extension);
|
2010-02-05 16:32:19 +00:00
|
|
|
if (!_cogl_check_extension (full_extension_name->str,
|
|
|
|
extensions_string))
|
2009-11-17 13:52:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_string_free (full_extension_name, TRUE);
|
|
|
|
|
|
|
|
/* If we found all of the extensions with this namespace
|
|
|
|
then use it as the suffix */
|
|
|
|
if (*extension == '\0')
|
|
|
|
{
|
|
|
|
suffix = namespace_suffix;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we couldn't find anything that provides the functions then
|
|
|
|
give up */
|
|
|
|
if (suffix == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Try to get all of the entry points */
|
|
|
|
for (func_num = 0; data->functions[func_num].name; func_num++)
|
|
|
|
{
|
|
|
|
void *func;
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-10 01:57:32 +00:00
|
|
|
char *full_function_name;
|
2009-11-17 13:52:40 +00:00
|
|
|
|
|
|
|
full_function_name = g_strconcat (data->functions[func_num].name,
|
|
|
|
suffix, NULL);
|
|
|
|
func = cogl_get_proc_address (full_function_name);
|
|
|
|
g_free (full_function_name);
|
|
|
|
|
|
|
|
if (func == NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Set the function pointer in the context */
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-10 01:57:32 +00:00
|
|
|
*(void **) ((guint8 *) ctx +
|
2009-11-17 13:52:40 +00:00
|
|
|
data->functions[func_num].pointer_offset) = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If one of the functions wasn't found then we should set all of
|
|
|
|
the function pointers back to NULL so that the rest of Cogl can
|
|
|
|
safely do feature testing by just looking at the function
|
|
|
|
pointers */
|
|
|
|
if (data->functions[func_num].name)
|
|
|
|
{
|
|
|
|
while (func_num-- > 0)
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-10 01:57:32 +00:00
|
|
|
*(void **) ((guint8 *) ctx +
|
2009-11-17 13:52:40 +00:00
|
|
|
data->functions[func_num].pointer_offset) = NULL;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return TRUE;
|
|
|
|
}
|