78 lines
2.1 KiB
C++
78 lines
2.1 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/>.
|
|
*/
|
|
|
|
#ifndef OUR_DICK_GRAPHICS_MODEL_HPP
|
|
#define OUR_DICK_GRAPHICS_MODEL_HPP
|
|
|
|
#include "mesh.hpp"
|
|
#include "ogl/shader_program.hpp"
|
|
|
|
#include <vector>
|
|
#include <type_traits> //enable_if, decay, is_same
|
|
#include <utility> //forward, move
|
|
#include <cstdlib> //size_t
|
|
|
|
namespace gfx{
|
|
|
|
class model
|
|
{
|
|
protected:
|
|
std::vector<unified_mesh> m_meshes;
|
|
|
|
public:
|
|
model() = default;
|
|
template<typename... Args, std::enable_if_t<(std::is_same_v<std::decay_t<Args>,::gfx::unified_mesh> && ...),int> = 0>
|
|
model(Args&&... args);
|
|
model(std::vector<unified_mesh>&& meshes);
|
|
model(unified_mesh* meshes, size_t size);
|
|
model(const model&) = delete;
|
|
model(model&&) = default;
|
|
~model() = default;
|
|
|
|
model& operator=(const model&) = default;
|
|
model& operator=(model&&) = default;
|
|
|
|
void configure();
|
|
|
|
void add_mesh(unified_mesh&& m);
|
|
template<typename... Args>
|
|
void add_meshes(unified_mesh&& m, Args&&... args);
|
|
|
|
unified_mesh& mesh(size_t index);
|
|
const unified_mesh& mesh(size_t index)const;
|
|
|
|
void render(ogl::shader_program& s);
|
|
};
|
|
|
|
template<typename... Args, std::enable_if_t<(std::is_same_v<std::decay_t<Args>,::gfx::unified_mesh> && ...),int>>
|
|
model::model(Args&&... args){
|
|
m_meshes.reserve(sizeof...(args));
|
|
add_meshes(std::forward<Args>(args)...);
|
|
}
|
|
template<typename... Args>
|
|
void model::add_meshes(unified_mesh&& m, Args&&... args){
|
|
add_mesh(std::move(m));
|
|
if constexpr(sizeof...(args) > 0){
|
|
add_meshes(std::forward<Args>(args)...);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|