]> granicus.if.org Git - graphviz/commitdiff
fix handling of glGenTextures failure
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 6 Sep 2020 00:26:51 +0000 (17:26 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 12 Sep 2020 02:27:04 +0000 (19:27 -0700)
According to the OpenGL docs, glGenTextures indicates failure not through
returning a value in its out parameter but rather via the glGetError API.
Moreover it could not actually indicate failure in the way this call site was
expecting because the out parameter is unsigned, not signed. This issue was
identified while investigating the cause of the following compiler warning:

  glcomptexture.c: In function â€˜glCompSetAddNewTexture’:
  glcomptexture.c:45:12: warning: comparison of unsigned expression < 0 is
    always false [-Wtype-limits]

    if (t->id < 0)  /*for some opengl based error , texture couldnt be created */
              ^

CHANGELOG.md
lib/glcomp/glcomptexture.c

index 701f694f6acc9f6f629d5093864d8f24b9c617aa..e2544b93cfc36625717130ede2ac0534f0712865 100644 (file)
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - "Warning! PATH too long installer unable to modify PATH!" using CMake Windows installer and PATH length > 1024 #1770
 - gvedit -? gives "option - unrecognized - ignored" instead of showing usage #1813
 - lefty is not built for Windows (fixed for MSBuild builds only) #1818
+- a failure to detect OpenGL glGenTextures() errors has been corrected
 
 ## [2.44.1] - 2020-06-29
 
index 872a7ceb8266ef1645e308459958b115435f878b..d3402bf3c2762f4dc486a0dfde57f40d46368022 100644 (file)
@@ -42,9 +42,11 @@ static glCompTex *glCompSetAddNewTexture(glCompSet * s, int width,
        glEnable(GL_DEPTH_TEST);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
        glGenTextures(1, &t->id);       //get next id
-       if (t->id < 0)          /*for some opengl based error , texture couldnt be created */
+       if (glGetError() != GL_NO_ERROR) {              /*for some opengl based error , texture couldnt be created */
+           /* drain the OpenGL error queue */
+           while (glGetError() != GL_NO_ERROR);
            Er = 1;
-       else {
+       else {
            glBindTexture(GL_TEXTURE_2D, t->id);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);