FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
C_renderTexture.hpp
1/*
2 * Copyright 2024 Guillaume Guillet
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _FGE_GRAPHIC_C_RENDERTEXTURE_HPP_INCLUDED
18#define _FGE_GRAPHIC_C_RENDERTEXTURE_HPP_INCLUDED
19
20/*
21 * Original from : https://github.com/SFML/SFML
22 * Copyright (C) 2007-2022 Laurent Gomila
23 *
24 * Altered/Modified by Guillaume Guillet
25 */
26
27#include "FastEngine/fge_extern.hpp"
28#include "FastEngine/graphic/C_renderTarget.hpp"
29#include "FastEngine/vulkan/C_descriptorSet.hpp"
30#include "FastEngine/vulkan/C_descriptorSetLayout.hpp"
31#include "FastEngine/vulkan/C_swapChain.hpp"
32#include "FastEngine/vulkan/C_textureImage.hpp"
33#include "FastEngine/vulkan/C_uniformBuffer.hpp"
34#include <array>
35#include <string>
36
37namespace fge
38{
39
40class FGE_API RenderTexture : public RenderTarget
41{
42public:
43 explicit RenderTexture(glm::vec<2, int> const& size = {1, 1},
44 fge::vulkan::Context const& context = fge::vulkan::GetActiveContext());
46 RenderTexture(RenderTexture&& r) noexcept;
47 ~RenderTexture() override;
48
49 RenderTexture& operator=(RenderTexture const& r);
50 RenderTexture& operator=(RenderTexture&& r) noexcept;
51
52 void resize(glm::vec<2, int> const& size);
53 void destroy() final;
54
55 uint32_t prepareNextFrame(VkCommandBufferInheritanceInfo const* inheritanceInfo, uint64_t timeout_ns) override;
56 void beginRenderPass(uint32_t imageIndex) override;
57 void endRenderPass() override;
58 void display(uint32_t imageIndex) override;
59
60 Vector2u getSize() const override;
61
62 [[nodiscard]] VkExtent2D getExtent2D() const override;
63 [[nodiscard]] fge::vulkan::CommandBuffer& getCommandBuffer() const override;
64 [[nodiscard]] VkRenderPass getRenderPass() const override;
65
66 [[nodiscard]] fge::vulkan::TextureImage const& getTextureImage() const;
67
68 [[nodiscard]] uint32_t getCurrentFrame() const;
69
70private:
71 void init(glm::vec<2, int> const& size);
72
73 void createRenderPass();
74 void createFramebuffer();
75
76 fge::vulkan::TextureImage g_textureImage;
77
78 VkRenderPass g_renderPass;
79
80 VkFramebuffer g_framebuffer;
81
82 mutable std::array<fge::vulkan::CommandBuffer, FGE_MAX_FRAMES_IN_FLIGHT> g_commandBuffers;
83
84 uint32_t g_currentFrame;
85
86 bool g_isCreated;
87};
88
89} // namespace fge
90
91
92#endif // _FGE_GRAPHIC_C_RENDERTEXTURE_HPP_INCLUDED
Definition C_renderTarget.hpp:56
Definition C_renderTexture.hpp:41
Vulkan command buffer wrapper.
Definition C_commandBuffer.hpp:36
Vulkan context.
Definition C_context.hpp:70
Definition C_textureImage.hpp:34