# HG changeset patch # User Sebastien Jodogne # Date 1674903923 -3600 # Node ID 444527d34647956844def11a67b9021db21e2eb0 # Parent a73a8415780fdbccf04712078436c1cd5f9e89a6 sanity check in textures diff -r a73a8415780f -r 444527d34647 OrthancStone/Sources/OpenGL/OpenGLTexture.cpp --- a/OrthancStone/Sources/OpenGL/OpenGLTexture.cpp Fri Jan 27 19:03:47 2023 +0100 +++ b/OrthancStone/Sources/OpenGL/OpenGLTexture.cpp Sat Jan 28 12:05:23 2023 +0100 @@ -143,6 +143,19 @@ // Load the texture from the image buffer glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, sourceFormat, pixelType, data); + + GLint w, h; + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h); + if (width != static_cast(w) || + height != static_cast(h)) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, + "Your GPU cannot create a texture of size " + + boost::lexical_cast(width) + " x " + + boost::lexical_cast(height)); + } + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, interpolation); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, interpolation); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);