Author Topic: OpenGL Extensions  (Read 2987 times)

Offline fivesprites

  • Mr. Polyvector
  • ***
  • Posts: 101
    • View Profile
    • FiveSprites
OpenGL Extensions
« on: 2012-Nov-20 »
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

  • Guest
Re: OpenGL Extensions
« Reply #1 on: 2012-Nov-20 »
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.

Offline fivesprites

  • Mr. Polyvector
  • ***
  • Posts: 101
    • View Profile
    • FiveSprites
Re: OpenGL Extensions
« Reply #2 on: 2012-Nov-20 »
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


Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2640
    • View Profile
Re: OpenGL Extensions
« Reply #3 on: 2012-Nov-20 »
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

  • Guest
Re: OpenGL Extensions
« Reply #4 on: 2012-Nov-20 »
I suspect you will need to use glGetProcAddress to access the function as it isn't accessible through the usual routes...

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2640
    • View Profile
Re: OpenGL Extensions
« Reply #5 on: 2012-Nov-20 »
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)

Offline fivesprites

  • Mr. Polyvector
  • ***
  • Posts: 101
    • View Profile
    • FiveSprites
Re: OpenGL Extensions
« Reply #6 on: 2012-Nov-20 »
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