17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-18 00:59:18 +02:00
Files
maszyna/gl/postfx.cpp
maj00r b8f040e6fd propagate template headers transitively, import Console where used
AnimModel.cpp reaches cParser through the simulation core, not a direct
import, so the previous pass missed it; the propagation now follows the
whole import closure. Train.cpp, drivermode.cpp and Globals.cpp call
Console:: inside _WIN32 guards without importing eu07.console - invisible
on Linux, where those blocks are skipped.
2026-09-10 01:41:24 +02:00

67 lines
1.3 KiB
C++

module;
#include <array>
#include <chrono>
#include <deque>
#include <limits>
#include <mutex>
#include <ostream>
#include <sstream>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <cstddef>
#include <string>
#include "glad/glad.h"
#include <vector>
#include <memory>
module eu07.gl.postfx;
import eu07.gl.framebuffer;
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>("quad.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)
{
apply({&src}, dst);
}
void gl::postfx::apply(std::vector<opengl_texture *> src, framebuffer *dst)
{
if (dst)
{
dst->clear(GL_COLOR_BUFFER_BIT);
dst->bind();
}
else
framebuffer::unbind();
program.bind();
vao->bind();
size_t unit = 0;
for (opengl_texture *tex : src)
tex->bind(unit++);
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}