Check that textures are a power of two early rather than dying in PVR code

This commit is contained in:
Luke Benstead 2017-07-23 20:47:31 +01:00
parent 4bf579f7bc
commit 63aa2ec47c

View File

@ -242,6 +242,18 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat,
if(internalFormat != GL_RGBA)
_glKosThrowError(GL_INVALID_VALUE, "glTexImage2D");
GLint w = width;
if(w == 0 || (w & -w) != w) {
/* Width is not a power of two. Must be!*/
_glKosThrowError(GL_INVALID_VALUE, "glTexImage2D");
}
GLint h = height;
if(h == 0 || (h & -h) != h) {
/* height is not a power of two. Must be!*/
_glKosThrowError(GL_INVALID_VALUE, "glTexImage2D");
}
if(level < 0)
_glKosThrowError(GL_INVALID_VALUE, "glTexImage2D");