cogl-program: Don't use separate definitions on GLES 1.1

Previously most of the code for cogl-program and cogl-shader was
ifdef'd out for GLES 1.1 and alternate stub definitions were
defined. This patch removes those and instead puts #ifdef's directly
in the functions that need it. This should make it a little bit easier
to maintain.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2516
This commit is contained in:
Neil Roberts 2011-01-17 12:21:33 +00:00
parent b7677d047d
commit ae9781e526
2 changed files with 45 additions and 153 deletions

View File

@ -31,13 +31,11 @@
#include "cogl-context.h"
#include "cogl-handle.h"
#ifndef HAVE_COGL_GLES
#include <string.h>
#include "cogl-shader-private.h"
#include "cogl-program-private.h"
#include <string.h>
static void _cogl_program_free (CoglProgram *program);
COGL_HANDLE_DEFINE (Program, program);
@ -394,6 +392,8 @@ cogl_program_uniform_matrix (int uniform_no,
uniform_no, size, count, transpose, value);
}
#ifndef HAVE_COGL_GLES
/* ARBfp local parameters can be referenced like:
*
* "program.local[5]"
@ -501,6 +501,8 @@ _cogl_program_flush_uniform_glsl (GLint location,
}
}
#endif /* HAVE_COGL_GLES */
#ifdef HAVE_COGL_GL
static void
@ -527,6 +529,12 @@ _cogl_program_flush_uniforms (CoglProgram *program,
GLuint gl_program,
gboolean gl_program_changed)
{
#ifdef HAVE_COGL_GLES
g_return_if_reached ();
#else /* HAVE_COGL_GLES */
CoglProgramUniform *uniform;
int i;
@ -575,97 +583,10 @@ _cogl_program_flush_uniforms (CoglProgram *program,
uniform->dirty = FALSE;
}
}
#endif /* HAVE_COGL_GLES */
}
#else /* HAVE_COGL_GLES */
/* No support on regular OpenGL 1.1 */
CoglHandle
cogl_create_program (void)
{
return COGL_INVALID_HANDLE;
}
gboolean
cogl_is_program (CoglHandle handle)
{
return FALSE;
}
CoglHandle
cogl_program_ref (CoglHandle handle)
{
return COGL_INVALID_HANDLE;
}
void
cogl_program_unref (CoglHandle handle)
{
}
void
cogl_program_attach_shader (CoglHandle program_handle,
CoglHandle shader_handle)
{
}
void
cogl_program_link (CoglHandle program_handle)
{
}
void
cogl_program_use (CoglHandle program_handle)
{
}
int
cogl_program_get_uniform_location (CoglHandle program_handle,
const char *uniform_name)
{
return 0;
}
void
cogl_program_uniform_1f (int uniform_no,
float value)
{
}
void
cogl_program_uniform_1i (int uniform_no,
int value)
{
}
void
cogl_program_uniform_float (int uniform_no,
int size,
int count,
const GLfloat *value)
{
}
void
cogl_program_uniform_int (int uniform_no,
int size,
int count,
const int *value)
{
}
void
cogl_program_uniform_matrix (int uniform_no,
int size,
int count,
gboolean transpose,
const GLfloat *value)
{
}
#endif /* HAVE_COGL_GLES2 */
CoglShaderLanguage
_cogl_program_get_language (CoglHandle handle)
{

View File

@ -52,8 +52,6 @@
#define GET_CONTEXT(CTXVAR,RETVAL) G_STMT_START { } G_STMT_END
#endif
#ifndef HAVE_COGL_GLES
static void _cogl_shader_free (CoglShader *shader);
COGL_HANDLE_DEFINE (Shader, shader);
@ -62,6 +60,8 @@ COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING (shader);
static void
_cogl_shader_free (CoglShader *shader)
{
#ifndef HAVE_COGL_GLES
/* Frees shader resources but its handle is not
released! Do that separately before this! */
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -77,6 +77,8 @@ _cogl_shader_free (CoglShader *shader)
if (shader->gl_handle)
GE (glDeleteShader (shader->gl_handle));
#endif /* HAVE_COGL_GLES */
g_slice_free (CoglShader, shader);
}
@ -112,6 +114,8 @@ cogl_create_shader (CoglShaderType type)
static void
delete_shader (CoglShader *shader)
{
#ifndef HAVE_COGL_GLES
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
#ifdef HAVE_COGL_GL
@ -128,6 +132,8 @@ delete_shader (CoglShader *shader)
}
shader->gl_handle = 0;
#endif /* HAVE_COGL_GLES */
}
void
@ -193,6 +199,8 @@ _cogl_shader_set_source_with_boilerplate (GLuint shader_gl_handle,
const char **strings_in,
const GLint *lengths_in)
{
#ifndef HAVE_COGL_GLES
static const char vertex_boilerplate[] = _COGL_VERTEX_SHADER_BOILERPLATE;
static const char fragment_boilerplate[] = _COGL_FRAGMENT_SHADER_BOILERPLATE;
@ -293,12 +301,16 @@ _cogl_shader_set_source_with_boilerplate (GLuint shader_gl_handle,
#ifdef HAVE_COGL_GLES2
g_free (tex_coord_declarations);
#endif
#endif /* HAVE_COGL_GLES */
}
void
_cogl_shader_compile_real (CoglHandle handle,
int n_tex_coord_attribs)
{
#ifndef HAVE_COGL_GLES
CoglShader *shader = handle;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -393,11 +405,19 @@ _cogl_shader_compile_real (CoglHandle handle,
}
#endif
}
#endif /* HAVE_COGL_GLES */
}
char *
cogl_shader_get_info_log (CoglHandle handle)
{
#ifdef HAVE_COGL_GLES
return NULL;
#else /* HAVE_COGL_GLES */
CoglShader *shader;
GET_CONTEXT (ctx, NULL);
@ -439,6 +459,8 @@ cogl_shader_get_info_log (CoglHandle handle)
buffer[len] = '\0';
return g_strdup (buffer);
}
#endif /* HAVE_COGL_GLES */
}
CoglShaderType
@ -461,6 +483,12 @@ cogl_shader_get_type (CoglHandle handle)
gboolean
cogl_shader_is_compiled (CoglHandle handle)
{
#ifdef HAVE_COGL_GLES
return FALSE;
#else /* HAVE_COGL_GLES */
GLint status;
CoglShader *shader;
@ -501,63 +529,6 @@ cogl_shader_is_compiled (CoglHandle handle)
else
return FALSE;
}
}
#else /* HAVE_COGL_GLES */
/* No support on regular OpenGL 1.1 */
CoglHandle
cogl_create_shader (CoglShaderType type)
{
return COGL_INVALID_HANDLE;
}
gboolean
cogl_is_shader (CoglHandle handle)
{
return FALSE;
}
CoglHandle
cogl_shader_ref (CoglHandle handle)
{
return COGL_INVALID_HANDLE;
}
void
cogl_shader_unref (CoglHandle handle)
{
}
void
cogl_shader_source (CoglHandle shader,
const char *source)
{
}
void
cogl_shader_compile (CoglHandle shader_handle)
{
}
char *
cogl_shader_get_info_log (CoglHandle handle)
{
return NULL;
}
CoglShaderType
cogl_shader_get_type (CoglHandle handle)
{
return COGL_SHADER_TYPE_VERTEX;
}
gboolean
cogl_shader_is_compiled (CoglHandle handle)
{
return FALSE;
}
#endif /* HAVE_COGL_GLES */
}