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.
20 /*---------------------------------------------------------------------------*/
24 PFNGLCLIENTACTIVETEXTURE_PROC glClientActiveTexture_;
25 PFNGLACTIVETEXTURE_PROC glActiveTexture_;
27 PFNGLGENBUFFERS_PROC glGenBuffers_;
28 PFNGLBINDBUFFER_PROC glBindBuffer_;
29 PFNGLBUFFERDATA_PROC glBufferData_;
30 PFNGLBUFFERSUBDATA_PROC glBufferSubData_;
31 PFNGLDELETEBUFFERS_PROC glDeleteBuffers_;
32 PFNGLISBUFFER_PROC glIsBuffer_;
34 PFNGLPOINTPARAMETERFV_PROC glPointParameterfv_;
38 /*---------------------------------------------------------------------------*/
40 int glext_check(const char *needle)
42 const GLubyte *haystack, *c;
44 /* Search for the given string in the OpenGL extension strings. */
46 for (haystack = glGetString(GL_EXTENSIONS); *haystack; haystack++)
48 for (c = (const GLubyte *) needle; *c && *haystack; c++, haystack++)
52 if ((*c == 0) && (*haystack == ' ' || *haystack == '\0'))
59 int glext_assert(const char *ext)
61 if (!glext_check(ext))
63 fprintf(stderr, "Missing required OpenGL extension (%s)\n", ext);
69 /*---------------------------------------------------------------------------*/
71 #define SDL_GL_GFPA(fun, str) do { \
72 ptr = SDL_GL_GetProcAddress(str); \
73 memcpy(&fun, &ptr, sizeof (void *)); \
76 /*---------------------------------------------------------------------------*/
84 if (glext_assert("ARB_multitexture"))
86 SDL_GL_GFPA(glClientActiveTexture_, "glClientActiveTextureARB");
87 SDL_GL_GFPA(glActiveTexture_, "glActiveTextureARB");
92 if (glext_assert("ARB_vertex_buffer_object"))
94 SDL_GL_GFPA(glGenBuffers_, "glGenBuffersARB");
95 SDL_GL_GFPA(glBindBuffer_, "glBindBufferARB");
96 SDL_GL_GFPA(glBufferData_, "glBufferDataARB");
97 SDL_GL_GFPA(glBufferSubData_, "glBufferSubDataARB");
98 SDL_GL_GFPA(glDeleteBuffers_, "glDeleteBuffersARB");
99 SDL_GL_GFPA(glIsBuffer_, "glIsBufferARB");
104 if (glext_assert("ARB_point_parameters"))
105 SDL_GL_GFPA(glPointParameterfv_, "glPointParameterfvARB");
118 /*---------------------------------------------------------------------------*/
120 void glClipPlane4f_(GLenum p, GLfloat a, GLfloat b, GLfloat c, GLfloat d)
147 /*---------------------------------------------------------------------------*/