1
\$\begingroup\$

How can I enable OpenGL 3.x functionality via extensions? I'm new to OpenGL development under Linux. Currently I have:

#define GL_GLEXT_PROTOTYPES
#include <GL/osmesa.h>
#include <GL/glu.h>

My problem with Mesa and OpenGL 2.x is that I get an OpenGL "invalid value" error here:

glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, width, height, 0, GL_RGBA, GL_FLOAT, NULL );

because of GL_RGBA32F_ARB, it seems.

Background: I need the texture for a framebuffer object, and GL_RGBA32F_ARB for float data without clamping. My program works well using OpenGL 3.0 if I create the context with GLX.

\$\endgroup\$
1
  • \$\begingroup\$ If you can share a complete but minimal example I'm interested in investigating. \$\endgroup\$
    – codeshot
    Jun 11, 2016 at 8:20

1 Answer 1

1
\$\begingroup\$

I think that it's better to use GLEW to export all the extensions functionality. It's cross platform and allows you to write conditional code for different configurations.

\$\endgroup\$
5
  • \$\begingroup\$ I tried glew now: #include <GL/glew.h> #ifndef GLAPI #define GLAPI extern #endif #include <GL/osmesa.h> #include <GL/glu.h> | I have to (re-)define GLAPI because glew undefines it at the end of the header and gl.h it not included again in the osmesa.h. I found that in a forum post. | Result: still not successfull with GL_RGBA32F_ARB. Additionally, my shaders now do not compile successfully. If relevant: I have Debian Wheezy with Mesa 8.0.5 and Glew 1.7. \$\endgroup\$
    – dmohr
    Aug 1, 2014 at 11:45
  • \$\begingroup\$ Have you initialized glew as shows glew's homepage? \$\endgroup\$ Aug 1, 2014 at 18:02
  • \$\begingroup\$ I did. I already use glew for the windows version of my application. I just removed the #ifdef WIN32 line(s). I can recheck on monday if there is something different on linux. \$\endgroup\$
    – dmohr
    Aug 2, 2014 at 16:59
  • \$\begingroup\$ According to the glew homepage, there is no difference between windows and linux. So glew initialization/usage should not be the problem. :( \$\endgroup\$
    – dmohr
    Aug 5, 2014 at 8:38
  • \$\begingroup\$ glew isn't compatible with osmesa because glew incorrectly assumes that OpenGL is a part of X Windows and uses functions from GLX and those don't work with OSMesa contexts. \$\endgroup\$
    – codeshot
    Jun 11, 2016 at 8:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .