diff --git a/NazaraModuleTemplate/build/scripts/module/modulename.lua b/NazaraModuleTemplate/build/scripts/module/modulename.lua index 0fa66f65e..cd24f2d12 100644 --- a/NazaraModuleTemplate/build/scripts/module/modulename.lua +++ b/NazaraModuleTemplate/build/scripts/module/modulename.lua @@ -17,7 +17,7 @@ else end if (_OPTIONS["united"]) then - excludes "../src/Nazara/ModuleName/Debug/Leaks.cpp" + excludes "../src/Nazara/ModuleName/Debug/NewOverload.cpp" else configuration "DebugStatic" links "NazaraCore-s-d" diff --git a/NazaraModuleTemplate/include/Nazara/ModuleName/Config.hpp b/NazaraModuleTemplate/include/Nazara/ModuleName/Config.hpp index c9e04ae5e..9257290da 100644 --- a/NazaraModuleTemplate/include/Nazara/ModuleName/Config.hpp +++ b/NazaraModuleTemplate/include/Nazara/ModuleName/Config.hpp @@ -29,10 +29,15 @@ /// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci -// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks, ralenti l'exécution) -#define NAZARA_MODULENAME_MEMORYMANAGER 0 +// Utilise le MemoryManager pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) +#define NAZARA_MODULENAME_MANAGE_MEMORY 0 // Active les tests de sécurité basés sur le code (Conseillé pour le développement) #define NAZARA_MODULENAME_SAFE 1 +/// Chaque modification d'un paramètre ci-dessous implique une modification (souvent mineure) du code + +/// Vérification des valeurs et types de certaines constantes +#include + #endif // NAZARA_CONFIG_MODULENAME_HPP diff --git a/NazaraModuleTemplate/include/Nazara/ModuleName/ConfigCheck.hpp b/NazaraModuleTemplate/include/Nazara/ModuleName/ConfigCheck.hpp new file mode 100644 index 000000000..25bf87f19 --- /dev/null +++ b/NazaraModuleTemplate/include/Nazara/ModuleName/ConfigCheck.hpp @@ -0,0 +1,22 @@ +// Copyright (C) 2014 AUTHORS +// This file is part of the "Nazara Engine - Module name" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_CONFIG_CHECK_MODULENAME_HPP +#define NAZARA_CONFIG_CHECK_MODULENAME_HPP + +/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp + +#include +#define CheckType(name, type, err) static_assert(std::is_ ##type ::value, #type err) +#define CheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type ::value && name op val, #type err) + +// On force la valeur de MANAGE_MEMORY en mode debug +#if defined(NAZARA_DEBUG) && !NAZARA_MODULENAME_MANAGE_MEMORY + #undef NAZARA_MODULENAME_MANAGE_MEMORY + #define NAZARA_MODULENAME_MANAGE_MEMORY 1 +#endif + +#endif // NAZARA_CONFIG_CHECK_MODULENAME_HPP diff --git a/NazaraModuleTemplate/include/Nazara/ModuleName/Debug.hpp b/NazaraModuleTemplate/include/Nazara/ModuleName/Debug.hpp index 70a0d3030..22128629b 100644 --- a/NazaraModuleTemplate/include/Nazara/ModuleName/Debug.hpp +++ b/NazaraModuleTemplate/include/Nazara/ModuleName/Debug.hpp @@ -3,9 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_MODULENAME_MEMORYMANAGER || defined(NAZARA_DEBUG) - #include - - #define delete NzMemoryManager::NextFree(__FILE__, __LINE__), delete - #define new new(__FILE__, __LINE__) +#if NAZARA_MODULENAME_MANAGE_MEMORY + #include #endif diff --git a/NazaraModuleTemplate/include/Nazara/ModuleName/DebugOff.hpp b/NazaraModuleTemplate/include/Nazara/ModuleName/DebugOff.hpp index 7ba52e986..b2106a5f4 100644 --- a/NazaraModuleTemplate/include/Nazara/ModuleName/DebugOff.hpp +++ b/NazaraModuleTemplate/include/Nazara/ModuleName/DebugOff.hpp @@ -2,7 +2,8 @@ // This file is part of the "Nazara Engine - Module name" // For conditions of distribution and use, see copyright notice in Config.hpp -#if NAZARA_MODULENAME_MEMORYMANAGER || defined(NAZARA_DEBUG) +// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp +#if NAZARA_MODULENAME_HPP #undef delete #undef new #endif diff --git a/NazaraModuleTemplate/src/Nazara/ModuleName/Debug/Leaks.cpp b/NazaraModuleTemplate/src/Nazara/ModuleName/Debug/NewOverload.cpp similarity index 74% rename from NazaraModuleTemplate/src/Nazara/ModuleName/Debug/Leaks.cpp rename to NazaraModuleTemplate/src/Nazara/ModuleName/Debug/NewOverload.cpp index 433220fae..468fb119e 100644 --- a/NazaraModuleTemplate/src/Nazara/ModuleName/Debug/Leaks.cpp +++ b/NazaraModuleTemplate/src/Nazara/ModuleName/Debug/NewOverload.cpp @@ -3,10 +3,10 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_MODULENAME_MEMORYMANAGER || defined(NAZARA_DEBUG) -#define NAZARA_DEBUG_MEMORYMANAGER_DISABLE_REDEFINITION -#include -#include +#if NAZARA_MODULENAME_MANAGE_MEMORY + +#include +#include // Nécessaire ? void* operator new(std::size_t size) { @@ -27,4 +27,5 @@ void operator delete[](void* pointer) noexcept { NzMemoryManager::Free(pointer, true); } -#endif + +#endif // NAZARA_MODULENAME_MANAGE_MEMORY diff --git a/build/scripts/module/audio.lua b/build/scripts/module/audio.lua index 38d5e5433..5da7dc9ac 100644 --- a/build/scripts/module/audio.lua +++ b/build/scripts/module/audio.lua @@ -21,7 +21,7 @@ else end if (_OPTIONS["united"]) then - excludes "../src/Nazara/Audio/Debug/Leaks.cpp" + excludes "../src/Nazara/Audio/Debug/NewOverload.cpp" else configuration "DebugStatic" links "NazaraCore-s-d" diff --git a/build/scripts/module/graphics.lua b/build/scripts/module/graphics.lua index ee7932783..34d33e1d0 100644 --- a/build/scripts/module/graphics.lua +++ b/build/scripts/module/graphics.lua @@ -17,7 +17,7 @@ else end if (_OPTIONS["united"]) then - excludes "../src/Nazara/Graphics/Debug/Leaks.cpp" + excludes "../src/Nazara/Graphics/Debug/NewOverload.cpp" else configuration "DebugStatic" links "NazaraCore-s-d" diff --git a/build/scripts/module/lua.lua b/build/scripts/module/lua.lua index 57a36f60a..934753399 100644 --- a/build/scripts/module/lua.lua +++ b/build/scripts/module/lua.lua @@ -17,7 +17,7 @@ else end if (_OPTIONS["united"]) then - excludes "../src/Nazara/Lua/Debug/Leaks.cpp" + excludes "../src/Nazara/Lua/Debug/NewOverload.cpp" else configuration "DebugStatic" links "NazaraCore-s-d" diff --git a/build/scripts/module/noise.lua b/build/scripts/module/noise.lua index c7fa9c548..ec1c9a017 100644 --- a/build/scripts/module/noise.lua +++ b/build/scripts/module/noise.lua @@ -17,7 +17,7 @@ else end if (_OPTIONS["united"]) then - excludes "../src/Nazara/Noise/Debug/Leaks.cpp" + excludes "../src/Nazara/Noise/Debug/NewOverload.cpp" else configuration "DebugStatic" links "NazaraCore-s-d" diff --git a/build/scripts/module/physics.lua b/build/scripts/module/physics.lua index edc301b66..09deb9c63 100644 --- a/build/scripts/module/physics.lua +++ b/build/scripts/module/physics.lua @@ -17,7 +17,7 @@ else end if (_OPTIONS["united"]) then - excludes "../src/Nazara/Physics/Debug/Leaks.cpp" + excludes "../src/Nazara/Physics/Debug/NewOverload.cpp" else configuration "DebugStatic" links "NazaraCore-s-d" diff --git a/build/scripts/module/renderer.lua b/build/scripts/module/renderer.lua index 83eeecd57..0acdb85a4 100644 --- a/build/scripts/module/renderer.lua +++ b/build/scripts/module/renderer.lua @@ -22,7 +22,7 @@ else end if (_OPTIONS["united"]) then - excludes "../src/Nazara/Renderer/Debug/Leaks.cpp" + excludes "../src/Nazara/Renderer/Debug/NewOverload.cpp" else configuration "DebugStatic" links "NazaraCore-s-d" diff --git a/build/scripts/module/utility.lua b/build/scripts/module/utility.lua index 2006ba9f1..ba88c4c3b 100644 --- a/build/scripts/module/utility.lua +++ b/build/scripts/module/utility.lua @@ -18,7 +18,7 @@ else end if (_OPTIONS["united"]) then - excludes "../src/Nazara/Utility/Debug/Leaks.cpp" + excludes "../src/Nazara/Utility/Debug/NewOverload.cpp" else configuration "DebugStatic" links "NazaraCore-s-d" diff --git a/include/Nazara/Audio/Config.hpp b/include/Nazara/Audio/Config.hpp index 26f7e7c36..0adc2c04f 100644 --- a/include/Nazara/Audio/Config.hpp +++ b/include/Nazara/Audio/Config.hpp @@ -27,15 +27,18 @@ #ifndef NAZARA_CONFIG_AUDIO_HPP #define NAZARA_CONFIG_AUDIO_HPP -/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci +/// Modifier la configuration d'un module nécessite une recompilation quasi-intégrale de celui-ci et de ceux en héritant -// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks, ralenti l'exécution) -#define NAZARA_AUDIO_MEMORYMANAGER 0 +// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) +#define NAZARA_AUDIO_MANAGE_MEMORY 0 -// Active les tests de sécurité basés sur le code (Conseillé pour le développement) +// Active les tests de sécurité supplémentaires (Teste notamment les arguments des fonctions, conseillé pour le développement) #define NAZARA_AUDIO_SAFE 1 // Le nombre de buffers utilisés lors du streaming d'objets audio (Au moins deux) -#define NAZARA_AUDIO_STREAMEDBUFFERCOUNT 2 +#define NAZARA_AUDIO_STREAMED_BUFFER_COUNT 2 + +/// Vérification des valeurs et types de certaines constantes +#include #endif // NAZARA_CONFIG_AUDIO_HPP diff --git a/include/Nazara/Audio/ConfigCheck.hpp b/include/Nazara/Audio/ConfigCheck.hpp new file mode 100644 index 000000000..e102d56ab --- /dev/null +++ b/include/Nazara/Audio/ConfigCheck.hpp @@ -0,0 +1,23 @@ +// Copyright (C) 2014 Jérôme Leclercq +// This file is part of the "Nazara Engine - Audio module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_CONFIG_CHECK_AUDIO_HPP +#define NAZARA_CONFIG_CHECK_AUDIO_HPP + +/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp + +#include +#define CheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type ::value && name op val, #type err) + +// On force la valeur de MANAGE_MEMORY en mode debug +#if defined(NAZARA_DEBUG) && !NAZARA_AUDIO_MANAGE_MEMORY + #undef NAZARA_AUDIO_MANAGE_MEMORY + #define NAZARA_AUDIO_MANAGE_MEMORY 1 +#endif + +CheckTypeAndVal(NAZARA_AUDIO_STREAMED_BUFFER_COUNT, integral, >, 0, " shall be a strictly positive integer"); + +#endif // NAZARA_CONFIG_CHECK_AUDIO_HPP diff --git a/include/Nazara/Audio/Debug.hpp b/include/Nazara/Audio/Debug.hpp index 84443d217..ae84c7a0c 100644 --- a/include/Nazara/Audio/Debug.hpp +++ b/include/Nazara/Audio/Debug.hpp @@ -3,6 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_AUDIO_MEMORYMANAGER || defined(NAZARA_DEBUG) - #include +#if NAZARA_AUDIO_MANAGE_MEMORY + #include #endif diff --git a/include/Nazara/Audio/DebugOff.hpp b/include/Nazara/Audio/DebugOff.hpp index 12cbf8a80..c91fba4e5 100644 --- a/include/Nazara/Audio/DebugOff.hpp +++ b/include/Nazara/Audio/DebugOff.hpp @@ -2,7 +2,8 @@ // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp -#if NAZARA_AUDIO_MEMORYMANAGER || defined(NAZARA_DEBUG) +// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp +#if NAZARA_AUDIO_MANAGE_MEMORY #undef delete #undef new #endif diff --git a/include/Nazara/Core/Config.hpp b/include/Nazara/Core/Config.hpp index d1df252c9..a8c33e665 100644 --- a/include/Nazara/Core/Config.hpp +++ b/include/Nazara/Core/Config.hpp @@ -29,6 +29,9 @@ /// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci +// Précision des réels lors de la transformation en chaîne de caractère (Max. chiffres après la virgule) +#define NAZARA_CORE_DECIMAL_DIGITS 6 + // Duplique la sortie du log sur le flux de sortie standard (cout) #define NAZARA_CORE_DUPLICATE_LOG_TO_COUT 0 @@ -44,11 +47,8 @@ // Incorpore la table Unicode Character Data (Nécessaires pour faire fonctionner le flag NzString::HandleUTF8) #define NAZARA_CORE_INCLUDE_UNICODEDATA 0 -// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks, ralenti l'exécution) -#define NAZARA_CORE_MEMORYMANAGER 0 - -// Précision des réels lors de la transformation en texte (Max. chiffres après la virgule) -#define NAZARA_CORE_REAL_PRECISION 6 +// Utilise le MemoryManager pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) +#define NAZARA_CORE_MANAGE_MEMORY 0 // Active les tests de sécurité basés sur le code (Conseillé pour le développement) #define NAZARA_CORE_SAFE 1 @@ -64,7 +64,7 @@ #define NAZARA_THREADSAFETY_LOG 1 // NzLog #define NAZARA_THREADSAFETY_RESOURCE 1 // NzResource -// Le nombre de spinlocks à utiliser avec les critical sections de Windows (0 pour désactiver) +// Le nombre de spinlocks à utiliser avec les sections critiques de Windows (0 pour désactiver) #define NAZARA_CORE_WINDOWS_CS_SPINLOCKS 4096 // Optimise l'implémentation Windows avec certaines avancées de Windows vista (Casse la compatibilité XP) @@ -75,4 +75,7 @@ #define NAZARA_CORE_TIMER_WAKEUPTIME 10 */ +/// Vérification des valeurs et types de certaines constantes +#include + #endif // NAZARA_CONFIG_CORE_HPP diff --git a/include/Nazara/Core/ConfigCheck.hpp b/include/Nazara/Core/ConfigCheck.hpp new file mode 100644 index 000000000..a5d0b3772 --- /dev/null +++ b/include/Nazara/Core/ConfigCheck.hpp @@ -0,0 +1,25 @@ +// Copyright (C) 2014 Jérôme Leclercq +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_CONFIG_CHECK_CORE_HPP +#define NAZARA_CONFIG_CHECK_CORE_HPP + +/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp + +#include +#define CheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type ::value && name op val, #type err) + +// On force la valeur de MANAGE_MEMORY en mode debug +#if defined(NAZARA_DEBUG) && !NAZARA_CORE_MANAGE_MEMORY + #undef NAZARA_CORE_MANAGE_MEMORY + #define NAZARA_CORE_MANAGE_MEMORY 1 +#endif + +CheckTypeAndVal(NAZARA_CORE_DECIMAL_DIGITS, integral, >, 0, " shall be a strictly positive integer"); +CheckTypeAndVal(NAZARA_CORE_FILE_BUFFERSIZE, integral, >, 0, " shall be a strictly positive integer"); +CheckTypeAndVal(NAZARA_CORE_WINDOWS_CS_SPINLOCKS, integral, >=, 0, " shall be a positive integer"); + +#endif // NAZARA_CONFIG_CHECK_CORE_HPP diff --git a/include/Nazara/Core/Debug.hpp b/include/Nazara/Core/Debug.hpp index 229014063..7febcddd3 100644 --- a/include/Nazara/Core/Debug.hpp +++ b/include/Nazara/Core/Debug.hpp @@ -3,6 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_CORE_MEMORYMANAGER || defined(NAZARA_DEBUG) - #include +#if NAZARA_CORE_MANAGE_MEMORY + #include #endif diff --git a/include/Nazara/Core/Debug/MemoryManager.hpp b/include/Nazara/Core/Debug/MemoryManager.hpp deleted file mode 100644 index 5aaac72c1..000000000 --- a/include/Nazara/Core/Debug/MemoryManager.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2014 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#ifndef NAZARA_DEBUG_MEMORYMANAGER_HPP -#define NAZARA_DEBUG_MEMORYMANAGER_HPP - -#include -#include -#include - -class NAZARA_API NzMemoryManager -{ - public: - static void* Allocate(std::size_t size, bool multi, const char* file = nullptr, unsigned int line = 0); - - static void Free(void* pointer, bool multi); - - static unsigned int GetAllocatedBlockCount(); - static std::size_t GetAllocatedSize(); - static unsigned int GetAllocationCount(); - - static void NextFree(const char* file, unsigned int line); - - private: - NzMemoryManager(); - ~NzMemoryManager(); - - static void Initialize(); - static void TimeInfo(char buffer[23]); - static void Uninitialize(); -}; - -NAZARA_API void* operator new(std::size_t size, const char* file, unsigned int line); -NAZARA_API void* operator new[](std::size_t size, const char* file, unsigned int line); -NAZARA_API void operator delete(void* ptr, const char* file, unsigned int line) noexcept; -NAZARA_API void operator delete[](void* ptr, const char* file, unsigned int line) noexcept; - -#endif // NAZARA_DEBUG_MEMORYMANAGER_HPP - -#ifndef NAZARA_DEBUG_MEMORYMANAGER_DISABLE_REDEFINITION - #define delete NzMemoryManager::NextFree(__FILE__, __LINE__), delete - #define new new(__FILE__, __LINE__) -#endif diff --git a/include/Nazara/Core/Debug/NewRedefinition.hpp b/include/Nazara/Core/Debug/NewRedefinition.hpp new file mode 100644 index 000000000..d0fea86c2 --- /dev/null +++ b/include/Nazara/Core/Debug/NewRedefinition.hpp @@ -0,0 +1,28 @@ +// Copyright (C) 2014 Jérôme Leclercq +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +// Pas de #pragma once car ce fichier est prévu pour être inclus plusieurs fois + +#include +#if NAZARA_CORE_MANAGE_MEMORY + +#ifndef NAZARA_DEBUG_NEWREDEFINITION_HPP +#define NAZARA_DEBUG_NEWREDEFINITION_HPP + +#include +#include + +NAZARA_API void* operator new(std::size_t size, const char* file, unsigned int line); +NAZARA_API void* operator new[](std::size_t size, const char* file, unsigned int line); +NAZARA_API void operator delete(void* ptr, const char* file, unsigned int line) noexcept; +NAZARA_API void operator delete[](void* ptr, const char* file, unsigned int line) noexcept; + +#endif // NAZARA_DEBUG_NEWREDEFINITION_HPP + +#ifndef NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION + #define delete NzMemoryManager::NextFree(__FILE__, __LINE__), delete + #define new new(__FILE__, __LINE__) +#endif + +#endif // NAZARA_CORE_MANAGE_MEMORY diff --git a/include/Nazara/Core/DebugOff.hpp b/include/Nazara/Core/DebugOff.hpp index 0231febdb..fd70b6f0b 100644 --- a/include/Nazara/Core/DebugOff.hpp +++ b/include/Nazara/Core/DebugOff.hpp @@ -2,7 +2,8 @@ // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp -#if NAZARA_CORE_MEMORYMANAGER || defined(NAZARA_DEBUG) +// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp +#if NAZARA_CORE_MANAGE_MEMORY #undef delete #undef new #endif diff --git a/include/Nazara/Core/MemoryManager.hpp b/include/Nazara/Core/MemoryManager.hpp new file mode 100644 index 000000000..437e5c53b --- /dev/null +++ b/include/Nazara/Core/MemoryManager.hpp @@ -0,0 +1,36 @@ +// Copyright (C) 2014 Jérôme Leclercq +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_MEMORYMANAGER_HPP +#define NAZARA_MEMORYMANAGER_HPP + +#include +#include +#include + +class NAZARA_API NzMemoryManager +{ + public: + static void* Allocate(std::size_t size, bool multi = false, const char* file = nullptr, unsigned int line = 0); + + static void Free(void* pointer, bool multi = false); + + static unsigned int GetAllocatedBlockCount(); + static std::size_t GetAllocatedSize(); + static unsigned int GetAllocationCount(); + + static void NextFree(const char* file, unsigned int line); + + private: + NzMemoryManager(); + ~NzMemoryManager(); + + static void Initialize(); + static void TimeInfo(char buffer[23]); + static void Uninitialize(); +}; + +#endif // NAZARA_MEMORYMANAGER_HPP diff --git a/include/Nazara/Graphics/Config.hpp b/include/Nazara/Graphics/Config.hpp index 99b26dde3..b09bace5e 100644 --- a/include/Nazara/Graphics/Config.hpp +++ b/include/Nazara/Graphics/Config.hpp @@ -32,13 +32,18 @@ // À partir de combien d'instances d'un même mesh/matériau l'instancing doit-il être utilisé ? #define NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT 10 -// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks, ralenti l'exécution) -#define NAZARA_GRAPHICS_MEMORYMANAGER 0 +// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) +#define NAZARA_GRAPHICS_MANAGE_MEMORY 0 // Active les tests de sécurité basés sur le code (Conseillé pour le développement) #define NAZARA_GRAPHICS_SAFE 1 +/// Chaque modification d'un paramètre ci-dessous implique une modification (souvent mineure) du code + // Le nombre maximum de lumières qu'un shader standard supportera -#define NAZARA_GRAPHICS_MAX_LIGHTPERPASS 3U // Unsigned +#define NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS 3 + +/// Vérification des valeurs et types de certaines constantes +#include #endif // NAZARA_CONFIG_GRAPHICS_HPP diff --git a/include/Nazara/Graphics/ConfigCheck.hpp b/include/Nazara/Graphics/ConfigCheck.hpp new file mode 100644 index 000000000..8b46edaaf --- /dev/null +++ b/include/Nazara/Graphics/ConfigCheck.hpp @@ -0,0 +1,24 @@ +// Copyright (C) 2014 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 + +#pragma once + +#ifndef NAZARA_CONFIG_CHECK_GRAPHICS_HPP +#define NAZARA_CONFIG_CHECK_GRAPHICS_HPP + +/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp + +#include +#define CheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type ::value && name op val, #type err) + +// On force la valeur de MANAGE_MEMORY en mode debug +#if defined(NAZARA_DEBUG) && !NAZARA_GRAPHICS_MANAGE_MEMORY + #undef NAZARA_GRAPHICS_MANAGE_MEMORY + #define NAZARA_GRAPHICS_MANAGE_MEMORY 1 +#endif + +CheckTypeAndVal(NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT, integral, >, 0, " shall be a strictly positive integer"); +CheckTypeAndVal(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, integral, >, 0, " shall be a strictly positive integer"); + +#endif // NAZARA_CONFIG_CHECK_GRAPHICS_HPP diff --git a/include/Nazara/Graphics/Debug.hpp b/include/Nazara/Graphics/Debug.hpp index 2a57e4d60..7902d36b1 100644 --- a/include/Nazara/Graphics/Debug.hpp +++ b/include/Nazara/Graphics/Debug.hpp @@ -3,6 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_GRAPHICS_MEMORYMANAGER || defined(NAZARA_DEBUG) - #include +#if NAZARA_GRAPHICS_MANAGE_MEMORY + #include #endif diff --git a/include/Nazara/Graphics/DebugOff.hpp b/include/Nazara/Graphics/DebugOff.hpp index e259e96d8..f5e3b3e1c 100644 --- a/include/Nazara/Graphics/DebugOff.hpp +++ b/include/Nazara/Graphics/DebugOff.hpp @@ -2,7 +2,8 @@ // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp -#if NAZARA_GRAPHICS_MEMORYMANAGER || defined(NAZARA_DEBUG) +// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp +#if NAZARA_GRAPHICS_HPP #undef delete #undef new #endif diff --git a/include/Nazara/Lua/Config.hpp b/include/Nazara/Lua/Config.hpp index eca07b135..7a4440231 100644 --- a/include/Nazara/Lua/Config.hpp +++ b/include/Nazara/Lua/Config.hpp @@ -29,10 +29,13 @@ /// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci -// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks, ralenti l'exécution) -#define NAZARA_LUA_MEMORYMANAGER 0 +// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) +#define NAZARA_LUA_MANAGE_MEMORY 0 // Active les tests de sécurité basés sur le code (Conseillé pour le développement) #define NAZARA_LUA_SAFE 1 +/// Vérification des valeurs et types de certaines constantes +#include + #endif // NAZARA_CONFIG_LUA_HPP diff --git a/include/Nazara/Lua/ConfigCheck.hpp b/include/Nazara/Lua/ConfigCheck.hpp new file mode 100644 index 000000000..21d39454d --- /dev/null +++ b/include/Nazara/Lua/ConfigCheck.hpp @@ -0,0 +1,18 @@ +// Copyright (C) 2014 Jérôme Leclercq +// This file is part of the "Nazara Engine - Lua module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_CONFIG_CHECK_LUA_HPP +#define NAZARA_CONFIG_CHECK_LUA_HPP + +/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp + +// On force la valeur de MANAGE_MEMORY en mode debug +#if defined(NAZARA_DEBUG) && !NAZARA_LUA_MANAGE_MEMORY + #undef NAZARA_LUA_MANAGE_MEMORY + #define NAZARA_LUA_MANAGE_MEMORY 1 +#endif + +#endif // NAZARA_CONFIG_CHECK_LUA_HPP diff --git a/include/Nazara/Lua/Debug.hpp b/include/Nazara/Lua/Debug.hpp index 8c60a54e9..4d6e67953 100644 --- a/include/Nazara/Lua/Debug.hpp +++ b/include/Nazara/Lua/Debug.hpp @@ -3,6 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_LUA_MEMORYMANAGER || defined(NAZARA_DEBUG) - #include +#if NAZARA_LUA_MANAGE_MEMORY + #include #endif diff --git a/include/Nazara/Lua/DebugOff.hpp b/include/Nazara/Lua/DebugOff.hpp index e142ba270..6d9271835 100644 --- a/include/Nazara/Lua/DebugOff.hpp +++ b/include/Nazara/Lua/DebugOff.hpp @@ -2,7 +2,8 @@ // This file is part of the "Nazara Engine - Lua scripting module" // For conditions of distribution and use, see copyright notice in Config.hpp -#if NAZARA_LUA_MEMORYMANAGER || defined(NAZARA_DEBUG) +// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp +#if NAZARA_LUA_MANAGE_MEMORY #undef delete #undef new #endif diff --git a/include/Nazara/Math/Basic.hpp b/include/Nazara/Math/Basic.hpp index 74e120e71..c100da41c 100644 --- a/include/Nazara/Math/Basic.hpp +++ b/include/Nazara/Math/Basic.hpp @@ -33,9 +33,9 @@ unsigned int NzGetNumberLength(int number); unsigned int NzGetNumberLength(unsigned int number); unsigned int NzGetNumberLength(long long number); unsigned int NzGetNumberLength(unsigned long long number); -unsigned int NzGetNumberLength(float number, nzUInt8 precision = NAZARA_CORE_REAL_PRECISION); -unsigned int NzGetNumberLength(double number, nzUInt8 precision = NAZARA_CORE_REAL_PRECISION); -unsigned int NzGetNumberLength(long double number, nzUInt8 precision = NAZARA_CORE_REAL_PRECISION); +unsigned int NzGetNumberLength(float number, nzUInt8 precision = NAZARA_CORE_DECIMAL_DIGITS); +unsigned int NzGetNumberLength(double number, nzUInt8 precision = NAZARA_CORE_DECIMAL_DIGITS); +unsigned int NzGetNumberLength(long double number, nzUInt8 precision = NAZARA_CORE_DECIMAL_DIGITS); template T NzLerp(T from, T to, T2 interpolation); template T NzNormalizeAngle(T angle); template bool NzNumberEquals(T a, T b, T maxDifference = std::numeric_limits::epsilon()); diff --git a/include/Nazara/Noise/Config.hpp b/include/Nazara/Noise/Config.hpp index d8ec10ba4..c9a033f1b 100644 --- a/include/Nazara/Noise/Config.hpp +++ b/include/Nazara/Noise/Config.hpp @@ -29,10 +29,13 @@ /// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci -// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks, ralenti l'exécution) -#define NAZARA_NOISE_MEMORYMANAGER 0 +// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) +#define NAZARA_NOISE_MANAGE_MEMORY 0 // Active les tests de sécurité basés sur le code (Conseillé pour le développement) #define NAZARA_NOISE_SAFE 1 +/// Vérification des valeurs et types de certaines constantes +#include + #endif // NAZARA_CONFIG_MODULENAME_HPP diff --git a/include/Nazara/Noise/ConfigCheck.hpp b/include/Nazara/Noise/ConfigCheck.hpp new file mode 100644 index 000000000..3cad1d19a --- /dev/null +++ b/include/Nazara/Noise/ConfigCheck.hpp @@ -0,0 +1,18 @@ +// Copyright (C) 2014 Jérôme Leclercq +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_CONFIG_CHECK_NOISE_HPP +#define NAZARA_CONFIG_CHECK_NOISE_HPP + +/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp + +// On force la valeur de MANAGE_MEMORY en mode debug +#if defined(NAZARA_DEBUG) && !NAZARA_NOISE_MANAGE_MEMORY + #undef NAZARA_NOISE_MANAGE_MEMORY + #define NAZARA_NOISE_MANAGE_MEMORY 1 +#endif + +#endif // NAZARA_CONFIG_CHECK_NOISE_HPP diff --git a/include/Nazara/Noise/Debug.hpp b/include/Nazara/Noise/Debug.hpp index 67f0bfadb..c47777ba1 100644 --- a/include/Nazara/Noise/Debug.hpp +++ b/include/Nazara/Noise/Debug.hpp @@ -3,6 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_NOISE_MEMORYMANAGER || defined(NAZARA_DEBUG) - #include +#if NAZARA_NOISE_MANAGE_MEMORY + #include #endif diff --git a/include/Nazara/Noise/DebugOff.hpp b/include/Nazara/Noise/DebugOff.hpp index f4b40fb55..9993f1d15 100644 --- a/include/Nazara/Noise/DebugOff.hpp +++ b/include/Nazara/Noise/DebugOff.hpp @@ -2,7 +2,8 @@ // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp -#if NAZARA_NOISE_MEMORYMANAGER || defined(NAZARA_DEBUG) +// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp +#if NAZARA_NOISE_MANAGE_MEMORY #undef delete #undef new #endif diff --git a/include/Nazara/Physics/Config.hpp b/include/Nazara/Physics/Config.hpp index 101c54444..3f10a9aad 100644 --- a/include/Nazara/Physics/Config.hpp +++ b/include/Nazara/Physics/Config.hpp @@ -29,10 +29,13 @@ /// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci -// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks, ralenti l'exécution) -#define NAZARA_PHYSICS_MEMORYMANAGER 0 +// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) +#define NAZARA_PHYSICS_MANAGE_MEMORY 0 // Active les tests de sécurité basés sur le code (Conseillé pour le développement) #define NAZARA_PHYSICS_SAFE 1 +/// Vérification des valeurs et types de certaines constantes +#include + #endif // NAZARA_CONFIG_PHYSICS_HPP diff --git a/include/Nazara/Physics/ConfigCheck.hpp b/include/Nazara/Physics/ConfigCheck.hpp new file mode 100644 index 000000000..037b6d0ec --- /dev/null +++ b/include/Nazara/Physics/ConfigCheck.hpp @@ -0,0 +1,18 @@ +// Copyright (C) 2014 Jérôme Leclercq +// This file is part of the "Nazara Engine - Physics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_CONFIG_CHECK_PHYSICS_HPP +#define NAZARA_CONFIG_CHECK_PHYSICS_HPP + +/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp + +// On force la valeur de MANAGE_MEMORY en mode debug +#if defined(NAZARA_DEBUG) && !NAZARA_PHYSICS_MANAGE_MEMORY + #undef NAZARA_PHYSICS_MANAGE_MEMORY + #define NAZARA_PHYSICS_MANAGE_MEMORY 1 +#endif + +#endif // NAZARA_CONFIG_CHECK_PHYSICS_HPP diff --git a/include/Nazara/Physics/Debug.hpp b/include/Nazara/Physics/Debug.hpp index c20cb6c56..f5ac12a54 100644 --- a/include/Nazara/Physics/Debug.hpp +++ b/include/Nazara/Physics/Debug.hpp @@ -3,6 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_PHYSICS_MEMORYMANAGER || defined(NAZARA_DEBUG) - #include +#if NAZARA_PHYSICS_MANAGE_MEMORY + #include #endif diff --git a/include/Nazara/Physics/DebugOff.hpp b/include/Nazara/Physics/DebugOff.hpp index 40964a5dc..b22910c3b 100644 --- a/include/Nazara/Physics/DebugOff.hpp +++ b/include/Nazara/Physics/DebugOff.hpp @@ -2,7 +2,8 @@ // This file is part of the "Nazara Engine - Physics module" // For conditions of distribution and use, see copyright notice in Config.hpp -#if NAZARA_PHYSICS_MEMORYMANAGER || defined(NAZARA_DEBUG) +// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp +#if NAZARA_PHYSICS_MANAGE_MEMORY #undef delete #undef new #endif diff --git a/include/Nazara/Renderer/Config.hpp b/include/Nazara/Renderer/Config.hpp index 479983228..0e5b08fc7 100644 --- a/include/Nazara/Renderer/Config.hpp +++ b/include/Nazara/Renderer/Config.hpp @@ -30,10 +30,10 @@ /// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci // La taille du buffer d'Instancing (définit le nombre maximum d'instances en un rendu) -#define NAZARA_RENDERER_INSTANCE_BUFFER_SIZE 8192*64 // 8192 matrices 4x4 flottantes +#define NAZARA_RENDERER_INSTANCE_BUFFER_SIZE 524288 // 8192 matrices 4x4 flottantes -// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks, ralenti l'exécution) -#define NAZARA_RENDERER_MEMORYMANAGER 0 +// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) +#define NAZARA_RENDERER_MANAGE_MEMORY 0 // Active le paramère debug des paramètres des contextes par défaut (Perte de performances mais capable de recevoir des messages d'OpenGL) #define NAZARA_RENDERER_OPENGL_DEBUG 0 @@ -41,4 +41,7 @@ // Active les tests de sécurité basés sur le code (Conseillé pour le développement) #define NAZARA_RENDERER_SAFE 1 +/// Vérification des valeurs et types de certaines constantes +#include + #endif // NAZARA_CONFIG_MODULENAME_HPP diff --git a/include/Nazara/Renderer/ConfigCheck.hpp b/include/Nazara/Renderer/ConfigCheck.hpp new file mode 100644 index 000000000..9e362d5ed --- /dev/null +++ b/include/Nazara/Renderer/ConfigCheck.hpp @@ -0,0 +1,23 @@ +// Copyright (C) 2014 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 + +#pragma once + +#ifndef NAZARA_CONFIG_CHECK_RENDERER_HPP +#define NAZARA_CONFIG_CHECK_RENDERER_HPP + +/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp + +#include +#define CheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type ::value && name op val, #type err) + +// On force la valeur de MANAGE_MEMORY en mode debug +#if defined(NAZARA_DEBUG) && !NAZARA_RENDERER_MANAGE_MEMORY + #undef NAZARA_RENDERER_MANAGE_MEMORY + #define NAZARA_RENDERER_MANAGE_MEMORY 1 +#endif + +CheckTypeAndVal(NAZARA_RENDERER_INSTANCE_BUFFER_SIZE, integral, >, 0, " shall be a strictly positive integer"); + +#endif // NAZARA_CONFIG_CHECK_RENDERER_HPP diff --git a/include/Nazara/Renderer/Debug.hpp b/include/Nazara/Renderer/Debug.hpp index 0554bfe88..2d30c585b 100644 --- a/include/Nazara/Renderer/Debug.hpp +++ b/include/Nazara/Renderer/Debug.hpp @@ -3,6 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_RENDERER_MEMORYMANAGER || defined(NAZARA_DEBUG) - #include +#if NAZARA_RENDERER_MANAGE_MEMORY + #include #endif diff --git a/include/Nazara/Renderer/DebugOff.hpp b/include/Nazara/Renderer/DebugOff.hpp index 8a417cd2b..031da1959 100644 --- a/include/Nazara/Renderer/DebugOff.hpp +++ b/include/Nazara/Renderer/DebugOff.hpp @@ -2,7 +2,8 @@ // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp -#if NAZARA_RENDERER_MEMORYMANAGER || defined(NAZARA_DEBUG) +// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp +#if NAZARA_RENDERER_MANAGE_MEMORY #undef delete #undef new #endif diff --git a/include/Nazara/Utility/Config.hpp b/include/Nazara/Utility/Config.hpp index f0fc1b90d..74d26c9da 100644 --- a/include/Nazara/Utility/Config.hpp +++ b/include/Nazara/Utility/Config.hpp @@ -1,5 +1,5 @@ /* - Nazara Engine - Window module + Nazara Engine - Utility module Copyright (C) 2014 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) @@ -29,11 +29,8 @@ /// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci -// Force les buffers à posséder un stride multiple de 32 bytes (Gain de performances sur certaines cartes/plus de consommation mémoire) -#define NAZARA_UTILITY_FORCE_DECLARATION_STRIDE_MULTIPLE_OF_32 0 ///FIXME: Ne peut pas être utilisé pour l'instant - -// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks, ralenti l'exécution) -#define NAZARA_UTILITY_MEMORYMANAGER 0 +// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) +#define NAZARA_UTILITY_MANAGE_MEMORY 0 // Le skinning doit-il prendre avantage du multi-threading ? (Boost de performances sur les processeurs multi-coeurs) #define NAZARA_UTILITY_MULTITHREADED_SKINNING 0 @@ -50,7 +47,13 @@ // Protège les classes des accès concurrentiels //#define NAZARA_UTILITY_THREADSAFE 1 +// Force les buffers à posséder un stride multiple de 32 bytes (Gain de performances sur certaines cartes/plus de consommation mémoire) +#define NAZARA_UTILITY_VERTEX_DECLARATION_FORCE_STRIDE_MULTIPLE_OF_32 0 ///FIXME: Ne peut pas être utilisé pour l'instant + // Sous Windows, fait en sorte que les touches ALT et F10 n'activent pas le menu de la fenêtre #define NAZARA_UTILITY_WINDOWS_DISABLE_MENU_KEYS 1 +/// Vérification des valeurs et types de certaines constantes +#include + #endif // NAZARA_CONFIG_UTILITY_HPP diff --git a/include/Nazara/Utility/ConfigCheck.hpp b/include/Nazara/Utility/ConfigCheck.hpp new file mode 100644 index 000000000..85379eba1 --- /dev/null +++ b/include/Nazara/Utility/ConfigCheck.hpp @@ -0,0 +1,23 @@ +// Copyright (C) 2014 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 + +#pragma once + +#ifndef NAZARA_CONFIG_CHECK_UTILITY_HPP +#define NAZARA_CONFIG_CHECK_UTILITY_HPP + +/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp + +#include +#define CheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type ::value && name op val, #type err) + +// On force la valeur de MANAGE_MEMORY en mode debug +#if defined(NAZARA_DEBUG) && !NAZARA_UTILITY_MANAGE_MEMORY + #undef NAZARA_UTILITY_MANAGE_MEMORY + #define NAZARA_UTILITY_MANAGE_MEMORY 1 +#endif + +CheckTypeAndVal(NAZARA_UTILITY_SKINNING_MAX_WEIGHTS, integral, >, 0, " shall be a strictly positive integer"); + +#endif // NAZARA_CONFIG_CHECK_UTILITY_HPP diff --git a/include/Nazara/Utility/Debug.hpp b/include/Nazara/Utility/Debug.hpp index ee1dc9d4e..d5ae45202 100644 --- a/include/Nazara/Utility/Debug.hpp +++ b/include/Nazara/Utility/Debug.hpp @@ -3,6 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_UTILITY_MEMORYMANAGER || defined(NAZARA_DEBUG) - #include +#if NAZARA_UTILITY_MANAGE_MEMORY + #include #endif diff --git a/include/Nazara/Utility/DebugOff.hpp b/include/Nazara/Utility/DebugOff.hpp index e94bd4e5a..177f4e29a 100644 --- a/include/Nazara/Utility/DebugOff.hpp +++ b/include/Nazara/Utility/DebugOff.hpp @@ -2,7 +2,8 @@ // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp -#if NAZARA_UTILITY_MEMORYMANAGER || defined(NAZARA_DEBUG) +// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp +#if NAZARA_UTILITY_MANAGE_MEMORY #undef delete #undef new #endif diff --git a/src/Nazara/Audio/Debug/Leaks.cpp b/src/Nazara/Audio/Debug/NewOverload.cpp similarity index 76% rename from src/Nazara/Audio/Debug/Leaks.cpp rename to src/Nazara/Audio/Debug/NewOverload.cpp index 5de4383c0..259ef3640 100644 --- a/src/Nazara/Audio/Debug/Leaks.cpp +++ b/src/Nazara/Audio/Debug/NewOverload.cpp @@ -3,10 +3,10 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_AUDIO_MEMORYMANAGER || defined(NAZARA_DEBUG) -#define NAZARA_DEBUG_MEMORYMANAGER_DISABLE_REDEFINITION -#include -#include +#if NAZARA_AUDIO_MANAGE_MEMORY + +#include +#include // Nécessaire ? void* operator new(std::size_t size) { @@ -28,4 +28,4 @@ void operator delete[](void* pointer) noexcept NzMemoryManager::Free(pointer, true); } -#endif +#endif // NAZARA_AUDIO_MANAGE_MEMORY diff --git a/src/Nazara/Audio/Music.cpp b/src/Nazara/Audio/Music.cpp index 4e3a62c44..16dfc64ec 100644 --- a/src/Nazara/Audio/Music.cpp +++ b/src/Nazara/Audio/Music.cpp @@ -237,10 +237,10 @@ bool NzMusic::FillAndQueueBuffer(unsigned int buffer) void NzMusic::MusicThread() { - ALuint buffers[NAZARA_AUDIO_STREAMEDBUFFERCOUNT]; - alGenBuffers(NAZARA_AUDIO_STREAMEDBUFFERCOUNT, buffers); + ALuint buffers[NAZARA_AUDIO_STREAMED_BUFFER_COUNT]; + alGenBuffers(NAZARA_AUDIO_STREAMED_BUFFER_COUNT, buffers); - for (unsigned int i = 0; i < NAZARA_AUDIO_STREAMEDBUFFERCOUNT; ++i) + for (unsigned int i = 0; i < NAZARA_AUDIO_STREAMED_BUFFER_COUNT; ++i) { if (FillAndQueueBuffer(buffers[i])) // Fin du fichier ? break; // Nous avons atteint la fin du fichier, inutile de rajouter des buffers @@ -280,7 +280,7 @@ void NzMusic::MusicThread() for (ALint i = 0; i < queuedBufferCount; ++i) alSourceUnqueueBuffers(m_source, 1, &buffer); - alDeleteBuffers(NAZARA_AUDIO_STREAMEDBUFFERCOUNT, buffers); + alDeleteBuffers(NAZARA_AUDIO_STREAMED_BUFFER_COUNT, buffers); } NzMusicLoader::LoaderList NzMusic::s_loaders; diff --git a/src/Nazara/Core/Debug/Leaks.cpp b/src/Nazara/Core/Debug/NewOverload.cpp similarity index 76% rename from src/Nazara/Core/Debug/Leaks.cpp rename to src/Nazara/Core/Debug/NewOverload.cpp index d4f2c0099..abbcb6728 100644 --- a/src/Nazara/Core/Debug/Leaks.cpp +++ b/src/Nazara/Core/Debug/NewOverload.cpp @@ -3,10 +3,10 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_CORE_MEMORYMANAGER || defined(NAZARA_DEBUG) -#define NAZARA_DEBUG_MEMORYMANAGER_DISABLE_REDEFINITION -#include -#include +#if NAZARA_CORE_MANAGE_MEMORY + +#include +#include // Nécessaire ? void* operator new(std::size_t size) { @@ -27,4 +27,5 @@ void operator delete[](void* pointer) noexcept { NzMemoryManager::Free(pointer, true); } -#endif + +#endif // NAZARA_CORE_MANAGE_MEMORY diff --git a/src/Nazara/Core/Debug/NewRedefinition.cpp b/src/Nazara/Core/Debug/NewRedefinition.cpp new file mode 100644 index 000000000..b4c06b816 --- /dev/null +++ b/src/Nazara/Core/Debug/NewRedefinition.cpp @@ -0,0 +1,36 @@ +// Copyright (C) 2014 Jérôme Leclercq +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#if NAZARA_CORE_MANAGE_MEMORY + +#define NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION + +#include +#include +#include // Nécessaire ? + +void* operator new(std::size_t size, const char* file, unsigned int line) +{ + return NzMemoryManager::Allocate(size, false, file, line); +} + +void* operator new[](std::size_t size, const char* file, unsigned int line) +{ + return NzMemoryManager::Allocate(size, true, file, line); +} + +void operator delete(void* ptr, const char* file, unsigned int line) noexcept +{ + NzMemoryManager::NextFree(file, line); + NzMemoryManager::Free(ptr, false); +} + +void operator delete[](void* ptr, const char* file, unsigned int line) noexcept +{ + NzMemoryManager::NextFree(file, line); + NzMemoryManager::Free(ptr, true); +} + +#endif // NAZARA_CORE_MANAGE_MEMORY diff --git a/src/Nazara/Core/Debug/MemoryManager.cpp b/src/Nazara/Core/MemoryManager.cpp similarity index 89% rename from src/Nazara/Core/Debug/MemoryManager.cpp rename to src/Nazara/Core/MemoryManager.cpp index ce5c2eb52..55505e2c0 100644 --- a/src/Nazara/Core/Debug/MemoryManager.cpp +++ b/src/Nazara/Core/MemoryManager.cpp @@ -2,9 +2,7 @@ // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp -#define NAZARA_DEBUG_MEMORYMANAGER_DISABLE_REDEFINITION - -#include +#include #include #include #include @@ -259,25 +257,3 @@ void NzMemoryManager::Uninitialize() std::fclose(log); } - -void* operator new(std::size_t size, const char* file, unsigned int line) -{ - return NzMemoryManager::Allocate(size, false, file, line); -} - -void* operator new[](std::size_t size, const char* file, unsigned int line) -{ - return NzMemoryManager::Allocate(size, true, file, line); -} - -void operator delete(void* ptr, const char* file, unsigned int line) noexcept -{ - NzMemoryManager::NextFree(file, line); - NzMemoryManager::Free(ptr, false); -} - -void operator delete[](void* ptr, const char* file, unsigned int line) noexcept -{ - NzMemoryManager::NextFree(file, line); - NzMemoryManager::Free(ptr, true); -} diff --git a/src/Nazara/Core/ParameterList.cpp b/src/Nazara/Core/ParameterList.cpp index bb8b6bc7b..ba0e7322e 100644 --- a/src/Nazara/Core/ParameterList.cpp +++ b/src/Nazara/Core/ParameterList.cpp @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp // Notre utilisation du placement new n'est pas (encore ?) compatible avec les définitions du MLT -#define NAZARA_DEBUG_MEMORYMANAGER_DISABLE_REDEFINITION +#define NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION #include #include diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index 8f2bf257f..85be12ce2 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -3930,7 +3930,7 @@ int NzString::Compare(const NzString& first, const NzString& second) NzString NzString::Number(float number) { std::ostringstream oss; - oss.precision(NAZARA_CORE_REAL_PRECISION); + oss.precision(NAZARA_CORE_DECIMAL_DIGITS); oss << number; return NzString(oss.str()); @@ -3939,7 +3939,7 @@ NzString NzString::Number(float number) NzString NzString::Number(double number) { std::ostringstream oss; - oss.precision(NAZARA_CORE_REAL_PRECISION); + oss.precision(NAZARA_CORE_DECIMAL_DIGITS); oss << number; return NzString(oss.str()); @@ -3948,7 +3948,7 @@ NzString NzString::Number(double number) NzString NzString::Number(long double number) { std::ostringstream oss; - oss.precision(NAZARA_CORE_REAL_PRECISION); + oss.precision(NAZARA_CORE_DECIMAL_DIGITS); oss << number; return NzString(oss.str()); diff --git a/src/Nazara/Graphics/Debug/Leaks.cpp b/src/Nazara/Graphics/Debug/NewOverload.cpp similarity index 75% rename from src/Nazara/Graphics/Debug/Leaks.cpp rename to src/Nazara/Graphics/Debug/NewOverload.cpp index 232f969df..985b556ec 100644 --- a/src/Nazara/Graphics/Debug/Leaks.cpp +++ b/src/Nazara/Graphics/Debug/NewOverload.cpp @@ -3,10 +3,10 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_GRAPHICS_MEMORYMANAGER || defined(NAZARA_DEBUG) -#define NAZARA_DEBUG_MEMORYMANAGER_DISABLE_REDEFINITION -#include -#include +#if NAZARA_GRAPHICS_MANAGE_MEMORY + +#include +#include // Nécessaire ? void* operator new(std::size_t size) { @@ -28,4 +28,4 @@ void operator delete[](void* pointer) noexcept NzMemoryManager::Free(pointer, true); } -#endif +#endif // NAZARA_GRAPHICS_MANAGE_MEMORY diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index 8a3ab4e2c..68726c809 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -247,12 +247,12 @@ void NzForwardRenderTechnique::DrawOpaqueModels(const NzScene* scene) const unsigned int lightIndex = 0; nzRendererComparison oldDepthFunc = NzRenderer::GetDepthFunc(); - unsigned int passCount = (lightCount == 0) ? 1 : (lightCount-1)/NAZARA_GRAPHICS_MAX_LIGHTPERPASS + 1; + unsigned int passCount = (lightCount == 0) ? 1 : (lightCount-1)/NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; for (unsigned int pass = 0; pass < passCount; ++pass) { if (lightUniforms->exists) { - unsigned int renderedLightCount = std::min(lightCount, NAZARA_GRAPHICS_MAX_LIGHTPERPASS); + unsigned int renderedLightCount = std::min(lightCount, NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U)); lightCount -= renderedLightCount; if (pass == 1) @@ -269,7 +269,7 @@ void NzForwardRenderTechnique::DrawOpaqueModels(const NzScene* scene) const for (unsigned int i = 0; i < renderedLightCount; ++i) m_directionalLights.GetLight(lightIndex++)->Enable(shader, lightUniforms->uniforms, lightUniforms->offset*i); - for (unsigned int i = renderedLightCount; i < NAZARA_GRAPHICS_MAX_LIGHTPERPASS; ++i) + for (unsigned int i = renderedLightCount; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) NzLight::Disable(shader, lightUniforms->uniforms, lightUniforms->offset*i); } @@ -303,7 +303,7 @@ void NzForwardRenderTechnique::DrawOpaqueModels(const NzScene* scene) const for (const NzMatrix4f& matrix : instances) { unsigned int directionalLightCount = m_directionalLights.GetLightCount(); - unsigned int otherLightCount = m_lights.ComputeClosestLights(matrix.GetTranslation() + boundingSphere.GetPosition(), boundingSphere.radius, m_maxLightPassPerObject*NAZARA_GRAPHICS_MAX_LIGHTPERPASS - directionalLightCount); + unsigned int otherLightCount = m_lights.ComputeClosestLights(matrix.GetTranslation() + boundingSphere.GetPosition(), boundingSphere.radius, m_maxLightPassPerObject*NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS - directionalLightCount); unsigned int lightCount = directionalLightCount + otherLightCount; NzRenderer::SetMatrix(nzMatrixType_World, matrix); @@ -311,10 +311,10 @@ void NzForwardRenderTechnique::DrawOpaqueModels(const NzScene* scene) const unsigned int otherLightIndex = 0; nzRendererComparison oldDepthFunc = NzRenderer::GetDepthFunc(); // Dans le cas où nous aurions à le changer - unsigned int passCount = (lightCount == 0) ? 1 : (lightCount-1)/NAZARA_GRAPHICS_MAX_LIGHTPERPASS + 1; + unsigned int passCount = (lightCount == 0) ? 1 : (lightCount-1)/NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; for (unsigned int pass = 0; pass < passCount; ++pass) { - unsigned int renderedLightCount = std::min(lightCount, NAZARA_GRAPHICS_MAX_LIGHTPERPASS); + unsigned int renderedLightCount = std::min(lightCount, NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U)); lightCount -= renderedLightCount; if (pass == 1) @@ -338,7 +338,7 @@ void NzForwardRenderTechnique::DrawOpaqueModels(const NzScene* scene) const } // On désactive l'éventuel surplus - for (unsigned int i = renderedLightCount; i < NAZARA_GRAPHICS_MAX_LIGHTPERPASS; ++i) + for (unsigned int i = renderedLightCount; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) NzLight::Disable(shader, lightUniforms->uniforms, lightUniforms->offset*i); // Et on passe à l'affichage @@ -478,7 +478,7 @@ void NzForwardRenderTechnique::DrawTransparentModels(const NzScene* scene) const lightUniforms = GetLightUniforms(shader); // On envoie les lumières directionnelles s'il y a (Les mêmes pour tous) - lightCount = std::min(m_directionalLights.GetLightCount(), NAZARA_GRAPHICS_MAX_LIGHTPERPASS); + lightCount = std::min(m_directionalLights.GetLightCount(), NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U)); for (unsigned int i = 0; i < lightCount; ++i) m_directionalLights.GetLight(i)->Enable(shader, lightUniforms->uniforms, lightUniforms->offset*i); @@ -511,14 +511,14 @@ void NzForwardRenderTechnique::DrawTransparentModels(const NzScene* scene) const NzRenderer::SetVertexBuffer(vertexBuffer); // Calcul des lumières les plus proches - if (lightCount < NAZARA_GRAPHICS_MAX_LIGHTPERPASS && !m_lights.IsEmpty()) + if (lightCount < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS && !m_lights.IsEmpty()) { - unsigned int count = std::min(NAZARA_GRAPHICS_MAX_LIGHTPERPASS - lightCount, m_lights.ComputeClosestLights(matrix.GetTranslation() + modelData.boundingSphere.GetPosition(), modelData.boundingSphere.radius, NAZARA_GRAPHICS_MAX_LIGHTPERPASS)); + unsigned int count = std::min(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS - lightCount, m_lights.ComputeClosestLights(matrix.GetTranslation() + modelData.boundingSphere.GetPosition(), modelData.boundingSphere.radius, NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS)); for (unsigned int i = 0; i < count; ++i) m_lights.GetResult(i)->Enable(shader, lightUniforms->uniforms, lightUniforms->offset*(lightCount++)); } - for (unsigned int i = lightCount; i < NAZARA_GRAPHICS_MAX_LIGHTPERPASS; ++i) + for (unsigned int i = lightCount; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) NzLight::Disable(shader, lightUniforms->uniforms, lightUniforms->offset*i); NzRenderer::SetMatrix(nzMatrixType_World, matrix); diff --git a/src/Nazara/Lua/Debug/Leaks.cpp b/src/Nazara/Lua/Debug/NewOverload.cpp similarity index 76% rename from src/Nazara/Lua/Debug/Leaks.cpp rename to src/Nazara/Lua/Debug/NewOverload.cpp index ba662680c..17bc09b73 100644 --- a/src/Nazara/Lua/Debug/Leaks.cpp +++ b/src/Nazara/Lua/Debug/NewOverload.cpp @@ -3,10 +3,10 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_LUA_MEMORYMANAGER || defined(NAZARA_DEBUG) -#define NAZARA_DEBUG_MEMORYMANAGER_DISABLE_REDEFINITION -#include -#include +#if NAZARA_LUA_MANAGE_MEMORY + +#include +#include // Nécessaire ? void* operator new(std::size_t size) { @@ -28,4 +28,4 @@ void operator delete[](void* pointer) noexcept NzMemoryManager::Free(pointer, true); } -#endif +#endif // NAZARA_LUA_MANAGE_MEMORY diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp index e3fa382e5..2db6aeb80 100644 --- a/src/Nazara/Lua/LuaInstance.cpp +++ b/src/Nazara/Lua/LuaInstance.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Lua scripting module" // For conditions of distribution and use, see copyright notice in Config.hpp -#define NAZARA_DEBUG_MEMORYMANAGER_DISABLE_REDEFINITION +#define NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION #include #include diff --git a/src/Nazara/Noise/Debug/Leaks.cpp b/src/Nazara/Noise/Debug/NewOverload.cpp similarity index 76% rename from src/Nazara/Noise/Debug/Leaks.cpp rename to src/Nazara/Noise/Debug/NewOverload.cpp index 73f49b69e..b22595d3e 100644 --- a/src/Nazara/Noise/Debug/Leaks.cpp +++ b/src/Nazara/Noise/Debug/NewOverload.cpp @@ -3,10 +3,10 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_NOISE_MEMORYMANAGER || defined(NAZARA_DEBUG) -#define NAZARA_DEBUG_MEMORYMANAGER_DISABLE_REDEFINITION -#include -#include +#if NAZARA_NOISE_MANAGE_MEMORY + +#include +#include // Nécessaire ? void* operator new(std::size_t size) { @@ -28,4 +28,4 @@ void operator delete[](void* pointer) noexcept NzMemoryManager::Free(pointer, true); } -#endif +#endif // NAZARA_NOISE_MANAGE_MEMORY diff --git a/src/Nazara/Physics/Debug/Leaks.cpp b/src/Nazara/Physics/Debug/NewOverload.cpp similarity index 75% rename from src/Nazara/Physics/Debug/Leaks.cpp rename to src/Nazara/Physics/Debug/NewOverload.cpp index 02cc3e294..278162316 100644 --- a/src/Nazara/Physics/Debug/Leaks.cpp +++ b/src/Nazara/Physics/Debug/NewOverload.cpp @@ -3,10 +3,10 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_PHYSICS_MEMORYMANAGER || defined(NAZARA_DEBUG) -#define NAZARA_DEBUG_MEMORYMANAGER_DISABLE_REDEFINITION -#include -#include +#if NAZARA_PHYSICS_MANAGE_MEMORY + +#include +#include // Nécessaire ? void* operator new(std::size_t size) { @@ -28,4 +28,4 @@ void operator delete[](void* pointer) noexcept NzMemoryManager::Free(pointer, true); } -#endif +#endif // NAZARA_PHYSICS_MANAGE_MEMORY diff --git a/src/Nazara/Renderer/Debug/Leaks.cpp b/src/Nazara/Renderer/Debug/NewOverload.cpp similarity index 75% rename from src/Nazara/Renderer/Debug/Leaks.cpp rename to src/Nazara/Renderer/Debug/NewOverload.cpp index 938f05c91..388752cab 100644 --- a/src/Nazara/Renderer/Debug/Leaks.cpp +++ b/src/Nazara/Renderer/Debug/NewOverload.cpp @@ -3,10 +3,10 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_RENDERER_MEMORYMANAGER || defined(NAZARA_DEBUG) -#define NAZARA_DEBUG_MEMORYMANAGER_DISABLE_REDEFINITION -#include -#include +#if NAZARA_RENDERER_MANAGE_MEMORY + +#include +#include // Nécessaire ? void* operator new(std::size_t size) { @@ -28,4 +28,4 @@ void operator delete[](void* pointer) noexcept NzMemoryManager::Free(pointer, true); } -#endif +#endif // NAZARA_RENDERER_MANAGE_MEMORY diff --git a/src/Nazara/Utility/Debug/Leaks.cpp b/src/Nazara/Utility/Debug/NewOverload.cpp similarity index 76% rename from src/Nazara/Utility/Debug/Leaks.cpp rename to src/Nazara/Utility/Debug/NewOverload.cpp index 3d3724324..7316673f5 100644 --- a/src/Nazara/Utility/Debug/Leaks.cpp +++ b/src/Nazara/Utility/Debug/NewOverload.cpp @@ -3,10 +3,10 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_UTILITY_MEMORYMANAGER || defined(NAZARA_DEBUG) -#define NAZARA_DEBUG_MEMORYMANAGER_DISABLE_REDEFINITION -#include -#include +#if NAZARA_UTILITY_MANAGE_MEMORY + +#include +#include // Nécessaire ? void* operator new(std::size_t size) { @@ -28,4 +28,4 @@ void operator delete[](void* pointer) noexcept NzMemoryManager::Free(pointer, true); } -#endif +#endif // NAZARA_UTILITY_MANAGE_MEMORY