changeset 2036:444527d34647 deep-learning

sanity check in textures
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 28 Jan 2023 12:05:23 +0100
parents a73a8415780f
children d81a7157a846
files OrthancStone/Sources/OpenGL/OpenGLTexture.cpp
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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<unsigned int>(w) ||
+            height != static_cast<unsigned int>(h))
+        {
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
+                                          "Your GPU cannot create a texture of size " +
+                                          boost::lexical_cast<std::string>(width) + " x " +
+                                          boost::lexical_cast<std::string>(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);