From 3395f17687bfe3f32249e7d1be583a7fe77c194e Mon Sep 17 00:00:00 2001 From: Luke Benstead Date: Wed, 17 Apr 2019 16:19:03 +0100 Subject: [PATCH] Throw GL_INVALID_OPERATION if mipmaps are specified for non-square textures --- GL/framebuffer.c | 7 +++++++ GL/texture.c | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/GL/framebuffer.c b/GL/framebuffer.c index cd77798..9af7575 100644 --- a/GL/framebuffer.c +++ b/GL/framebuffer.c @@ -206,6 +206,13 @@ void APIENTRY glGenerateMipmapEXT(GLenum target) { TextureObject* tex = _glGetBoundTexture(); + if(tex->width != tex->height) { + fprintf(stderr, "[GL ERROR] Mipmaps cannot be supported on non-square textures\n"); + _glKosThrowError(GL_INVALID_OPERATION, __func__); + _glKosPrintError(); + return; + } + if(!tex || !tex->data || !tex->mipmapCount) { _glKosThrowError(GL_INVALID_OPERATION, __func__); _glKosPrintError(); diff --git a/GL/texture.c b/GL/texture.c index 62bc950..f3a1662 100644 --- a/GL/texture.c +++ b/GL/texture.c @@ -852,6 +852,11 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat, _glKosThrowError(GL_INVALID_VALUE, "glTexImage2D"); } + if(level > 0 && width != height) { + fprintf(stderr, "[GL ERROR] Mipmaps cannot be supported on non-square textures\n"); + _glKosThrowError(GL_INVALID_OPERATION, __func__); + } + if(border) { _glKosThrowError(GL_INVALID_VALUE, "glTexImage2D"); }