Graphics: Add RenderTexture class
This commit is contained in:
committed by
Jérôme Leclercq
parent
4f08d0b3c1
commit
aaf3d97954
@@ -28,9 +28,6 @@ namespace Nz
|
||||
|
||||
virtual void BlitTexture(RenderFrame& renderFrame, CommandBufferBuilder& builder, const Texture& texture) const = 0;
|
||||
|
||||
virtual const Framebuffer& GetFramebuffer(std::size_t i) const = 0;
|
||||
virtual std::size_t GetFramebufferCount() const = 0;
|
||||
virtual const RenderPass& GetRenderPass() const = 0;
|
||||
virtual const Vector2ui& GetSize() const = 0;
|
||||
|
||||
NazaraSignal(OnRenderTargetRelease, const RenderTarget* /*renderTarget*/);
|
||||
|
||||
46
include/Nazara/Renderer/RenderTexture.hpp
Normal file
46
include/Nazara/Renderer/RenderTexture.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RENDERER_RENDERTEXTURE_HPP
|
||||
#define NAZARA_RENDERER_RENDERTEXTURE_HPP
|
||||
|
||||
#include <NazaraUtils/Prerequisites.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class Texture;
|
||||
|
||||
class NAZARA_RENDERER_API RenderTexture : public RenderTarget
|
||||
{
|
||||
public:
|
||||
inline RenderTexture(std::shared_ptr<Texture> targetTexture);
|
||||
inline RenderTexture(std::shared_ptr<Texture> targetTexture, PipelineStage targetPipelineStage, MemoryAccessFlags targetMemoryFlags, TextureLayout targetLayout);
|
||||
RenderTexture(const RenderTexture&) = delete;
|
||||
RenderTexture(RenderTexture&&) = delete;
|
||||
~RenderTexture() = default;
|
||||
|
||||
void BlitTexture(RenderFrame& renderFrame, CommandBufferBuilder& builder, const Texture& texture) const override;
|
||||
|
||||
const Vector2ui& GetSize() const override;
|
||||
|
||||
RenderTexture& operator=(const RenderTexture&) = delete;
|
||||
RenderTexture& operator=(RenderTexture&&) = delete;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Texture> m_targetTexture;
|
||||
MemoryAccessFlags m_targetMemoryFlags;
|
||||
PipelineStage m_targetPipelineStage;
|
||||
TextureLayout m_targetLayout;
|
||||
Vector2ui m_textureSize;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/RenderTexture.inl>
|
||||
|
||||
#endif // NAZARA_RENDERER_RENDERTEXTURE_HPP
|
||||
16
include/Nazara/Renderer/RenderTexture.inl
Normal file
16
include/Nazara/Renderer/RenderTexture.inl
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Renderer/RenderTexture.hpp>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline RenderTexture::RenderTexture(std::shared_ptr<Texture> targetTexture) :
|
||||
RenderTexture(std::move(targetTexture), PipelineStage::FragmentShader, MemoryAccess::ColorRead, TextureLayout::ColorInput)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
@@ -33,7 +33,10 @@ namespace Nz
|
||||
|
||||
virtual std::shared_ptr<CommandPool> CreateCommandPool(QueueType queueType) = 0;
|
||||
|
||||
virtual const Framebuffer& GetFramebuffer(std::size_t i) const = 0;
|
||||
virtual std::size_t GetFramebufferCount() const = 0;
|
||||
virtual PresentMode GetPresentMode() const = 0;
|
||||
virtual const RenderPass& GetRenderPass() const = 0;
|
||||
virtual PresentModeFlags GetSupportedPresentModes() const = 0;
|
||||
|
||||
virtual void NotifyResize(const Vector2ui& newSize) = 0;
|
||||
|
||||
@@ -108,4 +108,3 @@ namespace Nz
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
#include "TransientResources.hpp"
|
||||
|
||||
@@ -35,9 +35,9 @@ namespace Nz
|
||||
|
||||
inline void EnableRenderOnlyIfFocused(bool enable = true);
|
||||
|
||||
const Framebuffer& GetFramebuffer(std::size_t i) const override;
|
||||
std::size_t GetFramebufferCount() const override;
|
||||
const RenderPass& GetRenderPass() const override;
|
||||
inline const Framebuffer& GetFramebuffer(std::size_t i) const;
|
||||
inline std::size_t GetFramebufferCount() const;
|
||||
inline const RenderPass& GetRenderPass() const;
|
||||
const Vector2ui& GetSize() const override;
|
||||
inline Swapchain& GetSwapchain();
|
||||
inline const Swapchain& GetSwapchain() const;
|
||||
|
||||
@@ -35,6 +35,24 @@ namespace Nz
|
||||
m_renderOnlyIfFocused = enable;
|
||||
}
|
||||
|
||||
inline const Framebuffer& WindowSwapchain::GetFramebuffer(std::size_t i) const
|
||||
{
|
||||
assert(m_swapchain);
|
||||
return m_swapchain->GetFramebuffer(i);
|
||||
}
|
||||
|
||||
inline std::size_t WindowSwapchain::GetFramebufferCount() const
|
||||
{
|
||||
assert(m_swapchain);
|
||||
return m_swapchain->GetFramebufferCount();
|
||||
}
|
||||
|
||||
inline const RenderPass& WindowSwapchain::GetRenderPass() const
|
||||
{
|
||||
assert(m_swapchain);
|
||||
return m_swapchain->GetRenderPass();
|
||||
}
|
||||
|
||||
inline Swapchain& WindowSwapchain::GetSwapchain()
|
||||
{
|
||||
return *m_swapchain;
|
||||
|
||||
Reference in New Issue
Block a user