OpengGL glDrawBuffers () in Qt?

is the OpenGL function glDrawBuffers (GLsizei n, const GLenum * bufs) available in Qt? I am trying to pass several rendering goals into my fragment shader, QtCreator says that the function is not declared in this area. The idea is to have a frame buffer object with two color buffers and draw a fragment shader for these two buffers using the shader.

FIXED: It was just necessary to add #define GL_GLEXT_PROTOTYPES 1 to the intruder file :(

+4
source share
2 answers

Qt offers only rudimentary access to OpenGL features. Loading shaders and textures among them. No rendering goals. Just use a suitable extension loader library such as GLEW. GLEW will coexist well with Qt functionality.

Derive from QGLWidget and override glInit to call glewInit after initializeGL

+1
source

We just spent some time on it. We run Qt 5.2.1 on OSX 10.8 and Ubuntu 14.04 (sorry no WINDOWS ) and created OpenGL3.2 using QGLFormat.

There is no problem in OSX , since all the functions of OpenGL3.2 (for setting uniforms, drawing buffers, etc.) are defined in:

 #include "OpenGL/gl3.h" ///< already included by Qt.. so nothing to do 

On Linux , we have to enable BOTH of them:

 #include "GL/gl.h" #include "GL/glext.h" ///< not included by Qt!!! manually include it 

We also tried to inherit the QGLWidget class from QGLFunctions_3_2_Core (this class defines its own copy of glDrawBuffer, etc.), but this was not useful and simply led to 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 explored "#define GL_GLEXT_PROTOTYPES 1" above, but it was only useful when we used glcorearb.h (you can download this header online).

0
source

Source: https://habr.com/ru/post/1412281/


All Articles