Hmm, OK, I've conducted some research on the issue, and as I suspected, somebody (GLEW) actually uses macros This is more than what CDT obviously can handle
Since I'm no longer a hard-core linux user, I've installed the "classic" Eclipse from the web site on Ubuntu, then added the CDT via p2. This is my "lame" code I'm testing with:
#include <GL/glew.h>
#include <GL/glfw.h>
#include <iostream>
int main(int argc, char** argv) {
if (argc == 2) {
glBindBuffer(GL_ARRAY_BUFFER, -1);
}
std::cout<<"compiles"<<std::endl;
return 0;
}
First, it does compile. OGL 1.x functionality can be found (e.g. glBegin(), glVertex2f()...), because it is quite easily defined in glew.h:.
GLAPI void GLAPIENTRY glBegin (GLenum mode);
Now, if we get to the definition of glBindBuffer, which is:
#define glBindBuffer GLEW_GET_FUN(__glewBindBuffer)
.. whch leads us to
~ grep "#define GLEW_GET_FUN" /usr/include/GL/glew.h
#define GLEW_GET_FUN(x) x
~ grep "__glewBindBuffer;" /usr/include/GL/glew.h
GLEW_FUN_EXPORT PFNGLBINDBUFFERPROC __glewBindBuffer;
~ grep "#define GLEW_FUN_EXPORT" /usr/include/GL/glew.h
#define GLEW_FUN_EXPORT
#define GLEW_FUN_EXPORT GLEWAPI
(we can safely assume it's nothing on Linux)
~ grep "PFNGLBINDBUFFERPROC" /usr/include/GL/glew.h
typedef void (GLAPIENTRY * PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
GLEW_FUN_EXPORT PFNGLBINDBUFFERPROC __glewBindBuffer;
(we are searching for the first one.. which is the function signature)
hmm. A lot of #define and typedef magic Most C++ parsers would die at the very first define Let's see if we can cheat, though
Now that we know that the problem is (MACROS), we ca implement a hack. First, go off and download your personal copy of glext.h from http://www.opengl.org/registry/api/glext.h. Place it in your project's root directory. Now, let's change the source of our little hack to:
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include "glext.h"
#include <iostream>
int main(int argc, char** argv) {
if (argc == 2) {
glBindBuffer(GL_ARRAY_BUFFER, -1);
}
std::cout<<"compiles"<<std::endl;
return 0;
}
Now, that DOES compile, however I can't verify that it will run (as I'm not really an OGL person, and it's quite too late to write an example). However, if it does run with GLEW, it should run that way, too, provided you still link to the same libraries. I know, it is an ugly hack, but it does work. I haven't spent the time to test whether it works on other IDEs (QtCreator and KDevelop). Hope that helps.