Fixed compiling source shaders
authorSam Lantinga <slouken@libsdl.org>
Sun, 06 Feb 2011 10:59:37 -0800
changeset 52127b6101f3ea58
parent 5211 fb058f09061d
child 5213 25ad4a50d34f
Fixed compiling source shaders
src/render/opengles2/SDL_render_gles2.c
     1.1 --- a/src/render/opengles2/SDL_render_gles2.c	Sun Feb 06 10:27:05 2011 -0800
     1.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Sun Feb 06 10:59:37 2011 -0800
     1.3 @@ -608,7 +608,7 @@
     1.4      entry->id = glCreateShader(instance->type);
     1.5      if (instance->format == (GLenum)-1)
     1.6      {
     1.7 -        glShaderSource(entry->id, 1, (const char **)&instance->data, &instance->length);
     1.8 +        glShaderSource(entry->id, 1, (const char **)&instance->data, NULL);
     1.9          glCompileShader(entry->id);
    1.10          glGetShaderiv(entry->id, GL_COMPILE_STATUS, &compileSuccessful);
    1.11      }
    1.12 @@ -619,7 +619,22 @@
    1.13      }
    1.14      if (glGetError() != GL_NO_ERROR || !compileSuccessful)
    1.15      {
    1.16 -        SDL_SetError("Failed to load the specified shader");
    1.17 +        char *info = NULL;
    1.18 +        int length;
    1.19 +
    1.20 +        glGetShaderiv(entry->id, GL_INFO_LOG_LENGTH, &length);
    1.21 +        if (length > 0) {
    1.22 +            info = SDL_stack_alloc(char, length);
    1.23 +            if (info) {
    1.24 +                glGetShaderInfoLog(entry->id, length, &length, info);
    1.25 +            }
    1.26 +        }
    1.27 +        if (info) {
    1.28 +            SDL_SetError("Failed to load the shader: %s", info);
    1.29 +            SDL_stack_free(info);
    1.30 +        } else {
    1.31 +            SDL_SetError("Failed to load the shader");
    1.32 +        }
    1.33          glDeleteShader(entry->id);
    1.34          SDL_free(entry);
    1.35          return NULL;