PDA

View Full Version : GLext.h won't compile



thetinkerer
12-07-2008, 10:38 PM
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.

trinitrotoluene
12-08-2008, 08:34 AM
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 (http://glew.sourceforge.net/) or glee (http://www.opengl.org/sdk/libs/GLee/) to get the function pointer.

_NK47
12-08-2008, 09:42 AM
whats the error anyways? what does the compiler complain about? fyi: header files can't be really compiled. try it out.

thetinkerer
12-08-2008, 10:59 AM
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.

trinitrotoluene
12-08-2008, 01:48 PM
Do you include <GL/gl.h> before <GL/glext.h> ?. I suspect that you get GLclampf undefined because of that.

Rosario Leonardi
12-08-2008, 04:27 PM
If you are under windows also include windows.h or the APIENTRYP will not be defined.

thetinkerer
12-14-2008, 07:31 AM
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.

trinitrotoluene
12-14-2008, 10:03 AM
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.

thetinkerer
12-14-2008, 10:30 AM
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.

thetinkerer
12-14-2008, 10:39 AM
Can someone give me an example of how to do this *GetProcAddress thing?

trinitrotoluene
12-14-2008, 10:56 AM
Here is an example for the glActiveTexture function:


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

Just replace glutGetProcAddress with glxGetProcAddress or wglGetProcAddress.

thetinkerer
12-15-2008, 12:05 PM
What's the difference between glxGetProcAddress, wglGetProcAddress, and glutGetProcAddress? If they all do the same thing, what dependencies do each of these introduce?

ZbuffeR
12-15-2008, 12:31 PM
wgl : MS Windows only
glx : Xwindows only (unix, linux...)
glut : well, glut... which is cross-platform

thetinkerer
12-15-2008, 04:25 PM
OK, I think I want to be using glut then.