Reputation: 671
is the OpenGL function glDrawBuffers(GLsizei n, const GLenum *bufs) available in Qt? I'm trying to pass multiple render targets to my fragment shader, QtCreator says the function is not declared in this scope. The idea is to have a frame buffer object with two colorbuffers, and draw with the fragment shader to those two buffers.
FIXED: Just had to add #define GL_GLEXT_PROTOTYPES 1 to the offending file :(
Upvotes: 4
Views: 1878
Reputation: 899
We just spent some time fixing this. We are running Qt 5.2.1 on OSX 10.8 and Ubuntu 14.04 (sorry no WINDOWS experience) and created an OpenGL3.2 context using QGLFormat.
In OSX there is no problem as all OpenGL3.2 functions (to set uniforms, draw buffers, etc..) are defined in:
#include "OpenGL/gl3.h" ///< already included by Qt.. so nothing to do
On Linux on the other hand, we have to include BOTH of these:
#include "GL/gl.h"
#include "GL/glext.h" ///< not included by Qt!!! manually include it
We also attempted to have our QGLWidget class inherit from QGLFunctions_3_2_Core (this class defines its own copy of glDrawBuffer etc...), but this wasn't useful and simply resulted in a segfault:
Program received signal SIGSEGV, Segmentation fault. 0x0000000000407068
in glGetUniformLocation (this=0xbc5820, name=0x407cd0 "view_projection", program=1)
at /usr/include/qt5/QtGui/qopenglfunctions_3_2_core.h:1075 1075
return d_2_0_Core->GetUniformLocation(program, name);
We also investigated the "#define GL_GLEXT_PROTOTYPES 1" above, but this was only useful when we were using glcorearb.h (you can download this header online).
Upvotes: 0
Reputation: 162164
Qt offers only rudimentary access to OpenGL functions. Loading shaders and textures are amongst them. Render targets are not. Just use a proper extension loader library like GLEW. GLEW will nicely coexist with Qt's functionality.
Derive from QGLWidget and override glInit
to call glewInit
after calling initializeGL
Upvotes: 1