our_dick/include/ttt/main_renderer.hpp

72 lines
1.9 KiB
C++

/**
This file is a part of our_dick
Copyright (C) 2020-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_MAIN_RENDERER_HPP
#define OUR_DICK_MAIN_RENDERER_HPP
#include "gfx/ogl/shader_program.hpp"
#include "gfx/ogl/vao.hpp"
#include "gfx/ogl/vbo.hpp"
#include <rml/math.hpp>
#include "basic_framebuffer.hpp"
#include "wip/renderer.hpp"
#include <memory> //shared_ptr
//TODO remove this file
class scene{};
class main_renderer
{
private:
struct vertex{
rml::vec2f pos;
rml::vec2f tex_coord;
};
static constexpr vertex s_vertices[] = {
{{-1.0f, 1.0f}, {0.0f, 1.0f}},
{{-1.0f, -1.0f}, {0.0f, 0.0f}},
{{ 1.0f, -1.0f}, {1.0f, 0.0f}},
{{ 1.0f, -1.0f}, {1.0f, 0.0f}},
{{ 1.0f, 1.0f}, {1.0f, 1.0f}},
{{-1.0f, 1.0f}, {0.0f, 1.0f}}
};
private:
basic_framebuffer m_fb;
gfx::ogl::fbo m_primary_fb;
std::shared_ptr<gfx::ogl::shader_program> m_square_shader;
std::shared_ptr<gfx::ogl::shader_program> m_screen_shader;
gfx::ogl::vbo m_vbo;
gfx::ogl::vao m_vao;
gfx::ogl::vao m_board_vao;
gfx::ogl::vbo m_board_vbo;
public:
main_renderer(wip::gfx::renderer& res, int width, int height);
void set_vp_matrix(const rml::mat4f& vp);
void render(scene&);
gfx::ogl::texture& color_buffer(void);
void resize_viewport(int width, int height);
const rml::vec4f& get_viewport(void)const;
};
#endif