From: John T. <nu...@me...> - 2012-03-25 12:48:51
|
On Sun, Mar 25, 2012 at 01:29:29PM +0200, Sylvain wrote: > Hi, > > To support OpenGL (ES) 2.0 in fg_geometry we need functions such as > glVertexAttribPointer. > > To access these functions portably, especially on windows, we need to > define it at runtime (it's not defined in -lopengl32), probably > through glewGetProcAddress. > > I remember somebody saying recently on the list that we shouldn't use > GLEW or similar, and do that ourselves. > > How can we do that? :) First you check for extension availability by parsing the extension string returned by glGetString(GL_EXTENSIONS). Then if the extension you wish to use has new entry points, you need to get pointers to those functions by calling glXGetProcAddress, wglGetProcAddress, or even dlsym directly. Freeglut provides glutProcAddress that abstracts that platform-specific sort of thing so you should use that instead. Example pseudocode: void (*active_texture_arb)(GLenum); char *ext_str = glGetString(GL_EXTENSIONS); if(strstr(ext_str, "GL_ARB_multitexture")) { active_texture_arb = glutGetProcAddress("glActiveTextureARB"); } A word of wisdom: Don't use the same name for your function pointer as the original symbol if it's not static. libGL implementations on UNIX have those symbols globally defined in the shared library, and they will clash. -- John Tsiombikas http://nuclear.mutantstargoat.com/ |