From b243d15c7416547f732af113b761cc5a04f325e1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 24 May 2012 18:55:48 +0200 Subject: [PATCH] Added formats conversion Functor, NonCopyable, Tuple are now parts of NazaraCore (NazaraCore no longer needs NazaraUtility) Added loadFormat image parameter (ask loader to load image in specific format) Fixed utility project building It is now possible to convert, get validity or get name of pixel formats Changed endianness macros' name Removed useless NazaraEndianness macro Removed unused files --- build/scripts/module/utility.lua | 1 + include/Nazara/Audio/Sound.hpp | 27 - include/Nazara/Core/DynLib.hpp | 2 +- include/Nazara/Core/Endianness.hpp | 22 +- include/Nazara/Core/Endianness.inl | 26 +- include/Nazara/Core/File.hpp | 2 +- include/Nazara/{Utility => Core}/Functor.hpp | 4 +- include/Nazara/{Utility => Core}/Functor.inl | 0 include/Nazara/Core/Hash.hpp | 2 +- include/Nazara/Core/HashImpl.hpp | 2 +- include/Nazara/Core/Log.hpp | 2 +- include/Nazara/Core/Mutex.hpp | 2 +- .../Nazara/{Utility => Core}/NonCopyable.hpp | 0 include/Nazara/Core/Semaphore.hpp | 2 +- include/Nazara/Core/Thread.hpp | 4 +- include/Nazara/{Utility => Core}/Tuple.hpp | 2 +- include/Nazara/{Utility => Core}/Tuple.inl | 0 include/Nazara/Prerequesites.hpp | 3 +- include/Nazara/Renderer/Buffer.hpp | 2 +- include/Nazara/Renderer/OcclusionQuery.hpp | 2 +- include/Nazara/Renderer/Shader.hpp | 2 +- include/Nazara/Utility/Image.hpp | 13 +- include/Nazara/Utility/PixelFormat.hpp | 52 +- include/Nazara/Utility/PixelFormat.inl | 199 ++- include/Nazara/Utility/Window.hpp | 2 +- src/Nazara/Core/Hash/CRC32.cpp | 5 +- src/Nazara/Core/Hash/Fletcher16.cpp | 6 +- src/Nazara/Core/Hash/MD5.cpp | 2 +- src/Nazara/Core/Hash/SHA/Internal.cpp | 36 +- src/Nazara/Core/Win32/DirectoryImpl.hpp | 2 +- src/Nazara/Core/Win32/DynLibImpl.hpp | 2 +- src/Nazara/Core/Win32/FileImpl.hpp | 2 +- src/Nazara/Core/Win32/ThreadImpl.cpp | 2 +- src/Nazara/Renderer/OpenGL.cpp | 4 - src/Nazara/Utility/Image.cpp | 97 +- src/Nazara/Utility/Loaders/PCX.cpp | 7 +- src/Nazara/Utility/Loaders/STB.cpp | 47 +- src/Nazara/Utility/PixelFormat.cpp | 1161 +++++++++++++++++ src/Nazara/Utility/Utility.cpp | 9 + src/Nazara/Utility/Win32/WindowImpl.hpp | 2 +- 40 files changed, 1609 insertions(+), 150 deletions(-) delete mode 100644 include/Nazara/Audio/Sound.hpp rename include/Nazara/{Utility => Core}/Functor.hpp (91%) rename include/Nazara/{Utility => Core}/Functor.inl (100%) rename include/Nazara/{Utility => Core}/NonCopyable.hpp (100%) rename include/Nazara/{Utility => Core}/Tuple.hpp (91%) rename include/Nazara/{Utility => Core}/Tuple.inl (100%) create mode 100644 src/Nazara/Utility/PixelFormat.cpp diff --git a/build/scripts/module/utility.lua b/build/scripts/module/utility.lua index 4a9c930d4..8cadea0b3 100644 --- a/build/scripts/module/utility.lua +++ b/build/scripts/module/utility.lua @@ -7,6 +7,7 @@ files "../include/Nazara/Utility/**.hpp", "../include/Nazara/Utility/**.inl", "../src/Nazara/Utility/**.hpp", + "../src/Nazara/Utility/**.c", "../src/Nazara/Utility/**.cpp" } diff --git a/include/Nazara/Audio/Sound.hpp b/include/Nazara/Audio/Sound.hpp deleted file mode 100644 index ad7704775..000000000 --- a/include/Nazara/Audio/Sound.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2012 Jérôme Leclercq -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_SOUND_HPP -#define NAZARA_SOUND_HPP - -#include -#include -#include - -class NAZARA_API NzSound -{ - public: - NzSound(); - ~NzSound(); - - bool LoadFromFile(const NzString& filePath); - bool LoadFromMemory(const nzUInt8* ptr, std::size_t size); - - private: - -}; - -#endif // NAZARA_SOUND_HPP diff --git a/include/Nazara/Core/DynLib.hpp b/include/Nazara/Core/DynLib.hpp index 3fccb82e2..a7da89da8 100644 --- a/include/Nazara/Core/DynLib.hpp +++ b/include/Nazara/Core/DynLib.hpp @@ -8,8 +8,8 @@ #define NAZARA_DYNLIB_HPP #include +#include #include -#include #define NAZARA_CLASS_DYNLIB #include diff --git a/include/Nazara/Core/Endianness.hpp b/include/Nazara/Core/Endianness.hpp index 763b0fc07..d5af604c9 100644 --- a/include/Nazara/Core/Endianness.hpp +++ b/include/Nazara/Core/Endianness.hpp @@ -9,26 +9,18 @@ #include -#if defined(NAZARA_ENDIANNESS_BIGENDIAN) - #define NAZARA_ENDIANNESS_DETECTED 1 - #define NazaraEndianness nzEndianness_BigEndian -#elif defined(NAZARA_ENDIANNESS_LITTLEENDIAN) - #define NAZARA_ENDIANNESS_DETECTED 1 - #define NazaraEndianness nzEndianness_LittleEndian -#else +#if !defined(NAZARA_BIG_ENDIAN) && !defined(NAZARA_LITTLE_ENDIAN) + // Détection automatique selon les macros du compilateur #if defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || (defined(__MIPS__) && defined(__MISPEB__)) || \ defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || defined(__sparc__) || defined(__hppa__) - #define NAZARA_ENDIANNESS_DETECTED 1 - #define NAZARA_ENDIANNESS_BIGENDIAN - #define NazaraEndianness nzEndianness_BigEndian + #define NAZARA_BIG_ENDIAN #elif defined(__i386__) || defined(__i386) || defined(__X86__) || defined (__x86_64) - #define NAZARA_ENDIANNESS_DETECTED 1 - #define NAZARA_ENDIANNESS_LITTLEENDIAN - #define NazaraEndianness nzEndianness_LittleEndian + #define NAZARA_LITTLE_ENDIAN #else - #define NAZARA_ENDIANNESS_DETECTED 0 - #define NazaraEndianness NzGetPlatformEndianness() + #error Failed to identify endianness, you must define either NAZARA_BIG_ENDIAN or NAZARA_LITTLE_ENDIAN #endif +#elif defined(NAZARA_BIG_ENDIAN) && defined(NAZARA_LITTLE_ENDIAN) + #error You cannot define both NAZARA_BIG_ENDIAN and NAZARA_LITTLE_ENDIAN #endif enum nzEndianness diff --git a/include/Nazara/Core/Endianness.inl b/include/Nazara/Core/Endianness.inl index 253abc00d..20edee20f 100644 --- a/include/Nazara/Core/Endianness.inl +++ b/include/Nazara/Core/Endianness.inl @@ -17,27 +17,11 @@ inline void NzByteSwap(void* buffer, unsigned int size) inline nzEndianness NzGetPlatformEndianness() { -#if NAZARA_ENDIANNESS_DETECTED - return NazaraEndianness; -#else - static nzEndianness endianness = nzEndianness_Unknown; - static bool tested = false; - if (!tested) - { - nzUInt32 i = 1; - nzUInt8* p = reinterpret_cast(&i); - - // Méthode de récupération de l'endianness au runtime - if (p[0] == 1) - endianness = nzEndianness_LittleEndian; - else if (p[3] == 1) - endianness = nzEndianness_BigEndian; - - tested = true; - } - - return endianness; -#endif + #if defined(NAZARA_BIG_ENDIAN) + return nzEndianness_BigEndian; + #elif defined(NAZARA_LITTLE_ENDIAN) + return nzEndianness_LittleEndian; + #endif } #include diff --git a/include/Nazara/Core/File.hpp b/include/Nazara/Core/File.hpp index 79b8fc42f..b253d30b9 100644 --- a/include/Nazara/Core/File.hpp +++ b/include/Nazara/Core/File.hpp @@ -13,8 +13,8 @@ #include #include #include +#include #include -#include #define NAZARA_CLASS_FILE #include diff --git a/include/Nazara/Utility/Functor.hpp b/include/Nazara/Core/Functor.hpp similarity index 91% rename from include/Nazara/Utility/Functor.hpp rename to include/Nazara/Core/Functor.hpp index ebfb35b73..620423d70 100644 --- a/include/Nazara/Utility/Functor.hpp +++ b/include/Nazara/Core/Functor.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_FUNCTOR_HPP #define NAZARA_FUNCTOR_HPP -#include +#include // Inspiré du code de la SFML par Laurent Gomila @@ -40,6 +40,6 @@ template struct NzFunctorWithArgs : NzFunctor template struct NzFunctorWithoutArgs; template struct NzFunctorWithArgs; -#include +#include #endif // NAZARA_FUNCTOR_HPP diff --git a/include/Nazara/Utility/Functor.inl b/include/Nazara/Core/Functor.inl similarity index 100% rename from include/Nazara/Utility/Functor.inl rename to include/Nazara/Core/Functor.inl diff --git a/include/Nazara/Core/Hash.hpp b/include/Nazara/Core/Hash.hpp index a2913a689..2243326b4 100644 --- a/include/Nazara/Core/Hash.hpp +++ b/include/Nazara/Core/Hash.hpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include class NAZARA_API NzHash : NzNonCopyable { diff --git a/include/Nazara/Core/HashImpl.hpp b/include/Nazara/Core/HashImpl.hpp index b2d7cec5c..83f087bd6 100644 --- a/include/Nazara/Core/HashImpl.hpp +++ b/include/Nazara/Core/HashImpl.hpp @@ -8,7 +8,7 @@ #define NAZARA_HASHIMPL_HPP #include -#include +#include class NzHashDigest; diff --git a/include/Nazara/Core/Log.hpp b/include/Nazara/Core/Log.hpp index 71e69c418..8c61ffb4c 100644 --- a/include/Nazara/Core/Log.hpp +++ b/include/Nazara/Core/Log.hpp @@ -9,8 +9,8 @@ #include #include +#include #include -#include #define NAZARA_CLASS_LOG #include diff --git a/include/Nazara/Core/Mutex.hpp b/include/Nazara/Core/Mutex.hpp index bd534d4a5..01b410fcd 100644 --- a/include/Nazara/Core/Mutex.hpp +++ b/include/Nazara/Core/Mutex.hpp @@ -8,7 +8,7 @@ #define NAZARA_MUTEX_HPP #include -#include +#include class NzMutexImpl; class NzThreadCondition; diff --git a/include/Nazara/Utility/NonCopyable.hpp b/include/Nazara/Core/NonCopyable.hpp similarity index 100% rename from include/Nazara/Utility/NonCopyable.hpp rename to include/Nazara/Core/NonCopyable.hpp diff --git a/include/Nazara/Core/Semaphore.hpp b/include/Nazara/Core/Semaphore.hpp index 24ff442b4..53e7ae509 100644 --- a/include/Nazara/Core/Semaphore.hpp +++ b/include/Nazara/Core/Semaphore.hpp @@ -8,7 +8,7 @@ #define NAZARA_SEMAPHORE_HPP #include -#include +#include class NzSemaphoreImpl; diff --git a/include/Nazara/Core/Thread.hpp b/include/Nazara/Core/Thread.hpp index 49c782818..d5bd416ab 100644 --- a/include/Nazara/Core/Thread.hpp +++ b/include/Nazara/Core/Thread.hpp @@ -10,8 +10,8 @@ #define NAZARA_THREAD_HPP #include -#include -#include +#include +#include class NzThreadImpl; diff --git a/include/Nazara/Utility/Tuple.hpp b/include/Nazara/Core/Tuple.hpp similarity index 91% rename from include/Nazara/Utility/Tuple.hpp rename to include/Nazara/Core/Tuple.hpp index d0159b33e..94d0b77da 100644 --- a/include/Nazara/Utility/Tuple.hpp +++ b/include/Nazara/Core/Tuple.hpp @@ -11,6 +11,6 @@ template void NzUnpackTuple(F func, const std::tuple& t); -#include +#include #endif // NAZARA_TUPLE_HPP diff --git a/include/Nazara/Utility/Tuple.inl b/include/Nazara/Core/Tuple.inl similarity index 100% rename from include/Nazara/Utility/Tuple.inl rename to include/Nazara/Core/Tuple.inl diff --git a/include/Nazara/Prerequesites.hpp b/include/Nazara/Prerequesites.hpp index 71bbfeff5..ff66261cc 100644 --- a/include/Nazara/Prerequesites.hpp +++ b/include/Nazara/Prerequesites.hpp @@ -23,9 +23,8 @@ #define NAZARA_FUNCTION __FUNCSIG__ #elif defined(__GNUC__) #define NAZARA_COMPILER_GCC - #define NAZARA_FUNCTION __PRETTY_FUNCTION__ - #define NAZARA_DEPRECATED(txt) __attribute__((__deprecated__(txt))) + #define NAZARA_FUNCTION __PRETTY_FUNCTION__ #elif defined(__BORLANDC__) #define NAZARA_COMPILER_BORDLAND #define NAZARA_DEPRECATED(txt) diff --git a/include/Nazara/Renderer/Buffer.hpp b/include/Nazara/Renderer/Buffer.hpp index 285a6774b..8176f1c61 100644 --- a/include/Nazara/Renderer/Buffer.hpp +++ b/include/Nazara/Renderer/Buffer.hpp @@ -8,7 +8,7 @@ #define NAZARA_BUFFER_HPP #include -#include +#include #include enum nzBufferLock diff --git a/include/Nazara/Renderer/OcclusionQuery.hpp b/include/Nazara/Renderer/OcclusionQuery.hpp index 42580e6d1..e6ea73e3a 100644 --- a/include/Nazara/Renderer/OcclusionQuery.hpp +++ b/include/Nazara/Renderer/OcclusionQuery.hpp @@ -8,7 +8,7 @@ #define NAZARA_OCCLUSIONQUERY_HPP #include -#include +#include class NAZARA_API NzOcclusionQuery : NzNonCopyable { diff --git a/include/Nazara/Renderer/Shader.hpp b/include/Nazara/Renderer/Shader.hpp index e54de851d..f143d213a 100644 --- a/include/Nazara/Renderer/Shader.hpp +++ b/include/Nazara/Renderer/Shader.hpp @@ -8,9 +8,9 @@ #define NAZARA_SHADER_HPP #include +#include #include #include -#include #include enum nzShaderLanguage diff --git a/include/Nazara/Utility/Image.hpp b/include/Nazara/Utility/Image.hpp index 0273249a0..515a3607c 100644 --- a/include/Nazara/Utility/Image.hpp +++ b/include/Nazara/Utility/Image.hpp @@ -35,12 +35,21 @@ enum nzImageType struct NzImageParams { + // GCC 4.7 je te veux + NzImageParams() : + loadFormat(nzPixelFormat_Undefined) + { + } + + nzPixelFormat loadFormat; + bool IsValid() const { - return true; + return loadFormat == nzPixelFormat_Undefined || NzPixelFormat::IsValid(loadFormat); } }; +///TODO: Animations ? ///TODO: Filtres ///TODO: Mipmaps @@ -55,6 +64,8 @@ class NAZARA_API NzImage : public NzResource, public NzResourceLoader +#include enum nzPixelFormat { nzPixelFormat_Undefined, - nzPixelFormat_B8G8R8, - nzPixelFormat_B8G8R8A8, + nzPixelFormat_BGR8, + nzPixelFormat_BGRA8, nzPixelFormat_DXT1, nzPixelFormat_DXT3, nzPixelFormat_DXT5, nzPixelFormat_L8, - nzPixelFormat_L8A8, - nzPixelFormat_R4G4A4A4, - nzPixelFormat_R5G5A5A1, - nzPixelFormat_R8, - nzPixelFormat_R8G8, - nzPixelFormat_R8G8B8, - nzPixelFormat_R8G8B8A8 + nzPixelFormat_LA8, + /* + nzPixelFormat_RGB16F, + nzPixelFormat_RGB16I, + nzPixelFormat_RGB32F, + nzPixelFormat_RGB32I, + */ + nzPixelFormat_RGBA16F, + nzPixelFormat_RGBA16I, + /* + nzPixelFormat_RGBA32F, + nzPixelFormat_RGBA32I, + */ + nzPixelFormat_RGBA4, + nzPixelFormat_RGB5A1, + nzPixelFormat_RGB8, + nzPixelFormat_RGBA8, + + nzPixelFormat_Count }; +class NzUtility; + class NzPixelFormat { + friend class NzUtility; + public: + typedef nzUInt8* (*ConvertFunction)(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst); + + static bool Convert(nzPixelFormat srcFormat, nzPixelFormat dstFormat, const void* src, void* dst); + static bool Convert(nzPixelFormat srcFormat, nzPixelFormat dstFormat, const void* start, const void* end, void* dst); + static nzUInt8 GetBPP(nzPixelFormat format); + static bool IsCompressed(nzPixelFormat format); + static bool IsValid(nzPixelFormat format); + + static void SetConvertFunction(nzPixelFormat srcFormat, nzPixelFormat dstFormat, ConvertFunction); + + static NzString ToString(nzPixelFormat format); + + private: + static bool Initialize(); + static void Uninitialize(); + + static ConvertFunction s_convertFunctions[nzPixelFormat_Count][nzPixelFormat_Count]; }; #include diff --git a/include/Nazara/Utility/PixelFormat.inl b/include/Nazara/Utility/PixelFormat.inl index f89ca81ab..c50f9b304 100644 --- a/include/Nazara/Utility/PixelFormat.inl +++ b/include/Nazara/Utility/PixelFormat.inl @@ -2,19 +2,76 @@ // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include +#include +#include + +inline bool NzPixelFormat::Convert(nzPixelFormat srcFormat, nzPixelFormat dstFormat, const void* src, void* dst) +{ + if (srcFormat == dstFormat) + { + std::memcpy(dst, src, GetBPP(srcFormat)); + return true; + } + + #if NAZARA_UTILITY_SAFE + if (IsCompressed(srcFormat)) + { + NazaraError("Cannot convert single pixel from compressed format"); + return false; + } + + if (IsCompressed(dstFormat)) + { + NazaraError("Cannot convert single pixel to compressed format"); + return false; + } + #endif + + ConvertFunction func = s_convertFunctions[srcFormat][dstFormat]; + if (!func) + { + NazaraError("Pixel format conversion from " + ToString(srcFormat) + " to " + ToString(dstFormat) + " not supported"); + return false; + } + + func(static_cast(src), static_cast(src) + GetBPP(srcFormat), static_cast(dst)); + + return true; +} + +inline bool NzPixelFormat::Convert(nzPixelFormat srcFormat, nzPixelFormat dstFormat, const void* start, const void* end, void* dst) +{ + if (srcFormat == dstFormat) + { + std::memcpy(dst, start, static_cast(end)-static_cast(start)); + return true; + } + + ConvertFunction func = s_convertFunctions[srcFormat][dstFormat]; + if (!func) + { + NazaraError("Pixel format conversion from " + ToString(srcFormat) + " to " + ToString(dstFormat) + " not supported"); + return false; + } + + func(static_cast(start), static_cast(end), static_cast(dst)); + + return true; +} inline nzUInt8 NzPixelFormat::GetBPP(nzPixelFormat format) { switch (format) { + case nzPixelFormat_Count: case nzPixelFormat_Undefined: return 0; - case nzPixelFormat_B8G8R8: + case nzPixelFormat_BGR8: return 3; - case nzPixelFormat_B8G8R8A8: + case nzPixelFormat_BGRA8: return 4; case nzPixelFormat_DXT1: @@ -29,28 +86,48 @@ inline nzUInt8 NzPixelFormat::GetBPP(nzPixelFormat format) case nzPixelFormat_L8: return 1; - case nzPixelFormat_L8A8: + case nzPixelFormat_LA8: + return 2; +/* + case nzPixelFormat_RGB16F: + return 6; + + case nzPixelFormat_RGB16I: + return 6; + + case nzPixelFormat_RGB32F: + return 12; + + case nzPixelFormat_RGB32I: + return 12; +*/ + case nzPixelFormat_RGBA16F: + return 8; + + case nzPixelFormat_RGBA16I: + return 8; +/* + case nzPixelFormat_RGBA32F: + return 16; + + case nzPixelFormat_RGBA32I: + return 16; +*/ + case nzPixelFormat_RGBA4: return 2; - case nzPixelFormat_R4G4A4A4: + case nzPixelFormat_RGB5A1: return 2; - case nzPixelFormat_R5G5A5A1: - return 2; - - case nzPixelFormat_R8: - return 1; - - case nzPixelFormat_R8G8: - return 2; - - case nzPixelFormat_R8G8B8: + case nzPixelFormat_RGB8: return 3; - case nzPixelFormat_R8G8B8A8: + case nzPixelFormat_RGBA8: return 4; } + NazaraInternalError("Invalid pixel format"); + return 0; } @@ -68,4 +145,92 @@ inline bool NzPixelFormat::IsCompressed(nzPixelFormat format) } } -#include +inline bool NzPixelFormat::IsValid(nzPixelFormat format) +{ + switch (format) + { + case nzPixelFormat_Count: + case nzPixelFormat_Undefined: + return false; + + default: + return true; + } +} + +inline void NzPixelFormat::SetConvertFunction(nzPixelFormat srcFormat, nzPixelFormat dstFormat, ConvertFunction func) +{ + s_convertFunctions[srcFormat][dstFormat] = func; +} + +inline NzString NzPixelFormat::ToString(nzPixelFormat format) +{ + switch (format) + { + case nzPixelFormat_BGR8: + return "BGR8"; + + case nzPixelFormat_BGRA8: + return "BGRA8"; + + case nzPixelFormat_DXT1: + return "DXT1"; + + case nzPixelFormat_DXT3: + return "DXT3"; + + case nzPixelFormat_DXT5: + return "DXT5"; + + case nzPixelFormat_L8: + return "L8"; + + case nzPixelFormat_LA8: + return "LA8"; +/* + case nzPixelFormat_RGB16F: + return "RGB16F"; + + case nzPixelFormat_RGB16I: + return "RGB16I"; + + case nzPixelFormat_RGB32F: + return "RGB32F"; + + case nzPixelFormat_RGB32I: + return "RGB32I"; +*/ + case nzPixelFormat_RGBA16F: + return "RGBA16F"; + + case nzPixelFormat_RGBA16I: + return "RGBA16I"; +/* + case nzPixelFormat_RGBA32F: + return "RGBA32F"; + + case nzPixelFormat_RGBA32I: + return "RGBA32I"; +*/ + case nzPixelFormat_RGBA4: + return "RGBA4"; + + case nzPixelFormat_RGB5A1: + return "RGB5A1"; + + case nzPixelFormat_RGB8: + return "RGB8"; + + case nzPixelFormat_RGBA8: + return "RGBA8"; + + default: + NazaraInternalError("Invalid pixel format"); + + case nzPixelFormat_Count: + case nzPixelFormat_Undefined: + return "Invalid format"; + } +} + +#include diff --git a/include/Nazara/Utility/Window.hpp b/include/Nazara/Utility/Window.hpp index b51239f52..fd9f98c2e 100644 --- a/include/Nazara/Utility/Window.hpp +++ b/include/Nazara/Utility/Window.hpp @@ -10,11 +10,11 @@ #define NAZARA_WINDOW_HPP #include +#include #include #include #include #include -#include #include #include #include diff --git a/src/Nazara/Core/Hash/CRC32.cpp b/src/Nazara/Core/Hash/CRC32.cpp index 2c0a0685c..6a481e1c4 100644 --- a/src/Nazara/Core/Hash/CRC32.cpp +++ b/src/Nazara/Core/Hash/CRC32.cpp @@ -111,8 +111,9 @@ NzHashDigest NzHashCRC32::End() { m_state->crc ^= 0xFFFFFFFF; - if (NazaraEndianness == nzEndianness_LittleEndian) - NzByteSwap(&m_state->crc, sizeof(nzUInt32)); + #ifdef NAZARA_LITTLE_ENDIAN + NzByteSwap(&m_state->crc, sizeof(nzUInt32)); + #endif return NzHashDigest(GetHashName(), reinterpret_cast(&m_state->crc), 4); } diff --git a/src/Nazara/Core/Hash/Fletcher16.cpp b/src/Nazara/Core/Hash/Fletcher16.cpp index 6239a7ccf..e3c20b32d 100644 --- a/src/Nazara/Core/Hash/Fletcher16.cpp +++ b/src/Nazara/Core/Hash/Fletcher16.cpp @@ -52,8 +52,10 @@ NzHashDigest NzHashFletcher16::End() m_state->sum2 = (m_state->sum2 & 0xff) + (m_state->sum2 >> 8); nzUInt32 fletcher = (m_state->sum2 << 8) | m_state->sum1; - if (NazaraEndianness == nzEndianness_BigEndian) - NzByteSwap(&fletcher, sizeof(nzUInt32)); + + #ifdef NAZARA_BIG_ENDIAN + NzByteSwap(&fletcher, sizeof(nzUInt32)); + #endif return NzHashDigest(GetHashName(), reinterpret_cast(&fletcher), 2); } diff --git a/src/Nazara/Core/Hash/MD5.cpp b/src/Nazara/Core/Hash/MD5.cpp index d27faa985..6570fc8cc 100644 --- a/src/Nazara/Core/Hash/MD5.cpp +++ b/src/Nazara/Core/Hash/MD5.cpp @@ -114,7 +114,7 @@ namespace nzUInt32 d = state->abcd[3]; nzUInt32 t; - #ifdef NAZARA_ENDIANNESS_BIGENDIAN + #ifdef NAZARA_BIG_ENDIAN /* Define storage only for big-endian CPUs. */ nzUInt32 X[16]; diff --git a/src/Nazara/Core/Hash/SHA/Internal.cpp b/src/Nazara/Core/Hash/SHA/Internal.cpp index 0ab51a9ce..734de4ede 100644 --- a/src/Nazara/Core/Hash/SHA/Internal.cpp +++ b/src/Nazara/Core/Hash/SHA/Internal.cpp @@ -42,7 +42,7 @@ #include /*** ENDIAN REVERSAL MACROS *******************************************/ -#ifdef NAZARA_ENDIANNESS_LITTLEENDIAN +#ifdef NAZARA_LITTLE_ENDIAN #define REVERSE32(w,x) { \ nzUInt32 tmp = (w); \ @@ -272,7 +272,7 @@ void SHA1_Init(SHA_CTX* context) context->s1.bitcount = 0; } -#ifdef NAZARA_ENDIANNESS_LITTLEENDIAN +#ifdef NAZARA_LITTLE_ENDIAN #define ROUND1_0_TO_15(a,b,c,d,e) \ REVERSE32(*data++, W1[j]); \ @@ -281,7 +281,7 @@ void SHA1_Init(SHA_CTX* context) (b) = ROTL32(30, (b)); \ j++; -#else // NAZARA_ENDIANNESS_LITTLEENDIAN +#else // NAZARA_LITTLE_ENDIAN #define ROUND1_0_TO_15(a,b,c,d,e) \ (e) = ROTL32(5, (a)) + Ch((b), (c), (d)) + (e) + \ @@ -289,7 +289,7 @@ void SHA1_Init(SHA_CTX* context) (b) = ROTL32(30, (b)); \ j++; -#endif // NAZARA_ENDIANNESS_LITTLEENDIAN +#endif // NAZARA_LITTLE_ENDIAN #define ROUND1_16_TO_19(a,b,c,d,e) \ T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; \ @@ -512,7 +512,7 @@ void SHA1_End(SHA_CTX* context, nzUInt8* digest) } } /* Set the bit count: */ -#ifdef NAZARA_ENDIANNESS_LITTLEENDIAN +#ifdef NAZARA_LITTLE_ENDIAN /* Convert FROM host byte order */ REVERSE64(context->s1.bitcount,context->s1.bitcount); #endif @@ -523,7 +523,7 @@ void SHA1_End(SHA_CTX* context, nzUInt8* digest) SHA1_Internal_Transform(context, reinterpret_cast(context->s1.buffer)); /* Save the hash data for output: */ -#ifdef NAZARA_ENDIANNESS_LITTLEENDIAN +#ifdef NAZARA_LITTLE_ENDIAN { /* Convert TO host byte order */ for (int j = 0; j < (SHA1_DIGEST_LENGTH >> 2); j++) @@ -551,7 +551,7 @@ void SHA256_Init(SHA_CTX* context) SHA256_Internal_Init(context, sha256_initial_hash_value); } -#ifdef NAZARA_ENDIANNESS_LITTLEENDIAN +#ifdef NAZARA_LITTLE_ENDIAN #define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \ REVERSE32(*data++, W256[j]); \ @@ -561,7 +561,7 @@ void SHA256_Init(SHA_CTX* context) (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ j++ -#else // NAZARA_ENDIANNESS_LITTLEENDIAN +#else // NAZARA_LITTLE_ENDIAN #define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \ T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \ @@ -570,7 +570,7 @@ void SHA256_Init(SHA_CTX* context) (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ j++ -#endif // NAZARA_ENDIANNESS_LITTLEENDIAN +#endif // NAZARA_LITTLE_ENDIAN #define ROUND256(a,b,c,d,e,f,g,h) \ s0 = W256[(j+1)&0x0f]; \ @@ -693,7 +693,7 @@ void SHA256_Update(SHA_CTX* context, const nzUInt8 *data, std::size_t len) void SHA256_Internal_Last(SHA_CTX* context) { unsigned int usedspace = (context->s256.bitcount >> 3) % 64; -#ifdef NAZARA_ENDIANNESS_LITTLEENDIAN +#ifdef NAZARA_LITTLE_ENDIAN /* Convert FROM host byte order */ REVERSE64(context->s256.bitcount,context->s256.bitcount); #endif @@ -744,7 +744,7 @@ void SHA256_End(SHA_CTX* context, nzUInt8* digest) SHA256_Internal_Last(context); /* Save the hash data for output: */ -#ifdef NAZARA_ENDIANNESS_LITTLEENDIAN +#ifdef NAZARA_LITTLE_ENDIAN { /* Convert TO host byte order */ for (int j = 0; j < (SHA256_DIGEST_LENGTH >> 2); j++) @@ -786,7 +786,7 @@ void SHA224_End(SHA_CTX* context, nzUInt8* digest) SHA256_Internal_Last(context); /* Save the hash data for output: */ -#ifdef NAZARA_ENDIANNESS_LITTLEENDIAN +#ifdef NAZARA_LITTLE_ENDIAN { /* Convert TO host byte order */ for (int j = 0; j < (SHA224_DIGEST_LENGTH >> 2); j++) @@ -816,7 +816,7 @@ void SHA512_Init(SHA_CTX* context) } /* Unrolled SHA-512 round macros: */ -#ifdef NAZARA_ENDIANNESS_LITTLEENDIAN +#ifdef NAZARA_LITTLE_ENDIAN #define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \ REVERSE64(*data++, W512[j]); \ @@ -827,7 +827,7 @@ void SHA512_Init(SHA_CTX* context) j++ -#else // NAZARA_ENDIANNESS_LITTLEENDIAN +#else // NAZARA_LITTLE_ENDIAN #define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \ T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \ @@ -836,7 +836,7 @@ void SHA512_Init(SHA_CTX* context) (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \ j++ -#endif // NAZARA_ENDIANNESS_LITTLEENDIAN +#endif // NAZARA_LITTLE_ENDIAN #define ROUND512(a,b,c,d,e,f,g,h) \ s0 = W512[(j+1)&0x0f]; \ @@ -958,7 +958,7 @@ void SHA512_Internal_Last(SHA_CTX* context) unsigned int usedspace; usedspace = (context->s512.bitcount[0] >> 3) % 128; -#ifdef NAZARA_ENDIANNESS_LITTLEENDIAN +#ifdef NAZARA_LITTLE_ENDIAN /* Convert FROM host byte order */ REVERSE64(context->s512.bitcount[0],context->s512.bitcount[0]); REVERSE64(context->s512.bitcount[1],context->s512.bitcount[1]); @@ -1011,7 +1011,7 @@ void SHA512_End(SHA_CTX* context, nzUInt8* digest) SHA512_Internal_Last(context); /* Save the hash data for output: */ -#ifdef NAZARA_ENDIANNESS_LITTLEENDIAN +#ifdef NAZARA_LITTLE_ENDIAN { /* Convert TO host byte order */ for (int j = 0; j < (SHA512_DIGEST_LENGTH >> 3); j++) @@ -1051,7 +1051,7 @@ void SHA384_End(SHA_CTX* context, nzUInt8* digest) SHA512_Internal_Last(context); /* Save the hash data for output: */ -#ifdef NAZARA_ENDIANNESS_LITTLEENDIAN +#ifdef NAZARA_LITTLE_ENDIAN { /* Convert TO host byte order */ for (int j = 0; j < (SHA384_DIGEST_LENGTH >> 3); j++) diff --git a/src/Nazara/Core/Win32/DirectoryImpl.hpp b/src/Nazara/Core/Win32/DirectoryImpl.hpp index ce4ce1ae1..799cee9c6 100644 --- a/src/Nazara/Core/Win32/DirectoryImpl.hpp +++ b/src/Nazara/Core/Win32/DirectoryImpl.hpp @@ -8,7 +8,7 @@ #define NAZARA_DIRECTORYIMPL_HPP #include -#include +#include #include class NzDirectory; diff --git a/src/Nazara/Core/Win32/DynLibImpl.hpp b/src/Nazara/Core/Win32/DynLibImpl.hpp index 4734a105d..6688a98fd 100644 --- a/src/Nazara/Core/Win32/DynLibImpl.hpp +++ b/src/Nazara/Core/Win32/DynLibImpl.hpp @@ -8,7 +8,7 @@ #define NAZARA_DYNLIBIMPL_HPP #include -#include +#include #include class NzString; diff --git a/src/Nazara/Core/Win32/FileImpl.hpp b/src/Nazara/Core/Win32/FileImpl.hpp index fac9186f3..8f3cf3ad0 100644 --- a/src/Nazara/Core/Win32/FileImpl.hpp +++ b/src/Nazara/Core/Win32/FileImpl.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include diff --git a/src/Nazara/Core/Win32/ThreadImpl.cpp b/src/Nazara/Core/Win32/ThreadImpl.cpp index 3a9c6ac65..e6a627e0b 100644 --- a/src/Nazara/Core/Win32/ThreadImpl.cpp +++ b/src/Nazara/Core/Win32/ThreadImpl.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include diff --git a/src/Nazara/Renderer/OpenGL.cpp b/src/Nazara/Renderer/OpenGL.cpp index 9e863a952..e76b224c6 100644 --- a/src/Nazara/Renderer/OpenGL.cpp +++ b/src/Nazara/Renderer/OpenGL.cpp @@ -383,10 +383,6 @@ bool NzOpenGL::Initialize() NzContextParameters::defaultMajorVersion = openGLversion/100; NzContextParameters::defaultMinorVersion = (openGLversion%100)/10; -/* - NzContextParameters::defaultMajorVersion = std::min(openGLversion/100, 2U); - NzContextParameters::defaultMinorVersion = std::min((openGLversion%100)/10, 1U); -*/ if (!NzContext::InitializeReference()) { NazaraError("Failed to initialize reference context"); diff --git a/src/Nazara/Utility/Image.cpp b/src/Nazara/Utility/Image.cpp index 04c753094..3e906de75 100644 --- a/src/Nazara/Utility/Image.cpp +++ b/src/Nazara/Utility/Image.cpp @@ -36,6 +36,79 @@ NzImage::~NzImage() ReleaseImage(); } +bool NzImage::Convert(nzPixelFormat format) +{ + if (format == m_sharedImage->format) + return true; + + #if NAZARA_UTILITY_SAFE + if (!IsValid()) + { + NazaraError("Image must be valid"); + return false; + } + + if (!NzPixelFormat::IsValid(format)) + { + NazaraError("Invalid pixel format"); + return false; + } + #endif + + EnsureOwnership(); + + unsigned int depth = (IsCubemap()) ? 6 : m_sharedImage->depth; + unsigned int pixelsPerFace = m_sharedImage->width*m_sharedImage->height; + + nzUInt8* buffer; + if (depth > 1) + { + // Les images 3D sont un empilement d'images 2D + // Quant aux cubemaps, ils sont stockés côte à côte, ce qui revient au même + buffer = new nzUInt8[pixelsPerFace*depth*NzPixelFormat::GetBPP(format)]; + + nzUInt8* ptr = buffer; + nzUInt8* pixels = m_sharedImage->pixels; + unsigned int srcStride = pixelsPerFace * NzPixelFormat::GetBPP(m_sharedImage->format); + unsigned int dstStride = pixelsPerFace * NzPixelFormat::GetBPP(format); + + for (unsigned int i = 0; i < depth; ++i) + { + if (!NzPixelFormat::Convert(m_sharedImage->format, format, pixels, &pixels[srcStride], ptr)) + { + NazaraError("Failed to convert image"); + delete[] buffer; + + return false; + } + + pixels += srcStride; + ptr += dstStride; + } + + delete[] buffer; + } + else + { + buffer = new nzUInt8[pixelsPerFace*NzPixelFormat::GetBPP(format)]; + + if (!NzPixelFormat::Convert(m_sharedImage->format, format, m_sharedImage->pixels, &m_sharedImage->pixels[pixelsPerFace*NzPixelFormat::GetBPP(m_sharedImage->format)], buffer)) + { + NazaraError("Failed to convert image"); + delete[] buffer; + + return false; + } + } + + delete[] m_sharedImage->pixels; + + m_sharedImage->format = format; + m_sharedImage->pixels = buffer; + + return true; +} + bool NzImage::Copy(const NzImage& source, const NzRectui& srcRect, const NzVector2ui& dstPos) { #if NAZARA_UTILITY_SAFE @@ -78,6 +151,14 @@ bool NzImage::Create(nzImageType type, nzPixelFormat format, unsigned int width, { ReleaseImage(); + #if NAZARA_UTILITY_SAFE + if (!NzPixelFormat::IsValid(format)) + { + NazaraError("Invalid pixel format"); + return false; + } + #endif + unsigned int size = width*height*depth*NzPixelFormat::GetBPP(format); if (size == 0) return true; @@ -131,7 +212,19 @@ bool NzImage::Create(nzImageType type, nzPixelFormat format, unsigned int width, size *= 6; // Les cubemaps ont six faces #endif - m_sharedImage = new SharedImage(1, type, format, new nzUInt8[size], width, height, depth); + // Cette allocation est protégée car sa taille dépend directement de paramètres utilisateurs + nzUInt8* buffer; + try + { + buffer = new nzUInt8[size]; + } + catch (const std::exception& e) + { + NazaraError("Failed to allocate image buffer (" + NzString(e.what()) + ')'); + return false; + } + + m_sharedImage = new SharedImage(1, type, format, buffer, width, height, depth); return true; } @@ -472,4 +565,4 @@ void NzImage::ReleaseImage() m_sharedImage = &emptyImage; } -NzImage::SharedImage NzImage::emptyImage(0, nzImageType_2D, nzPixelFormat_R8G8B8, nullptr, 0, 0, 0); +NzImage::SharedImage NzImage::emptyImage(0, nzImageType_2D, nzPixelFormat_Undefined, nullptr, 0, 0, 0); diff --git a/src/Nazara/Utility/Loaders/PCX.cpp b/src/Nazara/Utility/Loaders/PCX.cpp index 67f8a803e..0eab2c186 100644 --- a/src/Nazara/Utility/Loaders/PCX.cpp +++ b/src/Nazara/Utility/Loaders/PCX.cpp @@ -74,7 +74,7 @@ namespace return false; } - #if NAZARA_ENDIANNESS_BIGENDIAN + #if NAZARA_BIG_ENDIAN // Les fichiers PCX sont en little endian NzByteSwap(&header.xmin, sizeof(nzUInt16)); NzByteSwap(&header.ymin, sizeof(nzUInt16)); @@ -93,7 +93,7 @@ namespace unsigned int width = header.xmax - header.xmin+1; unsigned int height = header.ymax - header.ymin+1; - if (!resource->Create(nzImageType_2D, nzPixelFormat_R8G8B8, width, height)) + if (!resource->Create(nzImageType_2D, nzPixelFormat_RGB8, width, height)) { NazaraError("Failed to create image"); return false; @@ -343,6 +343,9 @@ namespace return false; } + if (parameters.loadFormat != nzPixelFormat_Undefined) + resource->Convert(parameters.loadFormat); + return true; } diff --git a/src/Nazara/Utility/Loaders/STB.cpp b/src/Nazara/Utility/Loaders/STB.cpp index 10441f4e3..d4910e6ef 100644 --- a/src/Nazara/Utility/Loaders/STB.cpp +++ b/src/Nazara/Utility/Loaders/STB.cpp @@ -63,15 +63,44 @@ namespace { NazaraUnused(parameters); - static nzPixelFormat format[4] = { + static nzPixelFormat formats[4] = { nzPixelFormat_L8, - nzPixelFormat_L8A8, - nzPixelFormat_R8G8B8, - nzPixelFormat_R8G8B8A8 + nzPixelFormat_LA8, + nzPixelFormat_RGB8, + nzPixelFormat_RGBA8 }; + nzPixelFormat format; + int stbiFormat; + switch (parameters.loadFormat) + { + case nzPixelFormat_L8: + format = nzPixelFormat_L8; + stbiFormat = STBI_grey; + break; + + case nzPixelFormat_LA8: + format = nzPixelFormat_LA8; + stbiFormat = STBI_grey_alpha; + break; + + case nzPixelFormat_RGB8: + format = nzPixelFormat_RGB8; + stbiFormat = STBI_rgb; + break; + + case nzPixelFormat_RGBA8: + format = nzPixelFormat_RGBA8; + stbiFormat = STBI_rgb_alpha; + break; + + default: + format = nzPixelFormat_Undefined; + stbiFormat = STBI_default; + } + int width, height, bpp; - nzUInt8* ptr = stbi_load_from_callbacks(&callbacks, &stream, &width, &height, &bpp, STBI_default); + nzUInt8* ptr = stbi_load_from_callbacks(&callbacks, &stream, &width, &height, &bpp, stbiFormat); if (!ptr) { @@ -79,7 +108,10 @@ namespace return false; } - if (!resource->Create(nzImageType_2D, format[bpp-1], width, height)) + if (format == nzPixelFormat_Undefined) + format = formats[bpp-1]; + + if (!resource->Create(nzImageType_2D, format, width, height)) { NazaraError("Failed to create image"); stbi_image_free(ptr); @@ -90,6 +122,9 @@ namespace resource->Update(ptr); stbi_image_free(ptr); + if (stbiFormat == STBI_default && parameters.loadFormat != nzPixelFormat_Undefined) + resource->Convert(parameters.loadFormat); + return true; } diff --git a/src/Nazara/Utility/PixelFormat.cpp b/src/Nazara/Utility/PixelFormat.cpp new file mode 100644 index 000000000..de721769b --- /dev/null +++ b/src/Nazara/Utility/PixelFormat.cpp @@ -0,0 +1,1161 @@ +// Copyright (C) 2012 Jérôme Leclercq +// This file is part of the "Nazara Engine". +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +///FIXME: Endianness (nzUInt16) + +namespace +{ + inline nzUInt8 c4to8(nzUInt8 c) + { + return c * 255.f/15.f; + } + + inline nzUInt8 c5to8(nzUInt8 c) + { + return c * 255.f/31.f; + } + + inline nzUInt8 c8to4(nzUInt8 c) + { + return c * 15.f/255.f; + } + + inline nzUInt8 c8to5(nzUInt8 c) + { + return c * 31.f/255.f; + } + + template + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + NazaraUnused(start); + NazaraUnused(dst); + NazaraUnused(end); + + NazaraInternalError("Conversion from " + NzPixelFormat::ToString(from) + " to " + NzPixelFormat::ToString(to) + " is not supported"); + return nullptr; + } + + /**********************************BGR8***********************************/ + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[0]; + *dst++ = start[1]; + *dst++ = start[2]; + *dst++ = 0xFF; + + start += 3; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = static_cast(start[2] * 0.3 + start[1] * 0.59 + start[0] * 0.11); + + start += 3; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = static_cast(start[2] * 0.3 + start[1] * 0.59 + start[0] * 0.11); + *dst++ = 0xFF; + + start += 3; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = ((c8to4(start[2])) << 4) | c8to4(start[1]); + *dst++ = ((c8to4(start[0])) << 4) | 0x0F; + + start += 3; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + nzUInt16* ptr = reinterpret_cast(dst); + while (start < end) + { + *ptr++ = (static_cast(c8to5(start[2])) << 11) | + (static_cast(c8to5(start[1])) << 6) | + (static_cast(c8to5(start[0])) << 1) | + 0x1; + + start += 3; + } + + return reinterpret_cast(ptr); + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[2]; + *dst++ = start[1]; + *dst++ = start[0]; + + start += 3; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[2]; + *dst++ = start[1]; + *dst++ = start[0]; + *dst++ = 0xFF; + + start += 3; + } + + return dst; + } + + /**********************************BGRA8**********************************/ + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[0]; + *dst++ = start[1]; + *dst++ = start[2]; + + start += 4; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = static_cast(start[2] * 0.3 + start[1] * 0.59 + start[0] * 0.11); + + start += 4; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = static_cast(start[2] * 0.3 + start[1] * 0.59 + start[0] * 0.11); + *dst++ = start[3]; + + start += 4; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = (c8to4(start[2]) << 4) | c8to4(start[1]); + *dst++ = (c8to4(start[0]) << 4) | c8to4(start[3]); + + start += 4; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + nzUInt16* ptr = reinterpret_cast(dst); + while (start < end) + { + *ptr++ = (static_cast(c8to5(start[2])) << 11) | + (static_cast(c8to5(start[1])) << 6) | + (static_cast(c8to5(start[0])) << 1) | + ((start[3] == 0xFF) ? 1 : 0); + + start += 4; + } + + return reinterpret_cast(ptr); + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[2]; + *dst++ = start[1]; + *dst++ = start[0]; + + start += 4; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[2]; + *dst++ = start[1]; + *dst++ = start[0]; + *dst++ = start[3]; + + start += 4; + } + + return dst; + } + + /***********************************L8************************************/ + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[0]; + *dst++ = start[0]; + *dst++ = start[0]; + + start += 1; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[0]; + *dst++ = start[0]; + *dst++ = start[0]; + *dst++ = 0xFF; + + start += 1; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[0]; + *dst++ = 0xFF; + + start += 1; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + nzUInt8 l = c8to4(start[0]); + + *dst++ = (l << 4) | l; + *dst++ = (l << 4) | 0x0F; + + start += 1; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + nzUInt16* ptr = reinterpret_cast(dst); + while (start < end) + { + nzUInt16 l = static_cast(c8to5(start[0])); + + *ptr++ = (l << 11) | + (l << 6) | + (l << 1) | + 1; + + start += 1; + } + + return reinterpret_cast(ptr); + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[0]; + *dst++ = start[0]; + *dst++ = start[0]; + + start += 1; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[0]; + *dst++ = start[0]; + *dst++ = start[0]; + *dst++ = 0xFF; + + start += 1; + } + + return dst; + } + + /***********************************LA8***********************************/ + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[0]; + *dst++ = start[0]; + *dst++ = start[0]; + + start += 2; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[0]; + *dst++ = start[0]; + *dst++ = start[0]; + *dst++ = start[1]; + + start += 2; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[0]; + + start += 2; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + nzUInt8 l = c8to4(start[0]); + + *dst++ = (l << 4) | l; + *dst++ = (l << 4) | c8to4(start[1]); + + start += 2; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + nzUInt16* ptr = reinterpret_cast(dst); + while (start < end) + { + nzUInt16 l = static_cast(c8to5(start[0])); + + *ptr++ = (l << 11) | (l << 6) | (l << 1) | ((start[1] == 0xFF) ? 1 : 0); + + start += 2; + } + + return reinterpret_cast(ptr); + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[0]; + *dst++ = start[0]; + *dst++ = start[0]; + + start += 2; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[0]; + *dst++ = start[0]; + *dst++ = start[0]; + *dst++ = start[1]; + + start += 2; + } + + return dst; + } + + /*********************************RGBA4***********************************/ + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = (c4to8((start[1] & 0xF0) >> 4)); + *dst++ = (c4to8((start[0] & 0x0F) >> 0)); + *dst++ = (c4to8((start[0] & 0xF0) >> 4)); + + start += 2; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = c4to8((start[1] & 0xF0) >> 4); + *dst++ = c4to8((start[0] & 0x0F) >> 0); + *dst++ = c4to8((start[0] & 0xF0) >> 4); + *dst++ = c4to8((start[1] & 0x0F) >> 0); + + start += 2; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + nzUInt8 r = c4to8((start[0] & 0xF0) >> 4); + nzUInt8 g = c4to8((start[0] & 0x0F) >> 0); + nzUInt8 b = c4to8((start[1] & 0xF0) >> 4); + + *dst++ = static_cast(r * 0.3 + g * 0.59 + b * 0.11); + + start += 2; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + nzUInt8 r = c4to8((start[0] & 0xF0) >> 4); + nzUInt8 g = c4to8((start[0] & 0x0F) >> 0); + nzUInt8 b = c4to8((start[1] & 0xF0) >> 4); + + *dst++ = static_cast(r * 0.3 + g * 0.59 + b * 0.11); + *dst++ = c4to8(start[1] & 0x0F); + + start += 2; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + nzUInt16* ptr = reinterpret_cast(dst); + while (start < end) + { + nzUInt16 r = (start[0] & 0xF0) >> 4; + nzUInt16 g = (start[0] & 0x0F) >> 0; + nzUInt16 b = (start[1] & 0xF0) >> 4; + nzUInt8 a = (start[1] & 0x0F) >> 0; + + *ptr++ = (r << 11) | (g << 6) | (b << 1) | ((a == 0xFF) ? 1 : 0); + + start += 2; + } + + return reinterpret_cast(ptr); + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = c4to8((start[0] & 0xF0) >> 4); + *dst++ = c4to8((start[0] & 0x0F) >> 0); + *dst++ = c4to8((start[1] & 0xF0) >> 4); + + start += 2; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = c4to8((start[0] & 0xF0) >> 4); + *dst++ = c4to8((start[0] & 0x0F) >> 0); + *dst++ = c4to8((start[1] & 0xF0) >> 4); + *dst++ = c4to8((start[1] & 0x0F) >> 0); + + start += 2; + } + + return dst; + } + + /*********************************RGB5A1**********************************/ + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + nzUInt16 pixel = *reinterpret_cast(start); + + *dst++ = c5to8((pixel & 0x003E) >> 1); + *dst++ = c5to8((pixel & 0x07C0) >> 6); + *dst++ = c5to8((pixel & 0xF800) >> 11); + + start += 2; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + nzUInt16 pixel = *reinterpret_cast(start); + + *dst++ = c5to8((pixel & 0x003E) >> 1); + *dst++ = c5to8((pixel & 0x07C0) >> 6); + *dst++ = c5to8((pixel & 0xF800) >> 11); + *dst++ = static_cast((pixel & 0x1)*0xFF); + + start += 2; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + nzUInt16 pixel = *reinterpret_cast(start); + + nzUInt8 r = c5to8((pixel & 0xF800) >> 11); + nzUInt8 g = c5to8((pixel & 0x07C0) >> 6); + nzUInt8 b = c5to8((pixel & 0x003E) >> 1); + + *dst++ = static_cast(r * 0.3 + g * 0.59 + b * 0.11); + + start += 2; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + nzUInt16 pixel = *reinterpret_cast(start); + + nzUInt8 r = c5to8((pixel & 0xF800) >> 11); + nzUInt8 g = c5to8((pixel & 0x07C0) >> 6); + nzUInt8 b = c5to8((pixel & 0x003E) >> 1); + + *dst++ = static_cast(r * 0.3 + g * 0.59 + b * 0.11); + *dst++ = static_cast((pixel & 0x1)*0xFF); + + start += 2; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + nzUInt16 pixel = *reinterpret_cast(start); + + nzUInt8 r = c5to8((pixel & 0xF800) >> 11); + nzUInt8 g = c5to8((pixel & 0x07C0) >> 6); + nzUInt8 b = c5to8((pixel & 0x003E) >> 1); + + *dst++ = (c8to4(r) << 4) | c8to4(g); + *dst++ = (c8to4(b) << 4) | ((pixel & 0x1)*0x0F); + + start += 2; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + nzUInt16 pixel = *reinterpret_cast(start); + + *dst++ = c5to8((pixel & 0xF800) >> 11); + *dst++ = c5to8((pixel & 0x07C0) >> 6); + *dst++ = c5to8((pixel & 0x003E) >> 1); + + start += 2; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + nzUInt16 pixel = *reinterpret_cast(start); + + *dst++ = c5to8((pixel & 0xF800) >> 11); + *dst++ = c5to8((pixel & 0x07C0) >> 6); + *dst++ = c5to8((pixel & 0x003E) >> 1); + *dst++ = static_cast((pixel & 0x1)*0xFF); + + start += 2; + } + + return dst; + } + + /**********************************RGB8***********************************/ + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[2]; + *dst++ = start[1]; + *dst++ = start[0]; + + start += 3; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[2]; + *dst++ = start[1]; + *dst++ = start[0]; + *dst++ = 0xFF; + + start += 3; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = static_cast(start[0] * 0.3 + start[1] * 0.59 + start[2] * 0.11); + + start += 3; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = static_cast(start[0] * 0.3 + start[1] * 0.59 + start[2] * 0.11); + *dst++ = 0xFF; + + start += 3; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = (c8to4(start[0]) << 4) | c8to4(start[1]); + *dst++ = (c8to4(start[2]) << 4) | 0x0F; + + start += 3; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + nzUInt16* ptr = reinterpret_cast(dst); + while (start < end) + { + NazaraWarning("r: " + NzString::Number(c8to5(start[0]))); + + *ptr++ = (static_cast(c8to5(start[0])) << 11) | + (static_cast(c8to5(start[1])) << 6) | + (static_cast(c8to5(start[2])) << 1) | + 0x1; + + start += 3; + } + + return reinterpret_cast(ptr); + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[0]; + *dst++ = start[1]; + *dst++ = start[2]; + *dst++ = 0xFF; + + start += 3; + } + + return dst; + } + + /**********************************RGBA8**********************************/ + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[2]; + *dst++ = start[1]; + *dst++ = start[0]; + + start += 4; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[2]; + *dst++ = start[1]; + *dst++ = start[0]; + *dst++ = start[3]; + + start += 4; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = static_cast(start[0] * 0.3 + start[1] * 0.59 + start[2] * 0.11); + + start += 4; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = static_cast(start[0] * 0.3 + start[1] * 0.59 + start[2] * 0.11); + *dst++ = start[3]; + + start += 4; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = (c8to4(start[0]) << 4) | c8to4(start[1]); + *dst++ = (c8to4(start[2]) << 4) | c8to4(start[3]); + + start += 4; + } + + return dst; + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + nzUInt16* ptr = reinterpret_cast(dst); + while (start < end) + { + *ptr++ = (static_cast(c8to5(start[0])) << 11) | + (static_cast(c8to5(start[1])) << 6) | + (static_cast(c8to5(start[2])) << 1) | + ((start[3] == 0xFF) ? 1 : 0); + + start += 4; + } + + return reinterpret_cast(ptr); + } + + template<> + nzUInt8* ConvertPixels(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst) + { + while (start < end) + { + *dst++ = start[0]; + *dst++ = start[1]; + *dst++ = start[2]; + + start += 4; + } + + return dst; + } + + template + void RegisterConverter() + { + NzPixelFormat::SetConvertFunction(format1, format2, &ConvertPixels); + } +} + +bool NzPixelFormat::Initialize() +{ + /**********************************BGR8***********************************/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter();/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();*/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + + /**********************************BGRA8**********************************/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter();/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();*/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + + /**********************************DXT1***********************************/ + ///TODO +/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); +*/ + + /**********************************DXT3***********************************/ + ///TODO +/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); +*/ + + /**********************************DXT5***********************************/ + ///TODO +/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); +*/ + + /***********************************L8************************************/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter();/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();*/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + + /***********************************LA8***********************************/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter();/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();*/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + + /**********************************RGBA4**********************************/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();*/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + + /*********************************RGB5A1**********************************/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();*/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + + /**********************************RGB8***********************************/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();*/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + + /**********************************RGBA8**********************************/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();*/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + + return true; +} + +void NzPixelFormat::Uninitialize() +{ + std::memset(s_convertFunctions, 0, nzPixelFormat_Count*nzPixelFormat_Count*sizeof(NzPixelFormat::ConvertFunction)); +} + +NzPixelFormat::ConvertFunction NzPixelFormat::s_convertFunctions[nzPixelFormat_Count][nzPixelFormat_Count] = {{0}}; diff --git a/src/Nazara/Utility/Utility.cpp b/src/Nazara/Utility/Utility.cpp index 02bc5576e..64de352dc 100644 --- a/src/Nazara/Utility/Utility.cpp +++ b/src/Nazara/Utility/Utility.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include NzUtility::NzUtility() @@ -29,6 +30,12 @@ bool NzUtility::Initialize() } #endif + if (!NzPixelFormat::Initialize()) + { + NazaraError("Failed to initialize pixel format"); + return false; + } + // Loaders spécialisés NzLoaders_PCX_Register(); // Loader de fichiers .PCX (1, 4, 8, 24) @@ -53,6 +60,8 @@ void NzUtility::Uninitialize() NzLoaders_STB_Unregister(); NzLoaders_PCX_Unregister(); + NzPixelFormat::Uninitialize(); + s_initialized = false; } diff --git a/src/Nazara/Utility/Win32/WindowImpl.hpp b/src/Nazara/Utility/Win32/WindowImpl.hpp index 99a6025c9..caf84d163 100644 --- a/src/Nazara/Utility/Win32/WindowImpl.hpp +++ b/src/Nazara/Utility/Win32/WindowImpl.hpp @@ -9,12 +9,12 @@ #ifndef NAZARA_WINDOWIMPL_HPP #define NAZARA_WINDOWIMPL_HPP +#include #include #include #include #include #include -#include #include #include #include