GLext.h won't compile

Hello,

I’m trying to compile the typical GLext.h file for using OpenGL extensions. The GLext.h file, among 5000 other lines of code, contains a whole bunch of statements of the form:

typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);

My compiler is not liking these statements. Does anyone know why not or have any advice on getting GLext.h to compile? I’m using GCC, by the way.

Note: I’m putting this on both the beginner and advanced forums, only because I honestly don’t know where this should go.

Generally, when I use extension, I copy the definition I need in the header glext.h in my own header file like this:


typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t);

static PFNGLACTIVETEXTUREPROC glActiveTexture;
static PFNGLMULTITEXCOORD2FPROC glMultiTexCoord2f;

Then I use a *GetProcAddress function to get the function pointer. Notice that some user of this forum use glew or glee to get the function pointer.

whats the error anyways? what does the compiler complain about? fyi: header files can’t be really compiled. try it out.

Well, I guess it would be more proper to say that the file including the header file is giving me a problem, but Eclipse reports the error as being in the header file because that is logically where the error occurs.

The error for this line (which is the first line on which a problem occurs):

typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);

is simply -
parse error before red

and there are no problems before this problem.

Do you include <GL/gl.h> before <GL/glext.h> ?. I suspect that you get GLclampf undefined because of that.

If you are under windows also include windows.h or the APIENTRYP will not be defined.

At the top of my main file:

#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
#include “GLext.h”
#include <GL/gl.h>
#include “glut.h”

I am compiling using Eclipse. The more I look at it, the more I think it is a compiler issue.

At the top of my main file:

#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
#include “GLext.h”
#include <GL/gl.h>
#include “glut.h”

I am compiling using Eclipse. The more I look at it, the more I think it is a compiler issue.

You include GLext.h before gl.h. I have tried this and I got a lot of error with gcc. Have you tried to include it after <GL/gl.h>. The GLext.h file contain declarations that depend on the gl.h header.

Holy sh*t, it works! I thought I tried that before…thank you so much. Some people specifically told me not to do that, which may be why I never tried it.

Can someone give me an example of how to do this *GetProcAddress thing?

Here is an example for the glActiveTexture function:


 glActiveTexture = (PFNGLACTIVETEXTUREPROC)glutGetProcAddress("glActiveTexture");

Just replace glutGetProcAddress with glxGetProcAddress or wglGetProcAddress.

What’s the difference between glxGetProcAddress, wglGetProcAddress, and glutGetProcAddress? If they all do the same thing, what dependencies do each of these introduce?

wgl : MS Windows only
glx : Xwindows only (unix, linux…)
glut : well, glut… which is cross-platform

OK, I think I want to be using glut then.