our_dick/src/graphics/model.cpp
2020-10-11 12:36:05 -07:00

54 lines
1.5 KiB
C++

/**
This file is a part of our_dick
Copyright (C) 2020 rexy712
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "graphics/model.hpp"
#include <utility> //move
namespace gfx{
model::model(std::vector<unified_mesh>&& meshes):
m_meshes(std::move(meshes)){}
model::model(unified_mesh* meshes, size_t size){
m_meshes.reserve(size);
for(size_t i = 0;i < size;++i){
m_meshes.push_back(std::move(meshes[i]));
}
}
void model::configure(){
for(size_t i = 0;i < m_meshes.size();++i){
m_meshes[i].configure();
}
}
void model::add_mesh(unified_mesh&& m){
m_meshes.push_back(std::move(m));
}
unified_mesh& model::mesh(size_t index){
return m_meshes[index];
}
const unified_mesh& model::mesh(size_t index)const{
return m_meshes[index];
}
void model::render(shader_program& s){
for(size_t i = 0;i < m_meshes.size();++i){
m_meshes[i].render(s);
}
}
}