Add graphics module base
This commit is contained in:
parent
e9f3e39194
commit
95c9ad0fd8
|
|
@ -0,0 +1,9 @@
|
||||||
|
MODULE.Name = "Graphics"
|
||||||
|
|
||||||
|
MODULE.ClientOnly = true
|
||||||
|
|
||||||
|
MODULE.Libraries = {
|
||||||
|
"NazaraCore",
|
||||||
|
"NazaraRenderer",
|
||||||
|
"NazaraUtility"
|
||||||
|
}
|
||||||
|
|
@ -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 <Nazara/Graphics/ConfigCheck.hpp>
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
@ -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 <type_traits>
|
||||||
|
#define NazaraCheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type <decltype(name)>::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
|
||||||
|
|
@ -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 <Nazara/Graphics/Config.hpp>
|
||||||
|
#if NAZARA_GRAPHICS_MANAGE_MEMORY
|
||||||
|
#include <Nazara/Core/Debug/NewRedefinition.hpp>
|
||||||
|
#endif
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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 <Nazara/Prerequisites.hpp>
|
||||||
|
#include <Nazara/Graphics/Config.hpp>
|
||||||
|
#include <Nazara/Renderer/Renderer.hpp>
|
||||||
|
|
||||||
|
namespace Nz
|
||||||
|
{
|
||||||
|
class NAZARA_GRAPHICS_API Graphics : public ModuleBase<Graphics>
|
||||||
|
{
|
||||||
|
friend ModuleBase;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using Dependencies = TypeList<Renderer>;
|
||||||
|
|
||||||
|
struct Config {};
|
||||||
|
|
||||||
|
Graphics(Config /*config*/);
|
||||||
|
~Graphics();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static Graphics* s_instance;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -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 <Nazara/Graphics/Config.hpp>
|
||||||
|
#if NAZARA_GRAPHICS_MANAGE_MEMORY
|
||||||
|
|
||||||
|
#include <Nazara/Core/MemoryManager.hpp>
|
||||||
|
#include <new> // 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
|
||||||
|
|
@ -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 <Nazara/Graphics/Graphics.hpp>
|
||||||
|
#include <Nazara/Graphics/Debug.hpp>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue