Hi All,
Does anybody know how to access OpenGL extensions such as glGenBuffersARB() ?
Specifically, I'm trying to make use of VBO's for which there's no direct access within GLBasic. gl.gbas doesn't contain any inline code for glGenBuffers or glGenBuffersARB. The ARB extension can be found in the headers (GLext.h) but I always get link failures if I try to inline:
INLINE
} extern "C" { void __stdcall glGenBuffers( GLsizei n , GLuint *buffers );; }; namespace __GLBASIC__ {
ENDINLINE
FUNCTION glGenBuffers: n, buffers[]
INLINE
GLuint* pf=new GLuint[(int)n];
for(int i=0; i<(int)n; ++i) pf=buffers(i);
OGL glGenBuffers(n, pf);
delete[] pf;
ENDINLINE
ENDFUNCTION
linking:
gpc_temp3.o:gpc_temp3.cpp:(.text+0x3833b): undefined reference to `_glGenBuffers@8'
The same applies for glGenBuffersARB
//Andy
If you try this example :
INLINE
extern "C" void __stdcall glGenBuffers(int n , void *buffers );
ENDINLINE
It compiles fine, so I suspect its one of your type variables.
On its own, that inline will compile, but when you try to use it the link error appears. If I change the types to be the same as you defined then I get the same result I'm afraid.
INLINE
typedef int GLsizei;
typedef unsigned int GLuint;
extern "C" void __stdcall glGenBuffers(GLsizei n , GLuint *buffers );
ENDINLINE
FUNCTION glGenBuffers: n, buffers[]
INLINE
GLuint* pf=new GLuint[(int)n];
for(int i=0; i<(int)n; ++i) pf=buffers(i);
::glGenBuffers(n, pf);
delete[] pf;
ENDINLINE
ENDFUNCTION
linking:
gpc_temp2.o:gpc_temp2.cpp:(.text+0x31b): undefined reference to `_glGenBuffers@8'
The above routine is effectively the same as glGenTextures() found in gl.gbas
Are you linking a header with this extension definition in it somewhere else? If not then you may have to use an extension loader lib, like GLEW for example if your current GL headers don't support glGenBuffers.
I suspect you will need to use glGetProcAddress to access the function as it isn't accessible through the usual routes...
BTW I used OpenGL extensions in my OpenB3D port, using Glee. See here... http://www.glbasic.com/forum/index.php?topic=6982.msg56815#msg56815
Yep - looks like I'll need another route to get to the extensions. Thanks for the heads-up on OpenB3D - will take a look :)
//Andy