diff --git a/src/noggit/rendering/ModelRender.cpp b/src/noggit/rendering/ModelRender.cpp index f58dc22b..7c31f8bc 100755 --- a/src/noggit/rendering/ModelRender.cpp +++ b/src/noggit/rendering/ModelRender.cpp @@ -108,6 +108,21 @@ void ModelRender::draw(glm::mat4x4 const& model_view if (!_uploaded) { upload(); + + OpenGL::Scoped::vao_binder const _(_vao); + + { + OpenGL::Scoped::buffer_binder 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 (sizeof(::glm::vec3) + 8)); + m2_shader.attrib("texcoord1", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast (sizeof(::glm::vec3) * 2 + 8)); + m2_shader.attrib("texcoord2", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast (sizeof(::glm::vec3) * 2 + 8 + sizeof(glm::vec2))); + } + + { + OpenGL::Scoped::buffer_binder const transform_binder(_transform_buffer); + m2_shader.uniform("transform", instance.transformMatrix()); + } } if (_model->animated && (!_model->animcalc || _model->_per_instance_animation)) @@ -116,20 +131,6 @@ void ModelRender::draw(glm::mat4x4 const& model_view _model->animcalc = true; } - OpenGL::Scoped::vao_binder const _(_vao); - - m2_shader.uniform("transform", instance.transformMatrix()); - - { - OpenGL::Scoped::buffer_binder 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 (sizeof (::glm::vec3))); - m2_shader.attrib("bones_indices", 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof (ModelVertex), reinterpret_cast (sizeof (::glm::vec3) + 4)); - m2_shader.attrib("normal", 3, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast (sizeof(::glm::vec3) + 8)); - m2_shader.attrib("texcoord1", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast (sizeof(::glm::vec3) * 2 + 8)); - m2_shader.attrib("texcoord2", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast (sizeof(::glm::vec3) * 2 + 8 + sizeof(glm::vec2))); - } - OpenGL::Scoped::buffer_binder indices_binder(_indices_buffer); for (ModelRenderPass& p : _render_passes)