16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 11:19:19 +02:00
This commit is contained in:
milek7
2018-07-11 12:16:46 +02:00
parent 94712f5c77
commit e53b4fba26
6 changed files with 291 additions and 13 deletions

40
gl/postfx.cpp Normal file
View File

@@ -0,0 +1,40 @@
#include "stdafx.h"
#include "postfx.h"
std::shared_ptr<gl::shader> gl::postfx::vertex;
std::shared_ptr<gl::vao> gl::postfx::vao;
gl::postfx::postfx(const std::string &s) : postfx(shader("postfx_" + s + ".frag"))
{
}
gl::postfx::postfx(const shader &s)
{
if (!vertex)
vertex = std::make_shared<gl::shader>("postfx.vert");
if (!vao)
vao = std::make_shared<gl::vao>();
program.attach(*vertex);
program.attach(s);
program.link();
}
void gl::postfx::apply(opengl_texture &src, framebuffer *dst)
{
if (dst)
{
dst->clear();
dst->bind();
}
else
framebuffer::unbind();
program.bind();
vao->bind();
glActiveTexture(GL_TEXTURE0);
src.bind();
glDisable(GL_DEPTH_TEST);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}