diff --git a/build/scripts/modules/graphics.lua b/build/scripts/modules/graphics.lua new file mode 100644 index 000000000..71b2738ce --- /dev/null +++ b/build/scripts/modules/graphics.lua @@ -0,0 +1,9 @@ +MODULE.Name = "Graphics" + +MODULE.ClientOnly = true + +MODULE.Libraries = { + "NazaraCore", + "NazaraRenderer", + "NazaraUtility" +} diff --git a/include/Nazara/Graphics/Config.hpp b/include/Nazara/Graphics/Config.hpp new file mode 100644 index 000000000..9d10cc927 --- /dev/null +++ b/include/Nazara/Graphics/Config.hpp @@ -0,0 +1,56 @@ +/* + Nazara Engine - Graphics module + + Copyright (C) 2020 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do + so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +#pragma once + +#ifndef NAZARA_CONFIG_GRAPHICS_HPP +#define NAZARA_CONFIG_GRAPHICS_HPP + +/*! +* \defgroup graphics (NazaraGraphics) Graphics module +* Graphics/System module including classes to handle graphical elements... +*/ + +/// Each modification of a parameter needs a recompilation of the module + +// Use the MemoryManager to manage dynamic allocations (can detect memory leak but allocations/frees are slower) +#define NAZARA_GRAPHICS_MANAGE_MEMORY 0 + +// Activate the security tests based on the code (Advised for development) +#define NAZARA_GRAPHICS_SAFE 1 + +/// Checking the values and types of certain constants +#include + +#if !defined(NAZARA_STATIC) + #ifdef NAZARA_GRAPHICS_BUILD + #define NAZARA_GRAPHICS_API NAZARA_EXPORT + #else + #define NAZARA_GRAPHICS_API NAZARA_IMPORT + #endif +#else + #define NAZARA_GRAPHICS_API +#endif + +#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..20356f211 --- /dev/null +++ b/include/Nazara/Graphics/ConfigCheck.hpp @@ -0,0 +1,23 @@ +// Copyright (C) 2020 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_GRAPHICS_HPP +#define NAZARA_CONFIG_CHECK_GRAPHICS_HPP + +/// This file is used to check the constant values defined in Config.hpp + +#include +#define NazaraCheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type ::value && name op val, #type err) + +// We force the value of MANAGE_MEMORY in debug +#if defined(NAZARA_DEBUG) && !NAZARA_GRAPHICS_MANAGE_MEMORY + #undef NAZARA_GRAPHICS_MANAGE_MEMORY + #define NAZARA_GRAPHICS_MANAGE_MEMORY 0 +#endif + +#undef NazaraCheckTypeAndVal + +#endif // NAZARA_CONFIG_CHECK_GRAPHICS_HPP diff --git a/include/Nazara/Graphics/Debug.hpp b/include/Nazara/Graphics/Debug.hpp new file mode 100644 index 000000000..c7cd0cad5 --- /dev/null +++ b/include/Nazara/Graphics/Debug.hpp @@ -0,0 +1,8 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#if NAZARA_GRAPHICS_MANAGE_MEMORY + #include +#endif diff --git a/include/Nazara/Graphics/DebugOff.hpp b/include/Nazara/Graphics/DebugOff.hpp new file mode 100644 index 000000000..7cb6e72a7 --- /dev/null +++ b/include/Nazara/Graphics/DebugOff.hpp @@ -0,0 +1,9 @@ +// Copyright (C) 2020 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 + +// We assume that Debug.hpp has already been included, same thing for Config.hpp +#if NAZARA_GRAPHICS_MANAGE_MEMORY + #undef delete + #undef new +#endif diff --git a/include/Nazara/Graphics/Enums.hpp b/include/Nazara/Graphics/Enums.hpp new file mode 100644 index 000000000..f847d5fe4 --- /dev/null +++ b/include/Nazara/Graphics/Enums.hpp @@ -0,0 +1,14 @@ +// Copyright (C) 2020 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_ENUMS_GRAPHICS_HPP +#define NAZARA_ENUMS_GRAPHICS_HPP + +namespace Nz +{ +} + +#endif // NAZARA_ENUMS_GRAPHICS_HPP diff --git a/include/Nazara/Graphics/Graphics.hpp b/include/Nazara/Graphics/Graphics.hpp new file mode 100644 index 000000000..71f7f533a --- /dev/null +++ b/include/Nazara/Graphics/Graphics.hpp @@ -0,0 +1,33 @@ +// Copyright (C) 2020 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_GRAPHICS_HPP +#define NAZARA_GRAPHICS_HPP + +#include +#include +#include + +namespace Nz +{ + class NAZARA_GRAPHICS_API Graphics : public ModuleBase + { + friend ModuleBase; + + public: + using Dependencies = TypeList; + + struct Config {}; + + Graphics(Config /*config*/); + ~Graphics(); + + private: + static Graphics* s_instance; + }; +} + +#endif diff --git a/src/Nazara/Graphics/Debug/NewOverload.cpp b/src/Nazara/Graphics/Debug/NewOverload.cpp new file mode 100644 index 000000000..609c3ff82 --- /dev/null +++ b/src/Nazara/Graphics/Debug/NewOverload.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#if NAZARA_GRAPHICS_MANAGE_MEMORY + +#include +#include // Nécessaire ? + +void* operator new(std::size_t size) +{ + return Nz::MemoryManager::Allocate(size, false); +} + +void* operator new[](std::size_t size) +{ + return Nz::MemoryManager::Allocate(size, true); +} + +void operator delete(void* pointer) noexcept +{ + Nz::MemoryManager::Free(pointer, false); +} + +void operator delete[](void* pointer) noexcept +{ + Nz::MemoryManager::Free(pointer, true); +} + +#endif diff --git a/src/Nazara/Graphics/Graphics.cpp b/src/Nazara/Graphics/Graphics.cpp new file mode 100644 index 000000000..b2ac1d928 --- /dev/null +++ b/src/Nazara/Graphics/Graphics.cpp @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + /*! + * \ingroup graphics + * \class Nz::Graphics + * \brief Audio class that represents the module initializer of Graphics + */ + + Graphics::Graphics(Config /*config*/) : + ModuleBase("Graphics", this) + { + } + + Graphics::~Graphics() + { + } + + Graphics* Graphics::s_instance = nullptr; +}