90 lines
2.3 KiB
C++
90 lines
2.3 KiB
C++
/**
|
|
This file is a part of our_dick
|
|
Copyright (C) 2022 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_RENDERER_HPP
|
|
#define OUR_DICK_RENDERER_HPP
|
|
|
|
#include <vector>
|
|
#include <variant>
|
|
#include <utility> //pair, forward
|
|
#include <queue>
|
|
|
|
#include "math/vec.hpp"
|
|
|
|
#include "graphics/gl_include.hpp"
|
|
|
|
struct draw_command{
|
|
private:
|
|
using uniform_variant = std::variant<GLint,GLuint,GLfloat,math::vec2f,math::vec3f,math::vec4f,math::mat2f,math::mat3f,math::mat4f>;
|
|
|
|
public:
|
|
using framebuffer_type = GLuint;
|
|
using shader_type = GLuint;
|
|
using vao_type = GLuint;
|
|
using uniform_type = GLint;
|
|
using uniform_block_type = GLuint;
|
|
using binding_type = GLuint;
|
|
using shape_type = GLenum;
|
|
using texture_type = GLuint;
|
|
|
|
public:
|
|
framebuffer_type framebuffer;
|
|
math::vec4f viewport;
|
|
|
|
shader_type shader;
|
|
vao_type vertex_arrays;
|
|
|
|
shape_type shape;
|
|
size_t shape_count;
|
|
|
|
std::vector<std::pair<uniform_type,uniform_variant>> uniforms;
|
|
std::vector<std::pair<uniform_block_type, binding_type>> uniform_blocks;
|
|
std::vector<std::pair<texture_type,binding_type>> texture_binds;
|
|
|
|
GLuint clear = 0;
|
|
};
|
|
|
|
class wip_renderer
|
|
{
|
|
private:
|
|
std::queue<draw_command> m_draws;
|
|
|
|
public:
|
|
wip_renderer(void) = default;
|
|
wip_renderer(const wip_renderer&) = default;
|
|
wip_renderer(wip_renderer&&) = default;
|
|
~wip_renderer(void) = default;
|
|
|
|
wip_renderer& operator=(const wip_renderer&) = default;
|
|
wip_renderer& operator=(wip_renderer&&) = default;
|
|
|
|
void add_command(const draw_command&);
|
|
void add_command(draw_command&&);
|
|
template<class... Args>
|
|
void emplace_command(Args&&... args);
|
|
|
|
void render(void);
|
|
};
|
|
|
|
template<class... Args>
|
|
void wip_renderer::emplace_command(Args&&... args){
|
|
m_draws.emplace(std::forward<Args>(args)...);
|
|
}
|
|
|
|
#endif
|