I am using QT 4.8.4 and drawing OpenGL on QGraphicsScene background. The problem is that I am getting invalid return from glGetError(). My code snippet:
while (GLenum err = glGetError() != GL_NO_ERROR) {
std::cerr << err;
}
On application output I get a lot of lines with number 1
From the documentation I see possible values are:
GL_NO_ERROR, GL_INVALID_ENUM, GL_INVALID_VALUE, GL_INVALID_OPERATION, GL_INVALID_FRAMEBUFFER_OPERATION, GL_OUT_OF_MEMORY, GL_STACK_UNDERFLOW, GL_STACK_OVERFLOW
which are defined as 0, 0x0500, 0x0501, 0x0502, 0x0503, 0x0504, 0x0505, 0x0506.
This started to happen when I wrapped my native OpenGL drawing code with QT's:
painter->beginNativePainting();
...
painter->endNativePainting();
PS: The multiple 1's are from multiple draw calls and not from the loop.
Try this instead:
GLenum err;
while ( ( err = glGetError() ) != GL_NO_ERROR) {
std::cerr << err;
}
Your !=
was getting evaluated before the =
.
I suspect that the following line doesn't do what you want:
GLenum err = glGetError() != GL_NO_ERROR
It first evaluates glGetError() != GL_NO_ERROR
, and then assigns it to err
.
That's why it's always a good idea to spend 2 more characters in your source code:
(GLenum err = glGetError()) != GL_NO_ERROR
Additional advice: Use glewGetErrorString
if you are already using the glew
library:
std::cerr << glewGetErrorString(err);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With