#pragma once /* * Copyright (C) 2024 Brett Terpstra * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef BLT_GRAPHICS_POST_PROCESS_H #define BLT_GRAPHICS_POST_PROCESS_H #include #include #include #include #include #include namespace blt::gfx { class pp_engine_t; class pp_step_t; class pp_step_t { public: virtual void create() = 0; virtual void draw() = 0; frame_buffer_t& getBuffer() { return draw_buffer; } shader_t& getShader() { return *shader; } virtual ~pp_step_t() = default; protected: frame_buffer_t draw_buffer; std::unique_ptr shader; }; class pp_render_target_t : public pp_step_t { public: void create() override; void draw() override; }; class pp_to_screen_step_t : public pp_step_t { public: void create() override; void draw() override; }; class pp_engine_t { public: void create(); void bind(); void render(); void cleanup(); void addStep(std::unique_ptr step) { steps.emplace_back(std::move(step)); } static std::unique_ptr createShader(std::string_view fragment); private: std::vector> steps; std::unique_ptr screen_vao; #ifdef __EMSCRIPTEN__ std::unique_ptr to_screen; #endif }; } #endif //BLT_GRAPHICS_POST_PROCESS_H