16 layout (location = 0) in vec2 l_pos;
17 layout (location = 1) in vec2 l_texels;
24 gl_Position = vec4(l_pos, 0.0, 1.0);
35 out vec4 io_frag_colour;
37 uniform sampler2D u_texture;
41 io_frag_colour = texture(u_texture, io_texels);
74 constexpr const std::array<float, 16> verticies =
77 -1.0f, 1.0f, 0.0f, 1.0f,
78 -1.0f, -1.0f, 0.0f, 0.0f,
79 1.0f, 1.0f, 1.0f, 1.0f,
80 1.0f, -1.0f, 1.0f, 0.0f
86 glBufferData(GL_ARRAY_BUFFER, verticies.size() *
sizeof(
float), verticies.data(), GL_STATIC_DRAW);
87 glEnableVertexAttribArray(0);
88 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 *
sizeof(
float),
nullptr);
89 glEnableVertexAttribArray(1);
91 constexpr const std::uint64_t size = 2 *
sizeof(float);
92 glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 *
sizeof(
float),
reinterpret_cast<void*
>(size));
95 glBindBuffer(GL_ARRAY_BUFFER, 0);
125 effect->resize(width, height);
148 if (effect->is_enabled())
160 glActiveTexture(GL_TEXTURE0);
162 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
constexpr const auto vao_vert
PostProcess.cpp galaxy.
constexpr const auto vao_frag
Plain VAO fragment shader.
void bind()
Bind to draw to post processor framebuffer.
RenderTexture m_fb
For geometry and lighting.
void destroy()
Cleanup used memory.
unsigned int m_screen_vao
Simple quad to draw when applying effects (array).
meta::vector< std::unique_ptr< graphics::PostEffect > > m_effects
List of effects to apply in order.
PostProcess()
Constructor.
~PostProcess()
Destructor.
void resize(const int width, const int height)
Resize framebuffers.
void render_effects()
Draw post effects to stored framebuffer.
Shader m_output
Simple output shader.
void render_output()
Draw finished post effects to default framebuffer (screen).
unsigned int m_output_fb
Output cache.
void unbind()
Unbind to draw to post processor framebuffer.
unsigned int m_screen_vbo
Simple quad to draw when applying effects (buffer).
void init(const int width, const int height)
Initialize post processor and GL buffers.
void unbind()
Deactivate context.
void create(const int width, const int height)
Create framebuffer and texture.
unsigned int texture() const
Gets framebuffer texture.
void recreate(const int width=-1, const int height=-1)
Destroy and re-create framebuffer.
void bind(bool clear=true)
Activate context.
bool parse(const std::string &src)
Loads a combined raw shader.
void compile()
Compiles shader into GPU mem.
void bind() const
Make active shader.