2008-06-02 10:58:57 +00:00
|
|
|
/*
|
2009-04-27 14:48:12 +00:00
|
|
|
* Cogl
|
2008-06-02 10:58:57 +00:00
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* A Low Level GPU Graphics and Utilities API
|
2008-06-02 10:58:57 +00:00
|
|
|
*
|
2010-08-02 20:40:55 +00:00
|
|
|
* Copyright (C) 2007,2008,2009,2010 Intel Corporation.
|
2008-06-02 10:58:57 +00:00
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
* restriction, including without limitation the rights to use, copy,
|
|
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
* of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2008-06-02 10:58:57 +00:00
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
2008-06-02 10:58:57 +00:00
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
2010-03-01 12:56:10 +00:00
|
|
|
*
|
|
|
|
*
|
2008-06-02 10:58:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2008-10-30 17:25:00 +00:00
|
|
|
#include "cogl-shader-private.h"
|
2013-01-20 18:47:40 +00:00
|
|
|
#include "cogl-util-gl-private.h"
|
2010-11-04 22:25:52 +00:00
|
|
|
#include "cogl-context-private.h"
|
2012-04-16 13:14:10 +00:00
|
|
|
#include "cogl-object-private.h"
|
2013-01-07 19:16:11 +00:00
|
|
|
#include "cogl-glsl-shader-private.h"
|
|
|
|
#include "cogl-glsl-shader-boilerplate.h"
|
2008-06-02 10:58:57 +00:00
|
|
|
|
2010-08-02 20:40:55 +00:00
|
|
|
#include <glib.h>
|
|
|
|
|
2010-08-04 16:53:51 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2008-06-02 10:58:57 +00:00
|
|
|
static void _cogl_shader_free (CoglShader *shader);
|
|
|
|
|
2009-04-01 16:16:44 +00:00
|
|
|
COGL_HANDLE_DEFINE (Shader, shader);
|
2010-07-09 16:59:16 +00:00
|
|
|
COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING (shader);
|
2008-06-02 10:58:57 +00:00
|
|
|
|
2011-07-07 19:44:56 +00:00
|
|
|
#ifndef GL_FRAGMENT_SHADER
|
|
|
|
#define GL_FRAGMENT_SHADER 0x8B30
|
|
|
|
#endif
|
|
|
|
#ifndef GL_VERTEX_SHADER
|
|
|
|
#define GL_VERTEX_SHADER 0x8B31
|
|
|
|
#endif
|
|
|
|
|
2008-06-02 10:58:57 +00:00
|
|
|
static void
|
|
|
|
_cogl_shader_free (CoglShader *shader)
|
|
|
|
{
|
|
|
|
/* Frees shader resources but its handle is not
|
|
|
|
released! Do that separately before this! */
|
|
|
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
2010-08-04 16:53:51 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_COGL_GL
|
|
|
|
if (shader->language == COGL_SHADER_LANGUAGE_ARBFP)
|
2010-10-15 17:00:29 +00:00
|
|
|
{
|
|
|
|
if (shader->gl_handle)
|
2011-07-06 20:51:00 +00:00
|
|
|
GE (ctx, glDeletePrograms (1, &shader->gl_handle));
|
2010-10-15 17:00:29 +00:00
|
|
|
}
|
2010-08-04 16:53:51 +00:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (shader->gl_handle)
|
2011-07-06 20:51:00 +00:00
|
|
|
GE (ctx, glDeleteShader (shader->gl_handle));
|
2010-07-22 15:58:23 +00:00
|
|
|
|
|
|
|
g_slice_free (CoglShader, shader);
|
2008-06-02 10:58:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CoglHandle
|
2009-05-12 13:15:18 +00:00
|
|
|
cogl_create_shader (CoglShaderType type)
|
2008-06-02 10:58:57 +00:00
|
|
|
{
|
|
|
|
CoglShader *shader;
|
2009-05-12 13:15:18 +00:00
|
|
|
|
2011-07-06 20:51:00 +00:00
|
|
|
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
2010-08-02 20:40:55 +00:00
|
|
|
|
2010-08-04 16:53:51 +00:00
|
|
|
switch (type)
|
2009-05-12 13:15:18 +00:00
|
|
|
{
|
2010-08-04 16:53:51 +00:00
|
|
|
case COGL_SHADER_TYPE_VERTEX:
|
|
|
|
case COGL_SHADER_TYPE_FRAGMENT:
|
|
|
|
break;
|
|
|
|
default:
|
2009-05-12 13:15:18 +00:00
|
|
|
g_warning ("Unexpected shader type (0x%08lX) given to "
|
|
|
|
"cogl_create_shader", (unsigned long) type);
|
|
|
|
return COGL_INVALID_HANDLE;
|
|
|
|
}
|
2008-06-02 10:58:57 +00:00
|
|
|
|
|
|
|
shader = g_slice_new (CoglShader);
|
2010-08-04 16:53:51 +00:00
|
|
|
shader->language = COGL_SHADER_LANGUAGE_GLSL;
|
|
|
|
shader->gl_handle = 0;
|
2013-01-19 16:00:33 +00:00
|
|
|
shader->compilation_pipeline = NULL;
|
2010-07-14 18:39:24 +00:00
|
|
|
shader->type = type;
|
2008-06-02 10:58:57 +00:00
|
|
|
|
|
|
|
return _cogl_shader_handle_new (shader);
|
|
|
|
}
|
|
|
|
|
2010-12-02 21:08:30 +00:00
|
|
|
static void
|
|
|
|
delete_shader (CoglShader *shader)
|
|
|
|
{
|
|
|
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
|
|
|
|
|
|
#ifdef HAVE_COGL_GL
|
|
|
|
if (shader->language == COGL_SHADER_LANGUAGE_ARBFP)
|
|
|
|
{
|
|
|
|
if (shader->gl_handle)
|
2011-07-06 20:51:00 +00:00
|
|
|
GE (ctx, glDeletePrograms (1, &shader->gl_handle));
|
2010-12-02 21:08:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
if (shader->gl_handle)
|
2011-07-06 20:51:00 +00:00
|
|
|
GE (ctx, glDeleteShader (shader->gl_handle));
|
2010-12-02 21:08:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
shader->gl_handle = 0;
|
2013-01-19 16:00:33 +00:00
|
|
|
|
|
|
|
if (shader->compilation_pipeline)
|
|
|
|
{
|
|
|
|
cogl_object_unref (shader->compilation_pipeline);
|
|
|
|
shader->compilation_pipeline = NULL;
|
|
|
|
}
|
2010-12-02 21:08:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
cogl_shader_source (CoglHandle handle,
|
|
|
|
const char *source)
|
|
|
|
{
|
|
|
|
CoglShader *shader;
|
|
|
|
CoglShaderLanguage language;
|
|
|
|
|
|
|
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
|
|
|
|
|
|
if (!cogl_is_shader (handle))
|
|
|
|
return;
|
|
|
|
|
2012-03-06 18:21:28 +00:00
|
|
|
shader = handle;
|
2010-12-02 21:08:30 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_COGL_GL
|
|
|
|
if (strncmp (source, "!!ARBfp1.0", 10) == 0)
|
|
|
|
language = COGL_SHADER_LANGUAGE_ARBFP;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
language = COGL_SHADER_LANGUAGE_GLSL;
|
|
|
|
|
|
|
|
/* Delete the old object if the language is changing... */
|
|
|
|
if (G_UNLIKELY (language != shader->language) &&
|
|
|
|
shader->gl_handle)
|
|
|
|
delete_shader (shader);
|
|
|
|
|
|
|
|
shader->source = g_strdup (source);
|
|
|
|
|
|
|
|
shader->language = language;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
cogl_shader_compile (CoglHandle handle)
|
|
|
|
{
|
2013-01-19 16:00:33 +00:00
|
|
|
CoglShader *shader;
|
|
|
|
|
2011-07-07 19:44:56 +00:00
|
|
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
2010-12-02 21:08:30 +00:00
|
|
|
|
|
|
|
if (!cogl_is_shader (handle))
|
|
|
|
return;
|
|
|
|
|
2013-01-19 16:00:33 +00:00
|
|
|
#ifdef HAVE_COGL_GL
|
|
|
|
shader = handle;
|
|
|
|
if (shader->language == COGL_SHADER_LANGUAGE_ARBFP)
|
|
|
|
_cogl_shader_compile_real (handle, NULL);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* XXX: For GLSL we don't actually compile anything until the shader
|
|
|
|
* gets used so we have an opportunity to add some boilerplate to
|
|
|
|
* the shader.
|
2010-12-02 21:08:30 +00:00
|
|
|
*
|
|
|
|
* At the end of the day this is obviously a badly designed API
|
|
|
|
* given that we are having to lie to the user. It was a mistake to
|
|
|
|
* so thinly wrap the OpenGL shader API and the current plan is to
|
|
|
|
* replace it with a pipeline snippets API. */
|
|
|
|
}
|
|
|
|
|
2010-07-23 16:46:41 +00:00
|
|
|
void
|
2010-12-02 21:08:30 +00:00
|
|
|
_cogl_shader_compile_real (CoglHandle handle,
|
2013-01-19 16:00:33 +00:00
|
|
|
CoglPipeline *pipeline)
|
2010-07-23 16:46:41 +00:00
|
|
|
{
|
2010-12-02 21:08:30 +00:00
|
|
|
CoglShader *shader = handle;
|
2010-07-23 16:46:41 +00:00
|
|
|
|
|
|
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
2010-08-04 16:53:51 +00:00
|
|
|
|
2010-12-02 12:27:29 +00:00
|
|
|
#ifdef HAVE_COGL_GL
|
2010-12-02 21:08:30 +00:00
|
|
|
if (shader->language == COGL_SHADER_LANGUAGE_ARBFP)
|
2010-10-15 17:00:29 +00:00
|
|
|
{
|
|
|
|
#ifdef COGL_GL_DEBUG
|
|
|
|
GLenum gl_error;
|
|
|
|
#endif
|
|
|
|
|
2010-12-02 21:08:30 +00:00
|
|
|
if (shader->gl_handle)
|
|
|
|
return;
|
|
|
|
|
2011-07-06 20:51:00 +00:00
|
|
|
GE (ctx, glGenPrograms (1, &shader->gl_handle));
|
2010-10-15 17:00:29 +00:00
|
|
|
|
2011-07-06 20:51:00 +00:00
|
|
|
GE (ctx, glBindProgram (GL_FRAGMENT_PROGRAM_ARB, shader->gl_handle));
|
2010-10-15 17:00:29 +00:00
|
|
|
|
2011-01-24 14:28:00 +00:00
|
|
|
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_SHOW_SOURCE)))
|
2010-12-02 22:19:44 +00:00
|
|
|
g_message ("user ARBfp program:\n%s", shader->source);
|
|
|
|
|
2010-10-15 17:00:29 +00:00
|
|
|
#ifdef COGL_GL_DEBUG
|
2011-07-06 20:51:00 +00:00
|
|
|
while ((gl_error = ctx->glGetError ()) != GL_NO_ERROR)
|
2010-10-15 17:00:29 +00:00
|
|
|
;
|
|
|
|
#endif
|
2011-07-06 20:51:00 +00:00
|
|
|
ctx->glProgramString (GL_FRAGMENT_PROGRAM_ARB,
|
|
|
|
GL_PROGRAM_FORMAT_ASCII_ARB,
|
|
|
|
strlen (shader->source),
|
|
|
|
shader->source);
|
2010-10-15 17:00:29 +00:00
|
|
|
#ifdef COGL_GL_DEBUG
|
2011-07-06 20:51:00 +00:00
|
|
|
gl_error = ctx->glGetError ();
|
2010-10-15 17:00:29 +00:00
|
|
|
if (gl_error != GL_NO_ERROR)
|
|
|
|
{
|
|
|
|
g_warning ("%s: GL error (%d): Failed to compile ARBfp:\n%s\n%s",
|
|
|
|
G_STRLOC,
|
|
|
|
gl_error,
|
2010-12-02 21:08:30 +00:00
|
|
|
shader->source,
|
2011-07-06 20:51:00 +00:00
|
|
|
ctx->glGetString (GL_PROGRAM_ERROR_STRING_ARB));
|
2010-10-15 17:00:29 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2010-08-04 16:53:51 +00:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2010-07-23 16:46:41 +00:00
|
|
|
GLenum gl_type;
|
2013-01-19 16:00:33 +00:00
|
|
|
GLint status;
|
2010-07-23 16:46:41 +00:00
|
|
|
|
2013-01-19 16:00:33 +00:00
|
|
|
if (shader->gl_handle)
|
|
|
|
{
|
|
|
|
CoglPipeline *prev = shader->compilation_pipeline;
|
|
|
|
|
|
|
|
/* XXX: currently the only things that will affect the
|
|
|
|
* boilerplate for user shaders, apart from driver features,
|
|
|
|
* are the pipeline layer-indices and texture-unit-indices
|
|
|
|
*/
|
|
|
|
if (pipeline == prev ||
|
|
|
|
_cogl_pipeline_layer_and_unit_numbers_equal (prev, pipeline))
|
|
|
|
return;
|
|
|
|
}
|
2010-12-02 21:08:30 +00:00
|
|
|
|
|
|
|
if (shader->gl_handle)
|
|
|
|
delete_shader (shader);
|
|
|
|
|
2010-07-23 16:46:41 +00:00
|
|
|
switch (shader->type)
|
2010-08-04 16:53:51 +00:00
|
|
|
{
|
2010-07-23 16:46:41 +00:00
|
|
|
case COGL_SHADER_TYPE_VERTEX:
|
|
|
|
gl_type = GL_VERTEX_SHADER;
|
|
|
|
break;
|
|
|
|
case COGL_SHADER_TYPE_FRAGMENT:
|
|
|
|
gl_type = GL_FRAGMENT_SHADER;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
2010-08-04 16:53:51 +00:00
|
|
|
}
|
|
|
|
|
2011-07-06 20:51:00 +00:00
|
|
|
shader->gl_handle = ctx->glCreateShader (gl_type);
|
2008-06-02 10:58:57 +00:00
|
|
|
|
2013-01-07 19:16:11 +00:00
|
|
|
_cogl_glsl_shader_set_source_with_boilerplate (ctx,
|
|
|
|
shader->gl_handle,
|
|
|
|
gl_type,
|
2013-01-19 16:00:33 +00:00
|
|
|
pipeline,
|
2013-01-07 19:16:11 +00:00
|
|
|
1,
|
|
|
|
(const char **)
|
|
|
|
&shader->source,
|
|
|
|
NULL);
|
2010-07-23 16:46:41 +00:00
|
|
|
|
2011-07-06 20:51:00 +00:00
|
|
|
GE (ctx, glCompileShader (shader->gl_handle));
|
2010-12-02 12:27:29 +00:00
|
|
|
|
2013-01-19 16:00:33 +00:00
|
|
|
shader->compilation_pipeline = cogl_object_ref (pipeline);
|
2010-12-02 12:27:29 +00:00
|
|
|
|
2013-01-19 16:00:33 +00:00
|
|
|
GE (ctx, glGetShaderiv (shader->gl_handle, GL_COMPILE_STATUS, &status));
|
|
|
|
if (!status)
|
2010-12-02 21:08:30 +00:00
|
|
|
{
|
2013-01-19 16:00:33 +00:00
|
|
|
char buffer[512];
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
ctx->glGetShaderInfoLog (shader->gl_handle, 511, &len, buffer);
|
|
|
|
buffer[len] = '\0';
|
|
|
|
|
|
|
|
g_warning ("Failed to compile GLSL program:\n"
|
|
|
|
"src:\n%s\n"
|
|
|
|
"error:\n%s\n",
|
2010-12-02 21:08:30 +00:00
|
|
|
shader->source,
|
2013-01-19 16:00:33 +00:00
|
|
|
buffer);
|
2010-12-02 21:08:30 +00:00
|
|
|
}
|
|
|
|
}
|
2008-06-02 10:58:57 +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
|
|
|
char *
|
2009-06-01 15:31:32 +00:00
|
|
|
cogl_shader_get_info_log (CoglHandle handle)
|
2008-06-02 10:58:57 +00:00
|
|
|
{
|
|
|
|
if (!cogl_is_shader (handle))
|
2009-06-01 15:31:32 +00:00
|
|
|
return NULL;
|
2008-06-02 10:58:57 +00:00
|
|
|
|
2013-01-19 16:00:33 +00:00
|
|
|
/* XXX: This API doesn't really do anything!
|
|
|
|
*
|
|
|
|
* This API is purely for compatibility
|
|
|
|
*
|
|
|
|
* The reason we don't do anything is because a shader needs to
|
|
|
|
* be associated with a CoglPipeline for Cogl to be able to
|
|
|
|
* compile and link anything.
|
|
|
|
*
|
|
|
|
* The way this API was originally designed as a very thin wrapper
|
|
|
|
* over the GL api was a mistake and it's now very difficult to
|
|
|
|
* make the API work in a meaningful way given how the rest of Cogl
|
|
|
|
* has evolved.
|
|
|
|
*
|
|
|
|
* The CoglShader API is mostly deprecated by CoglSnippets and so
|
|
|
|
* these days we do the bare minimum to support the existing users
|
|
|
|
* of it until they are able to migrate to the snippets api.
|
|
|
|
*/
|
2008-06-02 10:58:57 +00:00
|
|
|
|
2013-01-19 16:00:33 +00:00
|
|
|
return g_strdup ("");
|
2008-06-02 10:58:57 +00:00
|
|
|
}
|
|
|
|
|
2009-05-12 13:15:18 +00:00
|
|
|
CoglShaderType
|
|
|
|
cogl_shader_get_type (CoglHandle handle)
|
2008-06-02 10:58:57 +00:00
|
|
|
{
|
|
|
|
CoglShader *shader;
|
|
|
|
|
2011-07-06 20:51:00 +00:00
|
|
|
_COGL_GET_CONTEXT (ctx, COGL_SHADER_TYPE_VERTEX);
|
2010-08-02 20:40:55 +00:00
|
|
|
|
2008-06-02 10:58:57 +00:00
|
|
|
if (!cogl_is_shader (handle))
|
2009-05-12 13:15:18 +00:00
|
|
|
{
|
|
|
|
g_warning ("Non shader handle type passed to cogl_shader_get_type");
|
|
|
|
return COGL_SHADER_TYPE_VERTEX;
|
|
|
|
}
|
|
|
|
|
2012-03-06 18:21:28 +00:00
|
|
|
shader = handle;
|
2010-07-23 16:44:53 +00:00
|
|
|
return shader->type;
|
2009-05-12 13:15:18 +00:00
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 20:56:40 +00:00
|
|
|
CoglBool
|
2009-05-12 13:15:18 +00:00
|
|
|
cogl_shader_is_compiled (CoglHandle handle)
|
|
|
|
{
|
2011-07-07 19:44:56 +00:00
|
|
|
#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES2)
|
2009-05-12 13:15:18 +00:00
|
|
|
if (!cogl_is_shader (handle))
|
|
|
|
return FALSE;
|
2008-06-02 10:58:57 +00:00
|
|
|
|
2013-01-19 16:00:33 +00:00
|
|
|
/* XXX: This API doesn't really do anything!
|
|
|
|
*
|
|
|
|
* This API is purely for compatibility and blatantly lies to the
|
|
|
|
* user about whether their shader has been compiled.
|
|
|
|
*
|
|
|
|
* I suppose we could say we're stretching the definition of
|
|
|
|
* "compile" and are deferring any related errors to be "linker"
|
|
|
|
* errors.
|
|
|
|
*
|
|
|
|
* The reason we don't do anything is because a shader needs to
|
|
|
|
* be associated with a CoglPipeline for Cogl to be able to
|
|
|
|
* compile and link anything.
|
|
|
|
*
|
|
|
|
* The CoglShader API is mostly deprecated by CoglSnippets and so
|
|
|
|
* these days we do the bare minimum to support the existing users
|
|
|
|
* of it until they are able to migrate to the snippets api.
|
|
|
|
*/
|
2008-06-02 10:58:57 +00:00
|
|
|
|
2013-01-19 16:00:33 +00:00
|
|
|
return TRUE;
|
2010-12-02 21:08:30 +00:00
|
|
|
|
2011-07-07 19:44:56 +00:00
|
|
|
#else
|
|
|
|
return FALSE;
|
|
|
|
#endif
|
2011-01-17 12:21:33 +00:00
|
|
|
}
|