Added ubo class template for handling Uniform Buffer Objects. This class automatically finds the offset and alignment for given data in a GLSL std140 uniform block. This makes it easy to just assign data through the gfx::ubo interface and bind that to the relevant shader_program's uniform block Changed shader_program's method of handling uniforms to match more closely to how vao handles its attributes. That is to call with the location as argument to get a proxy object on which to operate. I find this nicer to work with than having everything to do with uniforms in the shader_program class itself Add a flat_camera class which just assigns the near and far plane to 0 and 1 respectively Start work on a gui system which i'm really not confident about. Attempting to rethink how renderers work, but also no really confident about where i'm going with it Break out vbo_scoped_map into a more general scoped_buffer_map class so that vbo and ubo can utilize it Remove old gl_buffers units that were not really being used since my change over to opengl DSA functions Change the gfx::resource_manager to keep shared_ptr's in the container so the data can be more nicely shared Add missing aliases in math::fwd_declare.hpp for boolean types Change orthographic projection generator function to have the z values behave more in line with how opengl handles z depth. May have to undo this at some point but it seems to behave correctly now Fix some rvalue related aspects of util::deferred '
70 lines
1.9 KiB
C++
70 lines
1.9 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_ENGINE_MENU_RENDERER_HPP
|
|
#define OUR_DICK_ENGINE_MENU_RENDERER_HPP
|
|
|
|
#include "math/vec.hpp"
|
|
|
|
#include "graphics/resource_manager.hpp"
|
|
#include "graphics/shader_program.hpp"
|
|
#include "graphics/fbo.hpp"
|
|
#include "graphics/ubo.hpp"
|
|
|
|
namespace egn{
|
|
|
|
class renderer
|
|
{
|
|
private:
|
|
math::vec4f m_saved_viewport{0, 0, 0, 0};
|
|
|
|
public:
|
|
void set_viewport(float x, float y, float w, float h);
|
|
void resize_viewport(float w, float h);
|
|
void reposition_viewport(float x, float y);
|
|
void apply_viewport(void);
|
|
};
|
|
|
|
class menu_renderer : public renderer
|
|
{
|
|
private:
|
|
gfx::ubo<math::mat4f> m_vp_matrix;
|
|
std::shared_ptr<gfx::shader_program> m_font_shader;
|
|
public:
|
|
menu_renderer(gfx::resource_manager& resman);
|
|
menu_renderer(const menu_renderer&) = default;
|
|
menu_renderer(menu_renderer&&) = default;
|
|
~menu_renderer(void) = default;
|
|
|
|
menu_renderer& operator=(const menu_renderer&) = default;
|
|
menu_renderer& operator=(menu_renderer&&) = default;
|
|
|
|
void set_font(const gfx::texture& atlas);
|
|
void set_position(const math::vec2f& pos);
|
|
void set_vp_matrix(const math::mat4f& matrix);
|
|
|
|
void begin(void);
|
|
void draw_text(int count);
|
|
void draw_text_to(gfx::fbo& target, int count);
|
|
void end(void);
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|