3 This file is part of libmspgl
4 Copyright © 2007, 2009-2010 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #ifndef MSP_GL_BATCH_H_
9 #define MSP_GL_BATCH_H_
12 #include <msp/datafile/objectloader.h>
14 #include "primitivetype.h"
22 Stores primitive type and element indices for a single GL draw call. Data
23 type for indices is automatically chosen to accommodate the largest index in
26 This is a pretty low-level class and mainly intended to be used by the Mesh
32 class Loader: public DataFile::ObjectLoader<Batch>
37 void indices(const std::vector<unsigned> &);
41 PrimitiveType prim_type;
43 std::vector<unsigned char> data;
53 static unsigned restart_index;
56 Batch(PrimitiveType t);
59 PrimitiveType get_type() const { return prim_type; }
60 void set_data_type(DataType);
61 DataType get_data_type() const { return data_type; }
62 void use_index_buffer(Buffer *, Batch * = 0);
63 Batch &append(unsigned);
64 void append(const std::vector<unsigned> &);
65 void append(const Batch &);
66 unsigned size() const { return data.size()/get_index_size(); }
67 unsigned get_index(unsigned) const;
71 unsigned get_index_size() const;
76 template<typename T, typename U>
79 template<typename T, typename U>
82 template<typename T, typename U>
85 void unlink_from_ibuf();
86 void update_ibuf_offsets();