From 03d33a6f4ddde77371e320122884911e8577316c Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Tue, 7 Dec 2010 13:44:45 +0000 Subject: [PATCH] cogl-shader-boilerplate: Add the 3D texture extension on GLES2 To use the 3D texture extension on GLES2 it has to be enabled with the following line in GLSL: #extension GL_OES_texture_3D : enable --- cogl/cogl-shader.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cogl/cogl-shader.c b/cogl/cogl-shader.c index 530e293c7..927976a6d 100644 --- a/cogl/cogl-shader.c +++ b/cogl/cogl-shader.c @@ -196,8 +196,8 @@ _cogl_shader_set_source_with_boilerplate (GLuint shader_gl_handle, static const char vertex_boilerplate[] = _COGL_VERTEX_SHADER_BOILERPLATE; static const char fragment_boilerplate[] = _COGL_FRAGMENT_SHADER_BOILERPLATE; - const char **strings = g_alloca (sizeof (char *) * (count_in + 2)); - GLint *lengths = g_alloca (sizeof (GLint) * (count_in + 2)); + const char **strings = g_alloca (sizeof (char *) * (count_in + 3)); + GLint *lengths = g_alloca (sizeof (GLint) * (count_in + 3)); int count = 0; #ifdef HAVE_COGL_GLES2 char *tex_coord_declarations = NULL; @@ -205,6 +205,16 @@ _cogl_shader_set_source_with_boilerplate (GLuint shader_gl_handle, GET_CONTEXT (ctx, NO_RETVAL); +#ifdef HAVE_COGL_GLES2 + if (cogl_features_available (COGL_FEATURE_TEXTURE_3D)) + { + static const char texture_3d_extension[] = + "#extension GL_OES_texture_3D : enable\n"; + strings[count] = texture_3d_extension; + lengths[count++] = sizeof (texture_3d_extension) - 1; + } +#endif + if (shader_gl_type == GL_VERTEX_SHADER) { strings[count] = vertex_boilerplate;