PDA

View Full Version : compile error glxext.h



RigoN
09-12-2009, 03:01 PM
Hi, all!!!
I'm add my project new header files gl3.h, glext.h, glxext.h
Compile project, I get error:



glxext.h: 407: error: 'XID' is not a type name
glxext.h: 411: error: 'XID' is not a type name
glxext.h: 416: error: 'XID' is not a type name
glxext.h: 420: error: 'Bool' is not a type name
glxext.h: 421: error: ISO C + + forbids declaration 'Display' with no type
glxext.h: 421: error: expected ';' before '*' token
glxext.h: 422: error: 'GLXDrawable' is not a type name
glxext.h: 500: error: expected initializer before '*' token
glxext.h: 501: error: expected initializer before '*' token
glxext.h: 502: error: typedef-declaration 'PFNGLXGETFBCONFIGATTRIBPROC' with initialization (use the design __typeof__)
glxext.h: 502: error: no declaration 'Display' in this scope
glxext.h: 502: error: no declaration 'dpy' in this scope
glxext.h: 502: error: no declaration 'GLXFBConfig' in this scope
glxext.h: 502: error: expected primary-expression before 'int'
glxext.h: 502: error: expected primary-expression before 'int'
glxext.h: 503: error: expected initializer before '*' token

Please, help me!!!
What am I doing wrong, why there are errors?

marshats
09-12-2009, 04:25 PM
I am not exactly sure but reading the gl3.h file itself makes a statement that directly quotes "It is not possible to #include both <GL3/gl3.h> and either of <GL/gl.h> or <GL/glext.h> in the same source file." So make sure you don't have gl.h or glext.h include directives. Note glxext.h is linux specific so don't use it if you are in windows.

For years I have been frustrated by using the gl*ext header files directly so that is why I resort to the excellent cross-platform helper library GLEW: The openGL Extensions Wrangler (http://www.opengl.org/sdk/libs/GLEW/). Another alternative that some like for the same purpose is GLee (http://www.opengl.org/sdk/libs/GLee/)

For me I use glew to get the extensions so for what it is worth what I do is



#include <GL/glew.h> // great opengl extensions helper
#include <GL3/gl3.h>
#include <GL/freeglut.h> // use of opengl 3.0 context requires freeglut!

// compile with g++ main.cpp -lglut -lGLEW -DGL3_PROTOTYPES


Also I have found that I have to have a "#define GL3_PROTOTYPES" set before the gl3 header is included - in g++ this is just a -DGL3_PROTOTYPES command line option. In other compilers I bet just putting #define GL3_PROTOTYPES line before your #include's will accomplish the same thing.

RigoN
09-12-2009, 04:59 PM
Thanks!

I'm doing a project as a replacement for GLEW. And I need to initialize GL, GLX, WGL extension, using only glext, glxext, wglext. I think it's really done. using only these headers.

Or I have missed something ... then add some please.

marshats
09-12-2009, 07:08 PM
I looked at glew.h and followed its includes and noticed in Linux at least it explicitly added the following headers



#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xmd.h>


That reduced the number of compile errors but I was still left some .. maybe that will help in part. So it appears glxext.h has some dependencies on X11/headers that you have to include explicitly.

marshats
09-13-2009, 12:45 AM
After reading some more especially the glx.h header, it appeared as simple as just including gl3.h and glx.h. However on closer inspection glx.h includes gl.h and glxext.h -- gl.h doesn't make sense if you want to use the new gl3.h! So I decided to pull the minimal parts from glx.h that were needed to get rid of the compiler errors and came up with the following:



#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <GL/gl3.h>

typedef XID GLXContextID;
typedef XID GLXPixmap;
typedef XID GLXDrawable;
typedef XID GLXPbuffer;
typedef XID GLXWindow;
typedef XID GLXFBConfigID;
typedef struct __GLXcontextRec *GLXContext;
typedef struct __GLXFBConfigRec *GLXFBConfig;

#include <GL/glxext.h>

RigoN
09-13-2009, 02:47 AM
to marshats:
Thanks!!!
Your post helped, these errors are not already, thanks for the help.