]> git.tdb.fi Git - libs/gl.git/blobdiff - source/immediate.h
Move VertexFormat and VertexArrayBuilder to their own files
[libs/gl.git] / source / immediate.h
diff --git a/source/immediate.h b/source/immediate.h
new file mode 100644 (file)
index 0000000..b979973
--- /dev/null
@@ -0,0 +1,44 @@
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2007  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef MSP_GL_IMMEDIATE_H_
+#define MSP_GL_IMMEDIATE_H_
+
+#include "primitivetype.h"
+#include "vertexarray.h"
+#include "vertexbuilder.h"
+
+namespace Msp {
+namespace GL {
+
+/**
+Draws primitives on the screen.  This works similarly to the OpenGL immediate
+mode: call begin() to start a batch of primitives, specify vertices, and call
+end() to terminate the batch.  However, unlike OpenGL immediate mode, vertices
+are not drawn as they are specified.  Instead, they are accumulated in a
+VertexArray and drawn when end() is called.
+*/
+class Immediate: public VertexBuilder
+{
+public:
+       Immediate(VertexFormat);
+       void begin(PrimitiveType);
+       void end();
+private:
+       VertexArray array;
+       RefPtr<VertexArrayBuilder> builder;
+       PrimitiveType type;
+       bool in_batch;
+       unsigned n_vertices;
+
+       virtual void vertex_(float, float, float, float);
+};
+
+} // namespace GL
+} // namespace Msp
+
+#endif