Files
our_dick/include/screen_renderer.hpp
2022-01-10 10:35:33 -08:00

60 lines
1.7 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_SCREEN_RENDERER_HPP
#define OUR_DICK_SCREEN_RENDERER_HPP
#include "graphics/vbo.hpp"
#include "graphics/vao.hpp"
#include "graphics/texture.hpp"
#include "math/math.hpp"
#include "graphics/shader_program.hpp"
#include "engine/resource_manager.hpp"
#include "scene.hpp"
class screen_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:
gfx::shader_program* m_screen_shader;
gfx::vbo m_vbo;
gfx::vao m_vao;
gfx::texture* m_texture;
int m_screen_width, m_screen_height;
public:
screen_renderer(egn::resource_manager& res, int width, int height, gfx::texture& base_tex);
void render(scene&);
void resize_viewport(int width, int height);
};
#endif