ibuf = new Buffer;
if(!batches.empty())
batches.front().change_buffer(ibuf);
- vtx_setup.set_index_buffer(*ibuf);
dirty |= INDEX_BUFFER;
#ifdef DEBUG
vbuf->set_debug_name(debug_name+" [IBO]");
#endif
}
+
+ if(!batches.empty())
+ vtx_setup.set_index_buffer(*ibuf, batches.front().get_index_type());
}
}
dirty(0),
vertex_array(0),
inst_array(0),
- index_buffer(0)
+ index_buffer(0),
+ index_type(UNSIGNED_SHORT)
{
static Require req(ARB_vertex_array_object);
if(ARB_direct_state_access)
dirty |= INSTANCE_ARRAY;
}
-void VertexSetup::set_index_buffer(const Buffer &ibuf)
+void VertexSetup::set_index_buffer(const Buffer &ibuf, DataType itype)
{
index_buffer = &ibuf;
+ index_type = itype;
dirty |= INDEX_BUFFER;
}
#ifndef MSP_GL_VERTEXSETUP_H_
#define MSP_GL_VERTEXSETUP_H_
+#include "datatype.h"
#include "vertexformat.h"
namespace Msp {
const VertexArray *inst_array;
VertexFormat inst_format;
const Buffer *index_buffer;
+ DataType index_type;
public:
VertexSetup();
void set_vertex_array(const VertexArray &);
void set_instance_array(const VertexArray &);
- void set_index_buffer(const Buffer &);
+ void set_index_buffer(const Buffer &, DataType);
const VertexArray *get_vertex_array() const { return vertex_array; }
const VertexArray *get_instance_array() const { return inst_array; }
const Buffer *get_index_buffer() const { return index_buffer; }
+ DataType get_index_type() const { return index_type; }
private:
static bool verify_format(const VertexFormat &);
instance_buffer = new Buffer;
instance_data->use_buffer(instance_buffer);
+ const Mesh *mesh = object.get_mesh();
+
vtx_setup = new VertexSetup;
- vtx_setup->set_format_instanced(object.get_mesh()->get_vertices().get_format(), fmt);
- vtx_setup->set_vertex_array(object.get_mesh()->get_vertices());
- vtx_setup->set_index_buffer(*object.get_mesh()->get_index_buffer());
+ vtx_setup->set_format_instanced(mesh->get_vertices().get_format(), fmt);
+ vtx_setup->set_vertex_array(mesh->get_vertices());
+ vtx_setup->set_index_buffer(*mesh->get_index_buffer(), mesh->get_batches().front().get_index_type());
vtx_setup->set_instance_array(*instance_data);
}
else