Solved Types of GL_TRUE and GL_FALSE are not 'bool'.
-
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 -
This is a bit convoluted.
(bool)(GL_TRUE == GL_TRUE)
is simplytrue
and(bool)(GL_TRUE == GL_FALSE)
isfalse
.
What's the point of making it harder? -
@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. -
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
orGLenum
were born.
It so happens that nowadaysGLboolean
is usually anunsigned char
andGLenum
is usually something likeunsigned int
.The
glIsTexture
method returns a boolean value, so obviously aGLboolean
was chosen for the return type. For whatever reason GL_TRUE and GL_FALSE were defined asGLenum
and notGLboolean
, 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);
-
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!