mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 05:49:19 +02:00
work
This commit is contained in:
@@ -31,7 +31,8 @@ void gl::framebuffer::attach(const renderbuffer &rb, GLenum location)
|
||||
bool gl::framebuffer::is_complete()
|
||||
{
|
||||
bind();
|
||||
return glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE;
|
||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
return status == GL_FRAMEBUFFER_COMPLETE;
|
||||
}
|
||||
|
||||
void gl::framebuffer::clear()
|
||||
|
||||
40
gl/postfx.cpp
Normal file
40
gl/postfx.cpp
Normal 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);
|
||||
}
|
||||
22
gl/postfx.h
Normal file
22
gl/postfx.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "shader.h"
|
||||
#include "vao.h"
|
||||
#include "framebuffer.h"
|
||||
#include "Texture.h"
|
||||
|
||||
namespace gl
|
||||
{
|
||||
class postfx
|
||||
{
|
||||
private:
|
||||
gl::program program;
|
||||
static std::shared_ptr<gl::shader> vertex;
|
||||
static std::shared_ptr<gl::vao> vao;
|
||||
|
||||
public:
|
||||
postfx(const std::string &s);
|
||||
postfx(const shader &s);
|
||||
void apply(opengl_texture &src, framebuffer *dst);
|
||||
};
|
||||
}
|
||||
@@ -104,6 +104,8 @@ void gl::program::init()
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
glUniform1i(glGetUniformLocation(*this, "shadowmap"), 10); //m7t: do something better
|
||||
}
|
||||
|
||||
gl::program::program()
|
||||
|
||||
Reference in New Issue
Block a user