Fixed a build problem.
[gljewel.git] / vbo.c
blobd8b2ebbc6b2de2301f154f452befbcc50e339826
1 /**
2 * @file vbo.h
3 * @brief A wrapper around the Vertex Buffer extension to OpenGL 1.1.
5 * Copyright 2008 Stephen M. Webb <stephen.webb@bregmasoft.ca>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of Version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "vbo.h"
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
27 void initGlVboExtension(void)
29 #ifndef HAVE_GL_VERTEX_BUFFERS
30 int found = 0;
31 char* extensions = glGetString(GL_EXTENSIONS);
32 char* terminator = NULL;
33 for(;;)
35 char* where = (char*)strstr(extensions, "GL_ARB_vertex_buffer_object");
36 if (!where) break;
37 terminator = where + strlen("GL_ARB_vertex_buffer_object");
38 if (where == extensions || *(where - 1) == ' ')
40 if (*terminator == ' ' || *terminator == '\0')
42 found = 1;
43 break;
46 extensions = terminator;
49 if (!found)
51 fprintf(stderr, "OpenGL vertex buffer extension is not supported.\n");
52 exit(1);
56 glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffersARB");
57 glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffersARB");
58 glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBufferARB");
59 glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferDataARB");
60 /* glBufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubDataARB"); */
61 #endif