From 5bf78f891d679dc7304c9ffd471f2dee4a319bde Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Tue, 19 Feb 2013 03:17:05 -0400 Subject: [PATCH] Fixed OpenGL vertex buffer function usage (issue #489.) The functions will be assigned to their core version counterparts if the extension version isn't supported but the core version is. --- src/modules/graphics/opengl/OpenGL.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index 12ffdacb3..10afe3c9b 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -46,9 +46,8 @@ void initializeContext() contextInitialized = true; - textureUnits.clear(); - // initialize multiple texture unit support for shaders, if available + textureUnits.clear(); if (Shader::isSupported()) { GLint maxtextureunits; @@ -78,6 +77,24 @@ void initializeContext() glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *) &textureUnits[0]); } + // The functionality of the core and ARB VBOs are identical, so we can + // assign the pointers of the core functions to the names of the ARB + // functions, if the latter isn't supported but the former is. + if (GLEE_VERSION_1_5 && !GLEE_ARB_vertex_buffer_object) + { + glBindBufferARB = (GLEEPFNGLBINDBUFFERARBPROC) glBindBuffer; + glBufferDataARB = (GLEEPFNGLBUFFERDATAARBPROC) glBufferData; + glBufferSubDataARB = (GLEEPFNGLBUFFERSUBDATAARBPROC) glBufferSubData; + glDeleteBuffersARB = (GLEEPFNGLDELETEBUFFERSARBPROC) glDeleteBuffers; + glGenBuffersARB = (GLEEPFNGLGENBUFFERSARBPROC) glGenBuffers; + glGetBufferParameterivARB = (GLEEPFNGLGETBUFFERPARAMETERIVARBPROC) glGetBufferParameteriv; + glGetBufferPointervARB = (GLEEPFNGLGETBUFFERPOINTERVARBPROC) glGetBufferPointerv; + glGetBufferSubDataARB = (GLEEPFNGLGETBUFFERSUBDATAARBPROC) glGetBufferSubData; + glIsBufferARB = (GLEEPFNGLISBUFFERARBPROC) glIsBuffer; + glMapBufferARB = (GLEEPFNGLMAPBUFFERARBPROC) glMapBuffer; + glUnmapBufferARB = (GLEEPFNGLUNMAPBUFFERARBPROC) glUnmapBuffer; + } + // Set the 'default' texture (id 0) as a repeating white pixel. // Otherwise, texture2D inside a shader would return black when drawing graphics primitives, // which would create the need to use different "passthrough" shaders for untextured primitives vs images.