Shaders not compiling with GLES2 on Android

I am trying to get SDL2 working with OpenGL ES 2.0 shading support for my Android device. I already have working code using GLES 1.1 (no shaders) with SDL as well as GLES2 with an EGL context taken from the android ndk samples. The code I’m working on is basically an SDL2 port of the ndk sample, and it works well with GLES2 when compiled as a Linux build, but not on my device when compiled for the android-16 api.

The app seems to be exiting after failing to compile a vertex shader in the createShader() function of this code section (added comments):

static const char VERTEX_SHADER[] =
"#version 100\n"
“uniform mat2 scaleRot;\n”
“uniform vec2 offset;\n”
“attribute vec2 pos;\n”
“attribute vec4 color;\n”
“varying vec4 vColor;\n”
“void main() {\n”
" gl_Position = vec4(scaleRot*pos + offset, 0.0, 1.0);\n"
" vColor = color;\n"

static const char FRAGMENT_SHADER[] =
"#version 100\n"
“precision mediump float;\n”
“varying vec4 vColor;\n”
“void main() {\n”
" gl_FragColor = vColor;\n"

GLuint createShader(GLenum shaderType, const char* src) {
GLuint shader = glCreateShader(shaderType);
if (!shader) {
return 0;
glShaderSource(shader, 1, &src, NULL);

GLint compiled = GL_FALSE;

// HERE compile fails for first shader source input

glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
if (!compiled) {
    GLint infoLogLen = 0;
    glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLen);

    // HERE infoLogLen == 0
    // skip following block

    if (infoLogLen > 0) {

    return 0;
return shader;


So it looks like there’s a compile error, but no log entered for it. glGetError returns GL_NO_ERROR before program exit.

Does anyone know what I’m doing wrong here? Let me know if more information is needed.