1 #ifndef MSP_GL_VERTEXSETUP_H_
2 #define MSP_GL_VERTEXSETUP_H_
5 #include "vertexformat.h"
6 #include "vertexsetup_backend.h"
15 Combines vertex and instance attributes and an index buffer for a complete
16 description of vertex input state.
18 Applications normally don't need to deal with VertexSetups directly. They're
19 managed by the Mesh and InstanceArray classes.
21 class VertexSetup: public VertexSetupBackend
23 friend VertexSetupBackend;
33 mutable unsigned dirty = 0;
34 const VertexArray *vertex_array = 0;
35 VertexFormat vertex_format;
36 const VertexArray *inst_array = 0;
37 VertexFormat inst_format;
38 const Buffer *index_buffer = 0;
39 DataType index_type = UNSIGNED_SHORT;
42 /** Sets format for vertex data. Instance attributes won't be used. The
43 format cannot be changed once set. */
44 void set_format(const VertexFormat &);
46 /** Sets formats for both vertex and instance data. The formats cannot be
48 void set_format_instanced(const VertexFormat &, const VertexFormat &);
50 /** Sets the VertexArray to use as the source of vertex attribute values.
51 The array's format must match the VertexSetup's vertex format. */
52 void set_vertex_array(const VertexArray &);
54 /** Sets the VertexArray to use as the source of instance attribute values.
55 An instance format must be defined and the array's format must match it. */
56 void set_instance_array(const VertexArray &);
58 /** Sets the buffer containing index data and the type of indices. */
59 void set_index_buffer(const Buffer &, DataType);
61 const VertexArray *get_vertex_array() const { return vertex_array; }
62 const VertexArray *get_instance_array() const { return inst_array; }
63 const Buffer *get_index_buffer() const { return index_buffer; }
64 DataType get_index_type() const { return index_type; }
67 static bool verify_format(const VertexFormat &);
71 void refresh() const { if(dirty) update(); }
75 using VertexSetupBackend::set_debug_name;