Fixed bug 2122 - SDL_CreateTexture allows illegal texture sizes

Lloyd Bryant

SDL_CreateTexture() is succeeding (i.e. returning a valid pointer) when the requested horizontal or vertical size of the texture exceeds the maximum allowed by the render.  This results in hard-to-understand errors showing up when later attempting to use that texture (such as with SDL_SetRenderTarget()).
This commit is contained in:
Sam Lantinga 2013-09-30 22:16:14 -07:00
parent 0a805ff137
commit 76f3df86db
2 changed files with 13 additions and 0 deletions

View file

@ -1627,6 +1627,7 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
#endif
Uint32 windowFlags;
GLint window_framebuffer;
GLint value;
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
@ -1685,6 +1686,13 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
}
value = 0;
rdata->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
renderer->info.max_texture_width = value;
value = 0;
rdata->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
renderer->info.max_texture_height = value;
/* Determine supported shader formats */
/* HACK: glGetInteger is broken on the Zune HD's compositor, so we just hardcode this */
rdata->glGetError();