@@ -108,6 +108,21 @@ void ModelRender::draw(glm::mat4x4 const& model_view
|
|||||||
if (!_uploaded)
|
if (!_uploaded)
|
||||||
{
|
{
|
||||||
upload();
|
upload();
|
||||||
|
|
||||||
|
OpenGL::Scoped::vao_binder const _(_vao);
|
||||||
|
|
||||||
|
{
|
||||||
|
OpenGL::Scoped::buffer_binder<GL_ARRAY_BUFFER> const binder(_vertices_buffer);
|
||||||
|
m2_shader.attrib("pos", 3, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), 0);
|
||||||
|
m2_shader.attrib("normal", 3, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::glm::vec3) + 8));
|
||||||
|
m2_shader.attrib("texcoord1", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::glm::vec3) * 2 + 8));
|
||||||
|
m2_shader.attrib("texcoord2", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::glm::vec3) * 2 + 8 + sizeof(glm::vec2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
OpenGL::Scoped::buffer_binder<GL_ARRAY_BUFFER> const transform_binder(_transform_buffer);
|
||||||
|
m2_shader.uniform("transform", instance.transformMatrix());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_model->animated && (!_model->animcalc || _model->_per_instance_animation))
|
if (_model->animated && (!_model->animcalc || _model->_per_instance_animation))
|
||||||
@@ -116,20 +131,6 @@ void ModelRender::draw(glm::mat4x4 const& model_view
|
|||||||
_model->animcalc = true;
|
_model->animcalc = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenGL::Scoped::vao_binder const _(_vao);
|
|
||||||
|
|
||||||
m2_shader.uniform("transform", instance.transformMatrix());
|
|
||||||
|
|
||||||
{
|
|
||||||
OpenGL::Scoped::buffer_binder<GL_ARRAY_BUFFER> const binder(_vertices_buffer);
|
|
||||||
m2_shader.attrib("pos", 3, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), 0);
|
|
||||||
m2_shader.attrib("bones_weight", 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::glm::vec3)));
|
|
||||||
m2_shader.attrib("bones_indices", 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::glm::vec3) + 4));
|
|
||||||
m2_shader.attrib("normal", 3, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::glm::vec3) + 8));
|
|
||||||
m2_shader.attrib("texcoord1", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::glm::vec3) * 2 + 8));
|
|
||||||
m2_shader.attrib("texcoord2", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::glm::vec3) * 2 + 8 + sizeof(glm::vec2)));
|
|
||||||
}
|
|
||||||
|
|
||||||
OpenGL::Scoped::buffer_binder<GL_ELEMENT_ARRAY_BUFFER> indices_binder(_indices_buffer);
|
OpenGL::Scoped::buffer_binder<GL_ELEMENT_ARRAY_BUFFER> indices_binder(_indices_buffer);
|
||||||
|
|
||||||
for (ModelRenderPass& p : _render_passes)
|
for (ModelRenderPass& p : _render_passes)
|
||||||
|
|||||||
Reference in New Issue
Block a user