1 #ifndef MSP_GL_BATCH_H_
2 #define MSP_GL_BATCH_H_
5 #include <msp/datafile/objectloader.h>
6 #include "bufferable.h"
8 #include "primitivetype.h"
16 Stores primitive type and element indices for a single GL draw call. Data
17 type for indices is automatically chosen to accommodate the largest index in
20 This is a pretty low-level class and mainly intended to be used by the Mesh
23 class Batch: public Bufferable
26 class Loader: public DataFile::ObjectLoader<Batch>
31 void indices(const std::vector<unsigned> &);
35 PrimitiveType prim_type;
37 std::vector<UInt8> data;
41 static unsigned restart_index;
44 Batch(PrimitiveType t);
47 PrimitiveType get_type() const { return prim_type; }
48 void set_index_type(DataType);
49 DataType get_index_type() const { return index_type; }
51 DEPRECATED void set_data_type(DataType t) { set_index_type(t); }
52 DEPRECATED DataType get_data_type() const { return index_type; }
54 Batch &append(unsigned);
55 Batch &append(const std::vector<unsigned> &);
56 bool can_append(PrimitiveType);
57 Batch &append(const Batch &);
59 void append_index(unsigned);
60 virtual unsigned get_data_size() const { return data.size(); }
61 virtual const void *get_data_pointer() const { return &data[0]; }
62 virtual unsigned get_alignment() const { return get_index_size(); }
63 unsigned get_index_size() const;
65 unsigned size() const { return data.size()/get_index_size(); }
67 unsigned get_index(unsigned) const;
70 void draw_instanced(unsigned) const;
72 const void *setup_draw() const;
73 static void set_restart_index(unsigned);