69 lines
1.9 KiB
C++
69 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 "math/math.hpp"
|
|
#include "scene.hpp"
|
|
#include "gfx/resource_manager.hpp"
|
|
#include "basic_framebuffer.hpp"
|
|
|
|
#include <memory> //shared_ptr
|
|
|
|
class main_renderer
|
|
{
|
|
private:
|
|
struct vertex{
|
|
math::vec2<GLfloat> pos;
|
|
math::vec2<GLfloat> 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(gfx::resource_manager& res, int width, int height);
|
|
|
|
void set_vp_matrix(const math::mat4<GLfloat>& vp);
|
|
void render(scene&);
|
|
gfx::ogl::texture& color_buffer(void);
|
|
void resize_viewport(int width, int height);
|
|
const math::vec4<GLfloat>& get_viewport(void)const;
|
|
};
|
|
|
|
|
|
#endif
|