0

I'm currently working on OpenGL in Qt and trying to create a framebuffer object using following call

 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, scene_img, 0);

When I try to compile my project I get following error:

Error: C2065: 'GL_FRAMEBUFFER_EXT' : undeclared identifier

Apparently the name GL_FRAMEBUFFER_EXT is not identified anywhere. I tried importing QtOpenGL, QGLShaderProgram and QGLFramebufferObject with no luck. Still the same error. I took a look in ql.h, still no luck. Is there anything else I have to import? Note that my normal QGLWidget works without a problem, except for the FRAMEBUFFER issue.

Btw: Working on Windows 7

genpfault
  • 51,148
  • 11
  • 85
  • 139
anopheles
  • 434
  • 1
  • 9
  • 19

1 Answers1

2

trying to create a framebuffer object using following call

glFramebufferTexture2DEXT(

that doesn't create a framebuffer object. It assigns a texture as color attachment.

BTW, functions ending in EXT are extension functions that are not part of core functionality. Extensions usually go from EXT to ARB and may become core, however subtle to significant changes to the API may happen.

Anyway, everything beyond OpenGL-1.1 (Windows) or OpenGL-1.2 (GLX) must be accessed through the extension mechanism, even if it's become core functionality.

Most simple way to do it:

  1. Download GLEW from http://glew.sourceforge.net
  2. Replace all occurences of #include <GL/gl.h> with #include <GL/glew.h>
  3. call glewInit(); after (each) context creation
  4. add the GLEW libraries to your build linker settings.
datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • Thanks so far. I did everything you said. No my app doesn't complain anymore but now I simply get an error return code. Seems like I'm doing something wrong or have incompatible compilers. – anopheles Nov 07 '12 at 19:06
  • Okay, I narrowed it down to the call of glewInit(); I have multiple views (sub classes of QGLWidget) and I'm calling glewInit() in every initializeGL() call. Is this wrong or how should I use glewInit()? – anopheles Nov 07 '12 at 19:34
  • @user1509533: Yes, you have to call glewInit for each context. If that doesn't work, try adding glewInit() also at the beginning of each `paintGL`. If that works, you must add further code to be efficient (otherwise GLEW will reload all function pointers again and again, instead of using a cache). – datenwolf Nov 07 '12 at 19:48
  • Okay, I got it to work, I forgot to the glew32.dll inside the folder containing the glew32.lib file. Seems to work now. Thanks! – anopheles Nov 07 '12 at 21:36