our_dick/include/screen_renderer.hpp
2020-10-11 12:36:05 -07:00

59 lines
1.6 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_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 "screen_shader.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:
screen_shader m_screen_shader;
gfx::vbo m_vbo;
gfx::vao m_vao;
gfx::weak_texture_handle m_texture;
int m_screen_width, m_screen_height;
public:
screen_renderer(int width, int height, gfx::texture& base_tex);
void render(scene&);
void resize_viewport(int width, int height);
};
#endif