OpenGL Extensions

Previous topic - Next topic

fivesprites

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

MrTAToad

If you try this example :

Code (glbasic) Select
INLINE
extern "C" void __stdcall glGenBuffers(int n , void *buffers );
ENDINLINE


It compiles fine, so I suspect its one of your type variables.

fivesprites

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


bigsofty

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.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

MrTAToad

I suspect you will need to use glGetProcAddress to access the function as it isn't accessible through the usual routes...

bigsofty

BTW I used OpenGL extensions in my OpenB3D port, using Glee. See here... http://www.glbasic.com/forum/index.php?topic=6982.msg56815#msg56815
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

fivesprites

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