]> git.tdb.fi Git - libs/gl.git/blobdiff - source/vertexarray.cpp
Use RAII checks for extensions and versions
[libs/gl.git] / source / vertexarray.cpp
index 81a2acd5182a413777c39f0ebe944fe617b79b22..3c17141cfb59a592264505c7c67956cc5a9fd355 100644 (file)
@@ -5,7 +5,9 @@ Copyright © 2007  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
+#include "extension.h"
 #include "gl.h"
+#include "version_1_2.h"
 #include "vertexarray.h"
 #include "vertexbuffer.h"
 
@@ -71,11 +73,6 @@ void VertexArray::reset(VertexFormat f)
        stride=get_stride(format);
 }
 
-RefPtr<VertexArrayBuilder> VertexArray::modify()
-{
-       return new VertexArrayBuilder(*this);
-}
-
 void VertexArray::apply() const
 {
        if(format==NODATA)
@@ -134,6 +131,12 @@ void VertexArray::update_data()
        }
 }
 
+float *VertexArray::append()
+{
+       data.insert(data.end(), stride, 0.0f);
+       return &*data.end()-stride;
+}
+
 void VertexArray::set_array(unsigned array, unsigned bit, unsigned mask) const
 {
        if((enabled_arrays&mask) && !bit)
@@ -166,5 +169,27 @@ VertexArray::Loader::Loader(VertexArray &a):
        add("color4",    static_cast<void (Loader::*)(float, float, float, float)>(&Loader::color));
 }
 
+
+void array_element(int i)
+{
+       glArrayElement(i);
+}
+
+void draw_arrays(PrimitiveType mode, int first, sizei count)
+{
+       glDrawArrays(mode, first, count);
+}
+
+void draw_elements(PrimitiveType mode, sizei count, DataType type, const void *indices)
+{
+       glDrawElements(mode, count, type, indices);
+}
+
+void draw_range_elements(PrimitiveType mode, uint low, uint high, sizei count, DataType type, const void *indices)
+{
+       static RequireVersion _ver(1, 2);
+       glDrawRangeElements(mode, low, high, count, type, indices);
+}
+
 } // namespace GL
 } // namespace Msp