Antkeeper  0.0.1
final-pass.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ANTKEEPER_RENDER_FINAL_PASS_HPP
21 #define ANTKEEPER_RENDER_FINAL_PASS_HPP
22 
23 #include <engine/render/pass.hpp>
29 #include <engine/gl/texture.hpp>
30 #include <functional>
31 #include <memory>
32 
33 class resource_manager;
34 
35 namespace render {
36 
40 class final_pass: public pass
41 {
42 public:
44  void render(render::context& ctx) override;
45 
46  void set_color_texture(std::shared_ptr<gl::texture_2d> texture);
47  void set_bloom_texture(std::shared_ptr<gl::texture_2d> texture) noexcept;
48  void set_bloom_weight(float weight) noexcept;
49  void set_blue_noise_texture(std::shared_ptr<gl::texture_2d> texture);
50 
51 private:
52  void rebuild_command_buffer();
53 
54  std::unique_ptr<gl::vertex_array> m_vertex_array;
55  std::unique_ptr<gl::shader_program> m_shader_program;
56 
57  std::shared_ptr<gl::texture_2d> m_color_texture{};
58  std::shared_ptr<gl::texture_2d> m_bloom_texture{};
59  float m_bloom_weight{0.04f};
60  std::shared_ptr<gl::texture_2d> m_blue_noise_texture;
61  float m_blue_noise_scale{1.0f};
62  math::fvec2 m_resolution{};
63  float m_time{};
64  int m_frame{};
65 
66  std::vector<std::function<void()>> m_command_buffer;
67 };
68 
69 } // namespace render
70 
71 #endif // ANTKEEPER_RENDER_FINAL_PASS_HPP
72 
Graphics pipeline interface.
Definition: pipeline.hpp:48
void set_color_texture(std::shared_ptr< gl::texture_2d > texture)
Definition: final-pass.cpp:73
void render(render::context &ctx) override
Definition: final-pass.cpp:54
void set_blue_noise_texture(std::shared_ptr< gl::texture_2d > texture)
Definition: final-pass.cpp:90
void set_bloom_weight(float weight) noexcept
Definition: final-pass.cpp:85
void set_bloom_texture(std::shared_ptr< gl::texture_2d > texture) noexcept
Definition: final-pass.cpp:79
final_pass(gl::pipeline *pipeline, const gl::framebuffer *framebuffer, resource_manager *resource_manager)
Definition: final-pass.cpp:38
Render pass.
Definition: pass.hpp:34
Manages the loading, caching, and saving of resources.
High-level rendering.
n-dimensional vector.
Definition: vector.hpp:44
Context of a renderer.
Definition: context.hpp:40