Check the return value of glGenTextures()
authorSam Lantinga
Sat, 10 Aug 2013 10:49:26 -0700
changeset 7624ac9f3b12c42a
parent 7623 fe1b8a78de0b
child 7626 36e493277423
Check the return value of glGenTextures()
src/render/opengl/SDL_render_gl.c
src/render/opengles/SDL_render_gles.c
src/render/opengles2/SDL_render_gles2.c
     1.1 --- a/src/render/opengl/SDL_render_gl.c	Sat Aug 10 13:46:19 2013 -0400
     1.2 +++ b/src/render/opengl/SDL_render_gl.c	Sat Aug 10 10:49:26 2013 -0700
     1.3 @@ -633,6 +633,10 @@
     1.4  
     1.5      GL_CheckError("", renderer);
     1.6      renderdata->glGenTextures(1, &data->texture);
     1.7 +    if (GL_CheckError("glGenTexures()", renderer) < 0) {
     1.8 +        SDL_free(data);
     1.9 +        return -1;
    1.10 +    }
    1.11      if ((renderdata->GL_ARB_texture_rectangle_supported)
    1.12          /*&& texture->access != SDL_TEXTUREACCESS_TARGET*/){
    1.13          data->type = GL_TEXTURE_RECTANGLE_ARB;
     2.1 --- a/src/render/opengles/SDL_render_gles.c	Sat Aug 10 13:46:19 2013 -0400
     2.2 +++ b/src/render/opengles/SDL_render_gles.c	Sat Aug 10 10:49:26 2013 -0700
     2.3 @@ -475,6 +475,11 @@
     2.4      renderdata->glGetError();
     2.5      renderdata->glEnable(GL_TEXTURE_2D);
     2.6      renderdata->glGenTextures(1, &data->texture);
     2.7 +    result = renderdata->glGetError();
     2.8 +    if (result != GL_NO_ERROR) {
     2.9 +        SDL_free(data);
    2.10 +        return GLES_SetError("glGenTextures()", result);
    2.11 +    }
    2.12  
    2.13      data->type = GL_TEXTURE_2D;
    2.14      /* no NPOV textures allowed in OpenGL ES (yet) */
     3.1 --- a/src/render/opengles2/SDL_render_gles2.c	Sat Aug 10 13:46:19 2013 -0400
     3.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Sat Aug 10 10:49:26 2013 -0700
     3.3 @@ -418,6 +418,10 @@
     3.4      /* Allocate the texture */
     3.5      rdata->glGetError();
     3.6      rdata->glGenTextures(1, &tdata->texture);
     3.7 +    if (rdata->glGetError() != GL_NO_ERROR) {
     3.8 +        SDL_free(tdata);
     3.9 +        return SDL_SetError("Texture creation failed in glGenTextures()");
    3.10 +    }
    3.11      rdata->glActiveTexture(GL_TEXTURE0);
    3.12      rdata->glBindTexture(tdata->texture_type, tdata->texture);
    3.13      rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode);
    3.14 @@ -425,8 +429,7 @@
    3.15      rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    3.16      rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    3.17      rdata->glTexImage2D(tdata->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL);
    3.18 -    if (rdata->glGetError() != GL_NO_ERROR)
    3.19 -    {
    3.20 +    if (rdata->glGetError() != GL_NO_ERROR) {
    3.21          rdata->glDeleteTextures(1, &tdata->texture);
    3.22          SDL_free(tdata);
    3.23          return SDL_SetError("Texture creation failed");