Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Types of GL_TRUE and GL_FALSE are not 'bool'.
Forum Updated to NodeBB v4.3 + New Features

Types of GL_TRUE and GL_FALSE are not 'bool'.

Scheduled Pinned Locked Moved Solved Installation and Deployment
5 Posts 2 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AZOsan
    wrote on last edited by
    #1

    When I built Qt 5.1.1, types of GL_TRUE and GL_FALSE are not implemented as 'bool'.
    Therefore I added putit fix.

    *** qtbase/tests/auto/opengl/qgl/tst_qgl.cpp 2015-10-13 13:35:11.000000000 +0900
    --- tst_qgl.cpp 2016-01-09 21:16:11.352928721 +0900


    *** 2115,2139 ****

      QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
      // Make sure the texture IDs returned are valid:
    

    ! QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), GL_TRUE);
    ! QCOMPARE((bool)funcs->glIsTexture(boundPixmapTextureId), GL_TRUE);

      // Make sure the textures are still valid after we delete the image/pixmap:
      // Also check that although the textures are left intact, the cache entries are removed:
      delete boundImage;
      boundImage = 0;
    

    ! QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), GL_TRUE);
    QCOMPARE(QGLTextureCache::instance()->size(), startCacheItemCount+1);
    delete boundPixmap;
    boundPixmap = 0;
    ! QCOMPARE((bool)funcs->glIsTexture(boundPixmapTextureId), GL_TRUE);
    QCOMPARE(QGLTextureCache::instance()->size(), startCacheItemCount);

      // Finally, make sure QGLContext::deleteTexture deletes the texture IDs:
      ctx->deleteTexture(boundImageTextureId);
      ctx->deleteTexture(boundPixmapTextureId);
    

    ! QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), GL_FALSE);
    ! QCOMPARE((bool)funcs->glIsTexture(boundPixmapTextureId), GL_FALSE);
    }
    #endif

    --- 2115,2139 ----

      QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
      // Make sure the texture IDs returned are valid:
    

    ! QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), (bool)(GL_TRUE == GL_TRUE));
    ! QCOMPARE((bool)funcs->glIsTexture(boundPixmapTextureId), (bool)(GL_TRUE == GL_TRUE));

      // Make sure the textures are still valid after we delete the image/pixmap:
      // Also check that although the textures are left intact, the cache entries are removed:
      delete boundImage;
      boundImage = 0;
    

    ! QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), (bool)(GL_TRUE == GL_TRUE));
    QCOMPARE(QGLTextureCache::instance()->size(), startCacheItemCount+1);
    delete boundPixmap;
    boundPixmap = 0;
    ! QCOMPARE((bool)funcs->glIsTexture(boundPixmapTextureId), (bool)(GL_TRUE == GL_TRUE));
    QCOMPARE(QGLTextureCache::instance()->size(), startCacheItemCount);

      // Finally, make sure QGLContext::deleteTexture deletes the texture IDs:
      ctx->deleteTexture(boundImageTextureId);
      ctx->deleteTexture(boundPixmapTextureId);
    

    ! QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), (bool)(GL_TRUE == GL_FALSE));
    ! QCOMPARE((bool)funcs->glIsTexture(boundPixmapTextureId), (bool)(GL_TRUE == GL_FALSE));
    }
    #endif

    1 Reply Last reply
    0
    • Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      This is a bit convoluted.
      (bool)(GL_TRUE == GL_TRUE) is simply true and (bool)(GL_TRUE == GL_FALSE) is false.
      What's the point of making it harder?

      A 1 Reply Last reply
      0
      • Chris KawaC Chris Kawa

        This is a bit convoluted.
        (bool)(GL_TRUE == GL_TRUE) is simply true and (bool)(GL_TRUE == GL_FALSE) is false.
        What's the point of making it harder?

        A Offline
        A Offline
        AZOsan
        wrote on last edited by
        #3

        @Chris-Kawa Yes, I think correct you say. Using true and false is simple.

        I wondered why use GL_ value. And I don't know about GL_ well.
        There is some reason to use GL_ value, can leave a note GL_ value.

        1 Reply Last reply
        0
        • Chris KawaC Online
          Chris KawaC Online
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by Chris Kawa
          #4

          It's a historical issue. Back in the ancient times, when OpenGL was forged from the ashes of IrisGL in the depths of SGI the types had no well defined sizes on many platforms, so most libraries, including OpenGL declared their own types as #defines over whatever the given implementation provided. Thus types like GLboolean or GLenum were born.
          It so happens that nowadays GLboolean is usually an unsigned char and GLenum is usually something like unsigned int.

          The glIsTexture method returns a boolean value, so obviously a GLboolean was chosen for the return type. For whatever reason GL_TRUE and GL_FALSE were defined as GLenum and not GLboolean, so this creates an inconsistency that can never be fixed because of backwards compatibility.

          Anyway, both of these are integer types, so there's many ways to fix it, including, but not exhausting, the list:

          //compiler will automatically convert to a type accommodating both,  but might issue a warning
          ! QCOMPARE(funcs->glIsTexture(boundImageTextureId), GL_TRUE);
          
          //will probably work but casts integers to bools so ugly
          ! QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), (bool)GL_TRUE);
          
          //will work but probably downcasts int to unsigned char so...
          ! QCOMPARE(funcs->glIsTexture(boundImageTextureId), (Glboolean)GL_TRUE);
          
          //potentially upcasts both values
          ! QCOMPARE((GLint)funcs->glIsTexture(boundImageTextureId), (Glint)GL_TRUE);
          
          1 Reply Last reply
          1
          • A Offline
            A Offline
            AZOsan
            wrote on last edited by
            #5

            This problem is Raspberry Pi's making maybe.
            I wanted to say 'If GL_ values type isn't bool?'.
            There are many answer to this.

            I close this discussion. Thanks Chris!

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved