Core/AppFilesystemComponent: Add support for default resource parameters

This commit is contained in:
SirLynix
2023-01-28 11:27:49 +01:00
parent 60c00068ca
commit d27ca55943
24 changed files with 364 additions and 85 deletions

View File

@@ -3,6 +3,7 @@
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/Graphics.hpp>
#include <Nazara/Core/AppFilesystemComponent.hpp>
#include <Nazara/Graphics/GuillotineTextureAtlas.hpp>
#include <Nazara/Graphics/MaterialInstance.hpp>
#include <Nazara/Graphics/MaterialPipeline.hpp>
@@ -174,6 +175,14 @@ namespace Nz
m_defaultTextures = DefaultTextures{};
}
void Graphics::RegisterComponent(AppFilesystemComponent& component)
{
TextureParams defaultTexParams;
defaultTexParams.renderDevice = m_renderDevice;
component.SetDefaultResourceParameters<Texture>(defaultTexParams);
}
void Graphics::BuildBlitPipeline()
{
RenderPipelineLayoutInfo layoutInfo;

View File

@@ -32,6 +32,16 @@ namespace Nz
return true;
}
void TextureParams::Merge(const TextureParams& params)
{
ImageParams::Merge(params);
if (!renderDevice)
renderDevice = params.renderDevice;
usageFlags |= params.usageFlags;
}
std::shared_ptr<Texture> Texture::CreateFromImage(const Image& image, const TextureParams& params)
{
NazaraAssert(params.IsValid(), "Invalid TextureParams");

View File

@@ -39,6 +39,13 @@ namespace Nz
return true; // Rien à vérifier
}
void ImageParams::Merge(const ImageParams& params)
{
if (loadFormat == PixelFormat::Undefined)
loadFormat = params.loadFormat;
}
Image::Image() :
m_sharedImage(&emptyImage)
{