1 #ifndef MSP_GL_BATCH_H_
2 #define MSP_GL_BATCH_H_
5 #include <msp/datafile/objectloader.h>
6 #include "batch_backend.h"
7 #include "bufferable.h"
9 #include "primitivetype.h"
17 Stores primitive type and element indices for a single GL draw call. Data
18 type for indices is automatically chosen to accommodate the largest index in
21 This is a pretty low-level class and mainly intended to be used by the Mesh
24 class Batch: public BatchBackend, public Bufferable
27 class Loader: public DataFile::ObjectLoader<Batch>
32 void indices(const std::vector<unsigned> &);
36 PrimitiveType prim_type;
38 std::vector<std::uint8_t> data;
42 Batch(PrimitiveType t);
45 PrimitiveType get_type() const { return prim_type; }
46 void set_index_type(DataType);
47 DataType get_index_type() const { return index_type; }
49 Batch &append(unsigned);
50 Batch &append(const std::vector<unsigned> &);
51 bool can_append(PrimitiveType);
52 Batch &append(const Batch &);
54 void append_index(unsigned);
55 virtual unsigned get_data_size() const { return data.size(); }
56 virtual const void *get_data_pointer() const { return &data[0]; }
57 virtual unsigned get_alignment() const { return get_index_size(); }
58 unsigned get_index_size() const;
60 unsigned size() const { return data.size()/get_index_size(); }
62 unsigned get_index(unsigned) const;