X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuilders%2Fprimitivebuilder.h;fp=source%2Fbuilders%2Fprimitivebuilder.h;h=0ffd170cd3e82659cef26528b0bfaf341f2d634e;hb=7aaec9a70b8d7733429bec043f8e33e02956f266;hp=0000000000000000000000000000000000000000;hpb=bec07999d95b76f4b47cffcc564d0cd0afc0435e;p=libs%2Fgl.git diff --git a/source/builders/primitivebuilder.h b/source/builders/primitivebuilder.h new file mode 100644 index 00000000..0ffd170c --- /dev/null +++ b/source/builders/primitivebuilder.h @@ -0,0 +1,45 @@ +#ifndef MSP_GL_PRIMITIVEBUILDER_H_ +#define MSP_GL_PRIMITIVEBUILDER_H_ + +#include "primitivetype.h" +#include "vertexarray.h" +#include "vertexbuilder.h" + +namespace Msp { +namespace GL { + +class VertexArray; +class VertexArrayBuilder; + +/** +Base class for primitive builders. This is derived from VertexBuilder and adds +begin() and end() functions for specifying batches of primitives instead of +just vertices. +*/ +class PrimitiveBuilder: public VertexBuilder +{ +protected: + VertexArray &array; + VertexArrayBuilder vab; + PrimitiveType type; + bool in_batch; + unsigned offs; + + PrimitiveBuilder(VertexArray &); +public: + void begin(PrimitiveType); + void end(); + void offset(unsigned); + void element(unsigned); + PrimitiveType get_type() const; +protected: + virtual void vertex_(const Vector4 &); + virtual void begin_() = 0; + virtual void end_() = 0; + virtual void element_(unsigned) = 0; +}; + +} // namespace GL +} // namespace Msp + +#endif