Rewritted ResourceLoader and moved it to core
Added creation constructor to NzImage Added member function functor Added option to build Nazara as one library (instead of many) Fixed some 2011 copyrights Made use of "using def = T" C++11 feature instead of some illigible typedefs Removed unused premake file
This commit is contained in:
@@ -9,8 +9,6 @@
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
class NzConditionVariableImpl;
|
||||
|
||||
class NzMutexImpl
|
||||
{
|
||||
friend class NzConditionVariableImpl;
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace
|
||||
GL_STATIC_DRAW // nzBufferUsage_Static
|
||||
};
|
||||
|
||||
typedef nzUInt8* (*LockRoutine)(nzBufferType type, nzBufferAccess access, unsigned int offset, unsigned int size);
|
||||
using LockRoutine = nzUInt8* (*)(nzBufferType type, nzBufferAccess access, unsigned int offset, unsigned int size);
|
||||
|
||||
nzUInt8* LockBuffer(nzBufferType type, nzBufferAccess access, unsigned int offset, unsigned int size)
|
||||
{
|
||||
|
||||
@@ -354,9 +354,9 @@ bool NzOpenGL::Initialize()
|
||||
{
|
||||
try
|
||||
{
|
||||
glDebugMessageCallback = reinterpret_cast<PFNGLDEBUGMESSAGECALLBACKPROC>(LoadEntry("glDebugMessageCallback"));
|
||||
glDebugMessageControl = reinterpret_cast<PFNGLDEBUGMESSAGECONTROLPROC>(LoadEntry("glDebugMessageControl"));
|
||||
glDebugMessageInsert = reinterpret_cast<PFNGLDEBUGMESSAGEINSERTPROC>(LoadEntry("glDebugMessageInsert"));
|
||||
glDebugMessageCallback = reinterpret_cast<PFNGLDEBUGMESSAGECALLBACKPROC>(LoadEntry("glDebugMessageCallback"));
|
||||
glGetDebugMessageLog = reinterpret_cast<PFNGLGETDEBUGMESSAGELOGPROC>(LoadEntry("glGetDebugMessageLog"));
|
||||
|
||||
openGLextensions[NzOpenGL::DebugOutput] = true;
|
||||
@@ -371,9 +371,9 @@ bool NzOpenGL::Initialize()
|
||||
{
|
||||
try
|
||||
{
|
||||
glDebugMessageCallback = reinterpret_cast<PFNGLDEBUGMESSAGECALLBACKARBPROC>(LoadEntry("glDebugMessageCallbackARB"));
|
||||
glDebugMessageControl = reinterpret_cast<PFNGLDEBUGMESSAGECONTROLARBPROC>(LoadEntry("glDebugMessageControlARB"));
|
||||
glDebugMessageInsert = reinterpret_cast<PFNGLDEBUGMESSAGEINSERTARBPROC>(LoadEntry("glDebugMessageInsertARB"));
|
||||
glDebugMessageCallback = reinterpret_cast<PFNGLDEBUGMESSAGECALLBACKARBPROC>(LoadEntry("glDebugMessageCallbackARB"));
|
||||
glGetDebugMessageLog = reinterpret_cast<PFNGLGETDEBUGMESSAGELOGARBPROC>(LoadEntry("glGetDebugMessageLogARB"));
|
||||
|
||||
openGLextensions[NzOpenGL::DebugOutput] = true;
|
||||
@@ -590,9 +590,9 @@ PFNGLCOLORMASKPROC glColorMask = nullptr;
|
||||
PFNGLCULLFACEPROC glCullFace = nullptr;
|
||||
PFNGLCOMPILESHADERPROC glCompileShader = nullptr;
|
||||
PFNGLCOPYTEXSUBIMAGE2DPROC glCopyTexSubImage2D = nullptr;
|
||||
PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback = nullptr;
|
||||
PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl = nullptr;
|
||||
PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert = nullptr;
|
||||
PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback = nullptr;
|
||||
PFNGLDELETEBUFFERSPROC glDeleteBuffers = nullptr;
|
||||
PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers = nullptr;
|
||||
PFNGLDELETEPROGRAMPROC glDeleteProgram = nullptr;
|
||||
|
||||
@@ -147,10 +147,10 @@ namespace
|
||||
return new NzHardwareBuffer(parent, type);
|
||||
}
|
||||
|
||||
typedef std::tuple<const NzContext*, const NzIndexBuffer*, const NzVertexBuffer*, const NzVertexDeclaration*> VAO_Key;
|
||||
|
||||
constexpr unsigned int totalMatrixCount = nzMatrixCombination_Max+1;
|
||||
|
||||
using VAO_Key = std::tuple<const NzContext*, const NzIndexBuffer*, const NzVertexBuffer*, const NzVertexDeclaration*>;
|
||||
|
||||
std::map<VAO_Key, unsigned int> s_vaos;
|
||||
NzMatrix4f s_matrix[totalMatrixCount];
|
||||
int s_matrixLocation[totalMatrixCount];
|
||||
|
||||
@@ -14,15 +14,7 @@
|
||||
#include <stdexcept>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
NzShader::NzShader() :
|
||||
m_impl(nullptr),
|
||||
m_compiled(false)
|
||||
{
|
||||
}
|
||||
|
||||
NzShader::NzShader(nzShaderLanguage language) :
|
||||
m_impl(nullptr),
|
||||
m_compiled(false)
|
||||
NzShader::NzShader(nzShaderLanguage language)
|
||||
{
|
||||
Create(language);
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
|
||||
class NzRenderer;
|
||||
class NzTexture;
|
||||
class NzVertexBuffer;
|
||||
class NzVertexDeclaration;
|
||||
|
||||
@@ -517,7 +517,7 @@ void NzTexture::Destroy()
|
||||
bool NzTexture::Download(NzImage* image) const
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return false;
|
||||
@@ -576,7 +576,7 @@ bool NzTexture::Download(NzImage* image) const
|
||||
bool NzTexture::EnableMipmapping(bool enable)
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return false;
|
||||
@@ -603,7 +603,7 @@ bool NzTexture::EnableMipmapping(bool enable)
|
||||
unsigned int NzTexture::GetAnisotropyLevel() const
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return 0;
|
||||
@@ -626,7 +626,7 @@ unsigned int NzTexture::GetAnisotropyLevel() const
|
||||
nzUInt8 NzTexture::GetBPP() const
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return 0;
|
||||
@@ -639,7 +639,7 @@ nzUInt8 NzTexture::GetBPP() const
|
||||
unsigned int NzTexture::GetDepth() const
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return 0;
|
||||
@@ -652,7 +652,7 @@ unsigned int NzTexture::GetDepth() const
|
||||
nzTextureFilter NzTexture::GetFilterMode() const
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return nzTextureFilter_Unknown;
|
||||
@@ -689,7 +689,7 @@ nzTextureFilter NzTexture::GetFilterMode() const
|
||||
nzPixelFormat NzTexture::GetFormat() const
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return nzPixelFormat_Undefined;
|
||||
@@ -702,7 +702,7 @@ nzPixelFormat NzTexture::GetFormat() const
|
||||
unsigned int NzTexture::GetHeight() const
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return 0;
|
||||
@@ -715,7 +715,7 @@ unsigned int NzTexture::GetHeight() const
|
||||
nzImageType NzTexture::GetType() const
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return nzImageType_2D;
|
||||
@@ -728,7 +728,7 @@ nzImageType NzTexture::GetType() const
|
||||
unsigned int NzTexture::GetWidth() const
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return 0;
|
||||
@@ -741,7 +741,7 @@ unsigned int NzTexture::GetWidth() const
|
||||
nzTextureWrap NzTexture::GetWrapMode() const
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return nzTextureWrap_Unknown;
|
||||
@@ -773,7 +773,7 @@ nzTextureWrap NzTexture::GetWrapMode() const
|
||||
bool NzTexture::IsCompressed() const
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return false;
|
||||
@@ -786,7 +786,7 @@ bool NzTexture::IsCompressed() const
|
||||
bool NzTexture::IsCubemap() const
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return false;
|
||||
@@ -799,7 +799,7 @@ bool NzTexture::IsCubemap() const
|
||||
bool NzTexture::IsTarget() const
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return false;
|
||||
@@ -915,7 +915,7 @@ bool NzTexture::LoadFromStream(NzInputStream& stream, const NzImageParams& param
|
||||
bool NzTexture::Lock()
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return false;
|
||||
@@ -930,7 +930,7 @@ bool NzTexture::Lock()
|
||||
bool NzTexture::SetAnisotropyLevel(unsigned int anistropyLevel)
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return false;
|
||||
@@ -955,7 +955,7 @@ bool NzTexture::SetAnisotropyLevel(unsigned int anistropyLevel)
|
||||
bool NzTexture::SetFilterMode(nzTextureFilter filter)
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return false;
|
||||
@@ -1008,7 +1008,7 @@ bool NzTexture::SetFilterMode(nzTextureFilter filter)
|
||||
bool NzTexture::SetMipmapRange(nzUInt8 minLevel, nzUInt8 maxLevel)
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return false;
|
||||
@@ -1038,7 +1038,7 @@ bool NzTexture::SetMipmapRange(nzUInt8 minLevel, nzUInt8 maxLevel)
|
||||
bool NzTexture::SetWrapMode(nzTextureWrap wrap)
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return false;
|
||||
@@ -1175,7 +1175,7 @@ bool NzTexture::Update(const NzImage& image, const NzCubeui& cube, nzUInt8 level
|
||||
bool NzTexture::Update(const nzUInt8* pixels, nzUInt8 level)
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return false;
|
||||
@@ -1191,7 +1191,7 @@ bool NzTexture::Update(const nzUInt8* pixels, nzUInt8 level)
|
||||
bool NzTexture::Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z, nzUInt8 level)
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return false;
|
||||
@@ -1292,7 +1292,7 @@ bool NzTexture::Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int
|
||||
bool NzTexture::Update(const nzUInt8* pixels, const NzCubeui& cube, nzUInt8 level)
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return false;
|
||||
@@ -1436,7 +1436,7 @@ bool NzTexture::UpdateFace(nzCubemapFace face, const NzImage& image, const NzRec
|
||||
bool NzTexture::UpdateFace(nzCubemapFace face, const nzUInt8* pixels, nzUInt8 level)
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return false;
|
||||
@@ -1449,7 +1449,7 @@ bool NzTexture::UpdateFace(nzCubemapFace face, const nzUInt8* pixels, nzUInt8 le
|
||||
bool NzTexture::UpdateFace(nzCubemapFace face, const nzUInt8* pixels, const NzRectui& rect, nzUInt8 level)
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return false;
|
||||
@@ -1527,7 +1527,7 @@ bool NzTexture::UpdateFace(nzCubemapFace face, const nzUInt8* pixels, const NzRe
|
||||
void NzTexture::Unlock()
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Texture must be valid");
|
||||
return;
|
||||
@@ -1619,7 +1619,7 @@ bool NzTexture::IsTypeSupported(nzImageType type)
|
||||
void NzTexture::SetTarget(bool isTarget)
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraInternalError("Texture must be valid");
|
||||
return;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <Nazara/Utility/Animation.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
@@ -313,6 +314,4 @@ void NzAnimation::RemoveSequence(unsigned int index)
|
||||
m_impl->sequences.erase(it);
|
||||
}
|
||||
|
||||
std::list<NzAnimationLoader::MemoryLoader> NzAnimation::s_memoryLoaders;
|
||||
std::list<NzAnimationLoader::StreamLoader> NzAnimation::s_streamLoaders;
|
||||
std::multimap<NzString, NzAnimationLoader::LoadFileFunction> NzAnimation::s_fileLoaders;
|
||||
NzAnimationLoader::LoaderList NzAnimation::s_loaders;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <cmath>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace
|
||||
@@ -31,6 +32,20 @@ m_sharedImage(&emptyImage)
|
||||
{
|
||||
}
|
||||
|
||||
NzImage::NzImage(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth, nzUInt8 levelCount) :
|
||||
m_sharedImage(&emptyImage)
|
||||
{
|
||||
Create(type, format, width, height, depth, levelCount);
|
||||
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (!m_sharedImage)
|
||||
{
|
||||
NazaraError("Failed to create image");
|
||||
throw std::runtime_error("Constructor failed");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
NzImage::NzImage(const NzImage& image) :
|
||||
NzResource(image),
|
||||
m_sharedImage(image.m_sharedImage)
|
||||
@@ -57,7 +72,7 @@ NzImage::~NzImage()
|
||||
bool NzImage::Convert(nzPixelFormat format)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_sharedImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
return false;
|
||||
@@ -162,7 +177,7 @@ bool NzImage::Copy(const NzImage& source, const NzCubeui& srcCube, const NzVecto
|
||||
Correctif temporaire : Update veut de la mémoire contigüe
|
||||
Il est donc nécessaire de prendre la partie de la texture que nous voulons mettre à jour
|
||||
|
||||
FIXME: Trouver une interface pour gérer ce genre de problème (Façon OpenGL?)
|
||||
///FIXME: Trouver une interface pour gérer ce genre de problème (Façon OpenGL?)
|
||||
(Appliquer l'interface à NzTexture également)
|
||||
*/
|
||||
nzUInt8 bpp = NzPixelFormat::GetBPP(m_sharedImage->format);
|
||||
@@ -311,7 +326,7 @@ void NzImage::Destroy()
|
||||
bool NzImage::Fill(const NzColor& color)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_sharedImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
return false;
|
||||
@@ -369,7 +384,7 @@ bool NzImage::Fill(const NzColor& color)
|
||||
bool NzImage::Fill(const NzColor& color, const NzRectui& rect, unsigned int z)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_sharedImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
return false;
|
||||
@@ -432,7 +447,7 @@ bool NzImage::Fill(const NzColor& color, const NzRectui& rect, unsigned int z)
|
||||
bool NzImage::Fill(const NzColor& color, const NzCubeui& cube)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_sharedImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
return false;
|
||||
@@ -495,7 +510,7 @@ bool NzImage::Fill(const NzColor& color, const NzCubeui& cube)
|
||||
bool NzImage::FlipHorizontally()
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_sharedImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
return false;
|
||||
@@ -534,7 +549,7 @@ bool NzImage::FlipHorizontally()
|
||||
bool NzImage::FlipVertically()
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_sharedImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
return false;
|
||||
@@ -577,7 +592,7 @@ nzUInt8 NzImage::GetBPP() const
|
||||
const nzUInt8* NzImage::GetConstPixels(unsigned int x, unsigned int y, unsigned int z, nzUInt8 level) const
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_sharedImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
return nullptr;
|
||||
@@ -656,7 +671,7 @@ nzUInt8 NzImage::GetMaxLevel() const
|
||||
NzColor NzImage::GetPixelColor(unsigned int x, unsigned int y, unsigned int z) const
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_sharedImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
return NzColor();
|
||||
@@ -700,7 +715,7 @@ NzColor NzImage::GetPixelColor(unsigned int x, unsigned int y, unsigned int z) c
|
||||
nzUInt8* NzImage::GetPixels(unsigned int x, unsigned int y, unsigned int z, nzUInt8 level)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_sharedImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
return nullptr;
|
||||
@@ -832,7 +847,7 @@ bool NzImage::LoadFromStream(NzInputStream& stream, const NzImageParams& params)
|
||||
bool NzImage::SetLevelCount(nzUInt8 levelCount)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_sharedImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
return false;
|
||||
@@ -877,7 +892,7 @@ bool NzImage::SetLevelCount(nzUInt8 levelCount)
|
||||
bool NzImage::SetPixelColor(const NzColor& color, unsigned int x, unsigned int y, unsigned int z)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_sharedImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
return false;
|
||||
@@ -923,7 +938,7 @@ bool NzImage::SetPixelColor(const NzColor& color, unsigned int x, unsigned int y
|
||||
bool NzImage::Update(const nzUInt8* pixels, nzUInt8 level)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_sharedImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
return false;
|
||||
@@ -952,7 +967,7 @@ bool NzImage::Update(const nzUInt8* pixels, nzUInt8 level)
|
||||
bool NzImage::Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z, nzUInt8 level)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_sharedImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
return false;
|
||||
@@ -990,7 +1005,7 @@ bool NzImage::Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z
|
||||
unsigned int depth = (m_sharedImage->type == nzImageType_Cubemap) ? 6 : GetLevelSize(m_sharedImage->depth, level);
|
||||
if (z >= depth)
|
||||
{
|
||||
NazaraError("Z value exceeds depth (" + NzString::Number(z) + " >= (" + NzString::Number(depth) + ')');
|
||||
NazaraError("Z value exceeds depth (" + NzString::Number(z) + " >= " + NzString::Number(depth) + ')');
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -1015,7 +1030,7 @@ bool NzImage::Update(const nzUInt8* pixels, const NzCubeui& cube, nzUInt8 level)
|
||||
{
|
||||
///FIXME: Vérifier que ça fonctionne correctement
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
if (!m_sharedImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
return false;
|
||||
@@ -1152,6 +1167,4 @@ void NzImage::ReleaseImage()
|
||||
}
|
||||
|
||||
NzImage::SharedImage NzImage::emptyImage(0, nzImageType_2D, nzPixelFormat_Undefined, 1, nullptr, 0, 0, 0);
|
||||
std::list<NzImageLoader::MemoryLoader> NzImage::s_memoryLoaders;
|
||||
std::list<NzImageLoader::StreamLoader> NzImage::s_streamLoaders;
|
||||
std::multimap<NzString, NzImageLoader::LoadFileFunction> NzImage::s_fileLoaders;
|
||||
NzImageLoader::LoaderList NzImage::s_loaders;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2011 Jérôme Leclercq
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
@@ -18,27 +18,23 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
bool NzLoader_MD2_LoadStream(NzMesh* mesh, NzInputStream& stream, const NzMeshParams& parameters);
|
||||
|
||||
bool NzLoader_MD2_LoadFile(NzMesh* mesh, const NzString& filePath, const NzMeshParams& parameters)
|
||||
bool NzLoader_MD2_Check(NzInputStream& stream, const NzMeshParams& parameters)
|
||||
{
|
||||
NzFile file(filePath);
|
||||
if (!file.Open(NzFile::ReadOnly))
|
||||
{
|
||||
NazaraError("Failed to open file");
|
||||
NazaraUnused(parameters);
|
||||
|
||||
nzUInt32 magic[2];
|
||||
if (stream.Read(&magic[0], 2*sizeof(nzUInt32)) != 2*sizeof(nzUInt32))
|
||||
return false;
|
||||
}
|
||||
|
||||
return NzLoader_MD2_LoadStream(mesh, file, parameters);
|
||||
#if defined(NAZARA_BIG_ENDIAN)
|
||||
NzByteSwap(&magic[0], sizeof(nzUInt32));
|
||||
NzByteSwap(&magic[1], sizeof(nzUInt32));
|
||||
#endif
|
||||
|
||||
return magic[0] == md2Ident && magic[1] == 8;
|
||||
}
|
||||
|
||||
bool NzLoader_MD2_LoadMemory(NzMesh* mesh, const void* data, unsigned int size, const NzMeshParams& parameters)
|
||||
{
|
||||
NzMemoryStream stream(data, size);
|
||||
return NzLoader_MD2_LoadStream(mesh, stream, parameters);
|
||||
}
|
||||
|
||||
bool NzLoader_MD2_LoadStream(NzMesh* mesh, NzInputStream& stream, const NzMeshParams& parameters)
|
||||
bool NzLoader_MD2_Load(NzMesh* mesh, NzInputStream& stream, const NzMeshParams& parameters)
|
||||
{
|
||||
md2_header header;
|
||||
if (stream.Read(&header, sizeof(md2_header)) != sizeof(md2_header))
|
||||
@@ -208,60 +204,18 @@ namespace
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NzLoader_MD2_IdentifyMemory(const void* data, unsigned int size, const NzMeshParams& parameters)
|
||||
{
|
||||
NazaraUnused(parameters);
|
||||
|
||||
if (size < sizeof(md2_header))
|
||||
return false;
|
||||
|
||||
const md2_header* header = reinterpret_cast<const md2_header*>(data);
|
||||
|
||||
#if defined(NAZARA_BIG_ENDIAN)
|
||||
nzUInt32 ident = header->ident;
|
||||
nzUInt32 version = header->version;
|
||||
|
||||
NzByteSwap(&ident, sizeof(nzUInt32));
|
||||
NzByteSwap(&version, sizeof(nzUInt32));
|
||||
|
||||
return ident == md2Ident && version == 8;
|
||||
#else
|
||||
return header->ident == md2Ident && header->version == 8;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool NzLoader_MD2_IdentifyStream(NzInputStream& stream, const NzMeshParams& parameters)
|
||||
{
|
||||
NazaraUnused(parameters);
|
||||
|
||||
nzUInt32 magic[2];
|
||||
if (stream.Read(&magic[0], 2*sizeof(nzUInt32)) != 2*sizeof(nzUInt32))
|
||||
return false;
|
||||
|
||||
#if defined(NAZARA_BIG_ENDIAN)
|
||||
NzByteSwap(&magic[0], sizeof(nzUInt32));
|
||||
NzByteSwap(&magic[1], sizeof(nzUInt32));
|
||||
#endif
|
||||
|
||||
return magic[0] == md2Ident && magic[1] == 8;
|
||||
}
|
||||
}
|
||||
|
||||
void NzLoaders_MD2_Register()
|
||||
{
|
||||
NzMD2Mesh::Initialize();
|
||||
|
||||
NzMeshLoader::RegisterFileLoader("md2", NzLoader_MD2_LoadFile);
|
||||
NzMeshLoader::RegisterMemoryLoader(NzLoader_MD2_IdentifyMemory, NzLoader_MD2_LoadMemory);
|
||||
NzMeshLoader::RegisterStreamLoader(NzLoader_MD2_IdentifyStream, NzLoader_MD2_LoadStream);
|
||||
NzMeshLoader::RegisterLoader("md2", NzLoader_MD2_Check, NzLoader_MD2_Load);
|
||||
}
|
||||
|
||||
void NzLoaders_MD2_Unregister()
|
||||
{
|
||||
NzMeshLoader::UnregisterStreamLoader(NzLoader_MD2_IdentifyStream, NzLoader_MD2_LoadStream);
|
||||
NzMeshLoader::UnregisterMemoryLoader(NzLoader_MD2_IdentifyMemory, NzLoader_MD2_LoadMemory);
|
||||
NzMeshLoader::UnregisterFileLoader("md2", NzLoader_MD2_LoadFile);
|
||||
NzMeshLoader::UnregisterLoader("md2", NzLoader_MD2_Check, NzLoader_MD2_Load);
|
||||
|
||||
NzMD2Mesh::Uninitialize();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2011 Jérôme Leclercq
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
|
||||
@@ -37,27 +37,18 @@ namespace
|
||||
nzUInt8 padding[54];
|
||||
};
|
||||
|
||||
bool NzLoader_PCX_LoadStream(NzImage* image, NzInputStream& stream, const NzImageParams& parameters);
|
||||
|
||||
bool NzLoader_PCX_LoadFile(NzImage* image, const NzString& filePath, const NzImageParams& parameters)
|
||||
bool NzLoader_PCX_Check(NzInputStream& stream, const NzImageParams& parameters)
|
||||
{
|
||||
NzFile file(filePath);
|
||||
if (!file.Open(NzFile::ReadOnly))
|
||||
{
|
||||
NazaraError("Failed to open file");
|
||||
NazaraUnused(parameters);
|
||||
|
||||
nzUInt8 manufacturer;
|
||||
if (stream.Read(&manufacturer, 1) != 1)
|
||||
return false;
|
||||
}
|
||||
|
||||
return NzLoader_PCX_LoadStream(image, file, parameters);
|
||||
return manufacturer == 0x0a;
|
||||
}
|
||||
|
||||
bool NzLoader_PCX_LoadMemory(NzImage* image, const void* data, unsigned int size, const NzImageParams& parameters)
|
||||
{
|
||||
NzMemoryStream stream(data, size);
|
||||
return NzLoader_PCX_LoadStream(image, stream, parameters);
|
||||
}
|
||||
|
||||
bool NzLoader_PCX_LoadStream(NzImage* image, NzInputStream& stream, const NzImageParams& parameters)
|
||||
bool NzLoader_PCX_Load(NzImage* image, NzInputStream& stream, const NzImageParams& parameters)
|
||||
{
|
||||
NazaraUnused(parameters);
|
||||
|
||||
@@ -348,39 +339,14 @@ namespace
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NzLoader_PCX_IdentifyMemory(const void* data, unsigned int size, const NzImageParams& parameters)
|
||||
{
|
||||
NazaraUnused(parameters);
|
||||
|
||||
if (size < sizeof(pcx_header))
|
||||
return false;
|
||||
|
||||
return *reinterpret_cast<const nzUInt8*>(data) == 0x0a;
|
||||
}
|
||||
|
||||
bool NzLoader_PCX_IdentifyStream(NzInputStream& stream, const NzImageParams& parameters)
|
||||
{
|
||||
NazaraUnused(parameters);
|
||||
|
||||
nzUInt8 manufacturer;
|
||||
if (stream.Read(&manufacturer, 1) != 1)
|
||||
return false;
|
||||
|
||||
return manufacturer == 0x0a;
|
||||
}
|
||||
}
|
||||
|
||||
void NzLoaders_PCX_Register()
|
||||
{
|
||||
NzImageLoader::RegisterFileLoader("pcx", NzLoader_PCX_LoadFile);
|
||||
NzImageLoader::RegisterMemoryLoader(NzLoader_PCX_IdentifyMemory, NzLoader_PCX_LoadMemory);
|
||||
NzImageLoader::RegisterStreamLoader(NzLoader_PCX_IdentifyStream, NzLoader_PCX_LoadStream);
|
||||
NzImageLoader::RegisterLoader("pcx", NzLoader_PCX_Check, NzLoader_PCX_Load);
|
||||
}
|
||||
|
||||
void NzLoaders_PCX_Unregister()
|
||||
{
|
||||
NzImageLoader::UnregisterStreamLoader(NzLoader_PCX_IdentifyStream, NzLoader_PCX_LoadStream);
|
||||
NzImageLoader::UnregisterMemoryLoader(NzLoader_PCX_IdentifyMemory, NzLoader_PCX_LoadMemory);
|
||||
NzImageLoader::UnregisterFileLoader("pcx", NzLoader_PCX_LoadFile);
|
||||
NzImageLoader::UnregisterLoader("pcx", NzLoader_PCX_Check, NzLoader_PCX_Load);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2011 Jérôme Leclercq
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
@@ -37,30 +37,16 @@ namespace
|
||||
|
||||
static stbi_io_callbacks callbacks = {Read, Skip, Eof};
|
||||
|
||||
bool NzLoader_STB_LoadStream(NzImage* image, NzInputStream& stream, const NzImageParams& parameters);
|
||||
|
||||
bool NzLoader_STB_LoadFile(NzImage* image, const NzString& filePath, const NzImageParams& parameters)
|
||||
{
|
||||
NzFile file(filePath);
|
||||
if (!file.Open(NzFile::ReadOnly))
|
||||
{
|
||||
NazaraError("Failed to open file");
|
||||
return false;
|
||||
}
|
||||
|
||||
return NzLoader_STB_LoadStream(image, file, parameters);
|
||||
}
|
||||
|
||||
bool NzLoader_STB_LoadMemory(NzImage* image, const void* data, unsigned int size, const NzImageParams& parameters)
|
||||
{
|
||||
NzMemoryStream stream(data, size);
|
||||
return NzLoader_STB_LoadStream(image, stream, parameters);
|
||||
}
|
||||
|
||||
bool NzLoader_STB_LoadStream(NzImage* image, NzInputStream& stream, const NzImageParams& parameters)
|
||||
bool NzLoader_STB_Check(NzInputStream& stream, const NzImageParams& parameters)
|
||||
{
|
||||
NazaraUnused(parameters);
|
||||
|
||||
int width, height, bpp;
|
||||
return stbi_info_from_callbacks(&callbacks, &stream, &width, &height, &bpp);
|
||||
}
|
||||
|
||||
bool NzLoader_STB_Load(NzImage* image, NzInputStream& stream, const NzImageParams& parameters)
|
||||
{
|
||||
static const nzPixelFormat formats[4] =
|
||||
{
|
||||
nzPixelFormat_L8,
|
||||
@@ -127,34 +113,14 @@ namespace
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NzLoader_STB_IdentifyMemory(const void* data, unsigned int size, const NzImageParams& parameters)
|
||||
{
|
||||
NazaraUnused(parameters);
|
||||
|
||||
int width, height, bpp;
|
||||
return stbi_info_from_memory(reinterpret_cast<const stbi_uc*>(data), size, &width, &height, &bpp);
|
||||
}
|
||||
|
||||
bool NzLoader_STB_IdentifyStream(NzInputStream& stream, const NzImageParams& parameters)
|
||||
{
|
||||
NazaraUnused(parameters);
|
||||
|
||||
int width, height, bpp;
|
||||
return stbi_info_from_callbacks(&callbacks, &stream, &width, &height, &bpp);
|
||||
}
|
||||
}
|
||||
|
||||
void NzLoaders_STB_Register()
|
||||
{
|
||||
NzImageLoader::RegisterFileLoader("bmp, gif, hdr, jpg, jpeg, pic, png, psd, tga", NzLoader_STB_LoadFile);
|
||||
NzImageLoader::RegisterMemoryLoader(NzLoader_STB_IdentifyMemory, NzLoader_STB_LoadMemory);
|
||||
NzImageLoader::RegisterStreamLoader(NzLoader_STB_IdentifyStream, NzLoader_STB_LoadStream);
|
||||
NzImageLoader::RegisterLoader("bmp,gif,hdr,jpg,jpeg,pic,png,psd,tga", NzLoader_STB_Check, NzLoader_STB_Load);
|
||||
}
|
||||
|
||||
void NzLoaders_STB_Unregister()
|
||||
{
|
||||
NzImageLoader::UnregisterStreamLoader(NzLoader_STB_IdentifyStream, NzLoader_STB_LoadStream);
|
||||
NzImageLoader::UnregisterMemoryLoader(NzLoader_STB_IdentifyMemory, NzLoader_STB_LoadMemory);
|
||||
NzImageLoader::UnregisterFileLoader("bmp, gif, hdr, jpg, jpeg, pic, png, psd, tga", NzLoader_STB_LoadFile);
|
||||
NzImageLoader::UnregisterLoader("bmp,gif,hdr,jpg,jpeg,pic,png,psd,tga", NzLoader_STB_Check, NzLoader_STB_Load);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
#include <cstring>
|
||||
#include <deque>
|
||||
#include <map>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
bool NzMeshParams::IsValid() const
|
||||
@@ -619,6 +620,4 @@ bool NzMesh::SetAnimation(const NzAnimation* animation)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::list<NzMeshLoader::MemoryLoader> NzMesh::s_memoryLoaders;
|
||||
std::list<NzMeshLoader::StreamLoader> NzMesh::s_streamLoaders;
|
||||
std::multimap<NzString, NzMeshLoader::LoadFileFunction> NzMesh::s_fileLoaders;
|
||||
NzMeshLoader::LoaderList NzMesh::s_loaders;
|
||||
|
||||
Reference in New Issue
Block a user