2 * Copyright (C) 2003-2011 Neverball authors
4 * NEVERBALL is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
19 /*---------------------------------------------------------------------------*/
23 PFNGLACTIVETEXTURE_PROC glActiveTexture_;
25 PFNGLGENBUFFERS_PROC glGenBuffers_;
26 PFNGLBINDBUFFER_PROC glBindBuffer_;
27 PFNGLBUFFERDATA_PROC glBufferData_;
28 PFNGLBUFFERSUBDATA_PROC glBufferSubData_;
29 PFNGLDELETEBUFFERS_PROC glDeleteBuffers_;
30 PFNGLISBUFFER_PROC glIsBuffer_;
32 PFNGLPOINTPARAMETERFV_PROC glPointParameterfv_;
36 /*---------------------------------------------------------------------------*/
38 int glext_check(const char *needle)
40 const GLubyte *haystack, *c;
42 /* Search for the given string in the OpenGL extension strings. */
44 for (haystack = glGetString(GL_EXTENSIONS); *haystack; haystack++)
46 for (c = (const GLubyte *) needle; *c && *haystack; c++, haystack++)
50 if ((*c == 0) && (*haystack == ' ' || *haystack == '\0'))
57 /*---------------------------------------------------------------------------*/
59 #define SDL_GL_GFPA(fun, str) do { \
60 ptr = SDL_GL_GetProcAddress(str); \
61 memcpy(&fun, &ptr, sizeof (void *)); \
64 /*---------------------------------------------------------------------------*/
72 if (glext_check("ARB_multitexture"))
73 SDL_GL_GFPA(glActiveTexture_, "glActiveTextureARB");
75 if (glext_check("ARB_vertex_buffer_object"))
77 SDL_GL_GFPA(glGenBuffers_, "glGenBuffersARB");
78 SDL_GL_GFPA(glBindBuffer_, "glBindBufferARB");
79 SDL_GL_GFPA(glBufferData_, "glBufferDataARB");
80 SDL_GL_GFPA(glBufferSubData_, "glBufferSubDataARB");
81 SDL_GL_GFPA(glDeleteBuffers_, "glDeleteBuffersARB");
82 SDL_GL_GFPA(glIsBuffer_, "glIsBufferARB");
85 if (glext_check("ARB_point_parameters"))
86 SDL_GL_GFPA(glPointParameterfv_, "glPointParameterfvARB");
91 /*---------------------------------------------------------------------------*/