]> git.tdb.fi Git - libs/gl.git/blobdiff - source/vertexbuffer.cpp
Windows compatibility:
[libs/gl.git] / source / vertexbuffer.cpp
index 4385c2f10b0ae18f0253ffe0883ca68a111b9ce6..e3680811dd9a8ccb59e1fb0e0b1f5b84b53ac6e3 100644 (file)
@@ -1,7 +1,12 @@
-#define GL_GLEXT_PROTOTYPES
-#include <GL/gl.h>
-//XXX gl.h seems to include glext.h, but can I rely on this?
-//#include <GL/glext.h>
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2007  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#include "arb_vertex_buffer_object.h"
+#include "extension.h"
 #include "vertexbuffer.h"
 
 namespace Msp {
@@ -9,12 +14,14 @@ namespace GL {
 
 VertexBuffer::VertexBuffer()
 {
-       glGenBuffers(1, &id);
+       require_extension("GL_ARB_vertex_buffer_object");
+
+       glGenBuffersARB(1, &id);
 }
 
 void VertexBuffer::bind() const
 {
-       glBindBuffer(GL_ARRAY_BUFFER, id);
+       glBindBufferARB(GL_ARRAY_BUFFER, id);
        bound=this;
 }
 
@@ -22,12 +29,21 @@ void VertexBuffer::data(sizei size, void *d)
 {
        if(bound!=this) bind();
 
-       glBufferData(GL_ARRAY_BUFFER, size, d, GL_STATIC_DRAW);
+       glBufferDataARB(GL_ARRAY_BUFFER, size, d, GL_STATIC_DRAW);
 }
 
 VertexBuffer::~VertexBuffer()
 {
-       glDeleteBuffers(1, &id);
+       glDeleteBuffersARB(1, &id);
+}
+
+void VertexBuffer::unbind()
+{
+       if(bound)
+       {
+               glBindBufferARB(GL_ARRAY_BUFFER, 0);
+               bound=0;
+       }
 }
 
 const VertexBuffer *VertexBuffer::bound=0;