PDA

View Full Version : How to get GL_GLEXT_FUNCTION_POINTERS to work?



airfang
12-24-2007, 09:51 AM
I used 3d texture in my program, but when I wanted to port the program to OS X I encountered some problems:

in windows, what I did was include glext.h and started using something like:

PFNGLTEXIMAGE3DPROC glTexImage3D;

and later

glTexImage3D = (glTexImage3DEXTProcPtr)wglGetProcAddress("glTexImage3D");

but on OS X, from here (http://lists.apple.com/archives/Mac-opengl/2004/Jan/msg00095.html) I learnt that I need to define GL_GLEXT_FUNCTION_POINTERS in order to enable function pointers, I tried to define it like this:

#include <GLUT/glut.h>
#define GL_GLEXT_FUNCTION_POINTERS 1
#include <OpenGL/glext.h>

because defining it before including glut generated more error...also I replaced PFNGLTEXIMAGE3DPROC with glTexImage3DEXTProcPtr, but it still gives me "error: glTexImage3DEXTProcPtr does not name a type", I don't know where went wrong

Also, I know that wglGetProcAddress doesn't work on OS X, so how should this be implemented?

Thank you guys! Merry Christmas!

Groovounet
12-24-2007, 10:57 AM
I have ported a software from Windows to MacOS X and it seams actually really easy as far as MacOS X already provide an OpenGL 2 implementation. Under Windows I use GLEW to load every functions but under MacOS I just had to replace my #include <GL/glew.h> by #include <OpenGL/gl.h> (Do not remember the actual name of this include but I guest you will find it easely). In conclusion, no need of GetProcessAddress or whatever, just use the function!

This was done on MacOS 10.4... could different with previous release I think.

Merry Christmas too!

OneSadCookie
12-24-2007, 02:55 PM
You haven't needed to load function pointers since Mac OS X 10.2, at least. They're "weak linked", meaning that your application will run (but the function will be NULL) even if the user is running on an OS version without that function.

For compatibility with Windows/Linux code though, it's sometimes useful to use them.

<GLUT/glut.h> includes <OpenGL/gl.h> already, so by the time you define GL_GLEXT_FUNCTION_POINTERS it's too late. Make sure this is defined before all gl.h is first included.

airfang
12-25-2007, 11:22 PM
wow, got that working! thx! turns out I dont need to include glext.h at all, let alone defining GL_GLEXT_FUNCTION_POINTERS

OS X has made it so easy...

one more thing to ask u sadcookie, so I followed ur way to add Cocoa target in order to start a OpenGL application but I found the console missing, is there anyway I can get the console display out so I can get some information from standard output?

OneSadCookie
12-26-2007, 05:27 AM
Pressing cmd-shift-R ("Run Log") should bring it up, I think. There's a menu item somewhere too.

airfang
12-26-2007, 11:24 AM
Pressing cmd-shift-R ("Run Log") should bring it up, I think. There's a menu item somewhere too.

thx