Check the return value of glGenTextures()

--HG--
extra : rebase_source : e079554f253890d862bfd5d51d7b229e3fcff3d9
This commit is contained in:
Sam Lantinga 2013-08-10 10:49:26 -07:00
parent d4f386f5e3
commit 42c560b05d
3 changed files with 14 additions and 2 deletions

View file

@ -418,6 +418,10 @@ 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);
@ -425,8 +429,7 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
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");