Files
NazaraEngine/src/Nazara/Graphics/Formats/TextureLoader.cpp
Gawaboumga bbac0838dd Include-What-You-Use (#137)
* IWYU Core

* IWYU Noise

* IWYU Utility

* IWYU Audio

* IWYU Platform

* IWYU Lua

* IWYU Network

* IWYU Physics2D

* IWYU Physics3D

* IWYU Renderer

* IWYU Graphics

* IWYU NDKServer

* IWYU Fix

* Try to fix compilation

* Other fixes
2017-10-01 11:17:09 +02:00

57 lines
1.3 KiB
C++

// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/Formats/TextureLoader.hpp>
#include <Nazara/Graphics/Material.hpp>
#include <Nazara/Renderer/Texture.hpp>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
namespace
{
Ternary Check(Stream& stream, const MaterialParams& parameters)
{
NazaraUnused(stream);
bool skip;
if (parameters.custom.GetBooleanParameter("SkipNativeTextureLoader", &skip) && skip)
return Ternary_False;
return Ternary_Unknown;
}
bool Load(Material* material, Stream& stream, const MaterialParams& parameters)
{
NazaraUnused(parameters);
TextureRef texture = Texture::New();
if (!texture->LoadFromStream(stream))
{
NazaraError("Failed to load diffuse map");
return false;
}
material->Reset();
material->SetDiffuseMap(texture);
material->SetShader(parameters.shaderName);
return true;
}
}
namespace Loaders
{
void RegisterTexture()
{
MaterialLoader::RegisterLoader(ImageLoader::IsExtensionSupported, Check, Load);
}
void UnregisterTexture()
{
MaterialLoader::UnregisterLoader(ImageLoader::IsExtensionSupported, Check, Load);
}
}
}