Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Check the return value of glGenTextures()
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Aug 10, 2013
1 parent be730de commit 2a36e61
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/render/opengl/SDL_render_gl.c
Expand Up @@ -633,6 +633,10 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)

GL_CheckError("", renderer);
renderdata->glGenTextures(1, &data->texture);
if (GL_CheckError("glGenTexures()", renderer) < 0) {
SDL_free(data);
return -1;
}
if ((renderdata->GL_ARB_texture_rectangle_supported)
/*&& texture->access != SDL_TEXTUREACCESS_TARGET*/){
data->type = GL_TEXTURE_RECTANGLE_ARB;
Expand Down
5 changes: 5 additions & 0 deletions src/render/opengles/SDL_render_gles.c
Expand Up @@ -475,6 +475,11 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
renderdata->glGetError();
renderdata->glEnable(GL_TEXTURE_2D);
renderdata->glGenTextures(1, &data->texture);
result = renderdata->glGetError();
if (result != GL_NO_ERROR) {
SDL_free(data);
return GLES_SetError("glGenTextures()", result);
}

data->type = GL_TEXTURE_2D;
/* no NPOV textures allowed in OpenGL ES (yet) */
Expand Down
7 changes: 5 additions & 2 deletions src/render/opengles2/SDL_render_gles2.c
Expand Up @@ -418,15 +418,18 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
/* Allocate the texture */
rdata->glGetError();
rdata->glGenTextures(1, &tdata->texture);
if (rdata->glGetError() != GL_NO_ERROR) {
SDL_free(tdata);
return SDL_SetError("Texture creation failed in glGenTextures()");
}
rdata->glActiveTexture(GL_TEXTURE0);
rdata->glBindTexture(tdata->texture_type, tdata->texture);
rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode);
rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode);
rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
rdata->glTexImage2D(tdata->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL);
if (rdata->glGetError() != GL_NO_ERROR)
{
if (rdata->glGetError() != GL_NO_ERROR) {
rdata->glDeleteTextures(1, &tdata->texture);
SDL_free(tdata);
return SDL_SetError("Texture creation failed");
Expand Down

0 comments on commit 2a36e61

Please sign in to comment.