Merge remote-tracking branch 'origin/master' into Resource-Update
Conflicts: include/Nazara/Audio/Music.hpp include/Nazara/Audio/SoundBuffer.hpp include/Nazara/Core/Resource.hpp include/Nazara/Core/ResourceListener.hpp include/Nazara/Graphics/Material.hpp include/Nazara/Renderer/Context.hpp include/Nazara/Renderer/RenderBuffer.hpp include/Nazara/Renderer/Shader.hpp include/Nazara/Renderer/Texture.hpp include/Nazara/Renderer/UberShader.hpp include/Nazara/Utility/Animation.hpp include/Nazara/Utility/Buffer.hpp include/Nazara/Utility/Image.hpp include/Nazara/Utility/IndexBuffer.hpp include/Nazara/Utility/Mesh.hpp include/Nazara/Utility/SkeletalMesh.hpp include/Nazara/Utility/Skeleton.hpp include/Nazara/Utility/StaticMesh.hpp include/Nazara/Utility/SubMesh.hpp include/Nazara/Utility/VertexBuffer.hpp include/Nazara/Utility/VertexDeclaration.hpp src/Nazara/Core/Resource.cpp src/Nazara/Core/ResourceListener.cpp src/Nazara/Graphics/DeferredRenderQueue.cpp src/Nazara/Graphics/ForwardRenderQueue.cpp src/Nazara/Graphics/SkinningManager.cpp src/Nazara/Renderer/RenderTexture.cpp src/Nazara/Renderer/Renderer.cpp src/Nazara/Utility/Mesh.cpp Former-commit-id: 99b5ad26a19fe9c9f8118da7b5920bffe89f60f8
This commit is contained in:
commit
5f5be93992
|
|
@ -0,0 +1,95 @@
|
|||
Copyright (c) 2011, Pablo Impallari (www.impallari.com|impallari@gmail.com),
|
||||
Copyright (c) 2011, Igino Marini. (www.ikern.com|mail@iginomarini.com),
|
||||
with Reserved Font Name Cabin.
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
|
|
@ -191,7 +191,7 @@ end
|
|||
|
||||
newaction
|
||||
{
|
||||
trigger = "unicode",
|
||||
trigger = "parseunicode",
|
||||
description = "Parse the Unicode Character Data and put the useful informations into a header",
|
||||
execute = parseUnicodeData
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ files
|
|||
"../src/Nazara/Utility/**.cpp"
|
||||
}
|
||||
|
||||
links "freetype-s"
|
||||
|
||||
if (os.is("windows")) then
|
||||
excludes { "../src/Nazara/Utility/Posix/*.hpp", "../src/Nazara/Utility/Posix/*.cpp" }
|
||||
links "gdi32"
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ int main()
|
|||
// Ensuite, nous allons rajouter un modèle à notre scène.
|
||||
// Les modèles représentent, globalement, tout ce qui est visible en trois dimensions.
|
||||
// Nous choisirons ici un vaisseau spatial (Quoi de mieux pour une scène spatiale ?)
|
||||
NzModel spaceship;
|
||||
NzModel* spaceship = scene.CreateNode<NzModel>(); // Création depuis la scène
|
||||
|
||||
// Une structure permettant de paramétrer le chargement des modèles
|
||||
NzModelParameters params;
|
||||
|
|
@ -95,9 +95,13 @@ int main()
|
|||
// Ce paramètre sert à indiquer la mise à l'échelle désirée lors du chargement du modèle.
|
||||
params.mesh.scale.Set(0.01f); // Un centième de la taille originelle
|
||||
|
||||
// Les UVs de ce fichier sont retournées (repère OpenGL, origine coin bas-gauche) par rapport à ce que le moteur attend
|
||||
// Nous devons dire au moteur de les retourner lors du chargement
|
||||
params.mesh.flipUVs = true;
|
||||
|
||||
// On charge ensuite le modèle depuis son fichier
|
||||
// Le moteur va charger le fichier et essayer de retrouver les fichiers associés (comme les matériaux, textures, ...)
|
||||
if (!spaceship.LoadFromFile("resources/Spaceship/spaceship.obj", params))
|
||||
if (!spaceship->LoadFromFile("resources/Spaceship/spaceship.obj", params))
|
||||
{
|
||||
std::cout << "Failed to load spaceship" << std::endl;
|
||||
std::getchar();
|
||||
|
|
@ -107,7 +111,7 @@ int main()
|
|||
|
||||
// Nous voulons afficher quelques statistiques relatives au modèle, comme le nombre de sommets et de triangles
|
||||
// Pour cela, nous devons accéder au mesh (maillage 3D)
|
||||
NzMesh* mesh = spaceship.GetMesh();
|
||||
NzMesh* mesh = spaceship->GetMesh();
|
||||
|
||||
std::cout << mesh->GetVertexCount() << " sommets" << std::endl;
|
||||
std::cout << mesh->GetTriangleCount() << " triangles" << std::endl;
|
||||
|
|
@ -115,7 +119,7 @@ int main()
|
|||
// En revanche, le format OBJ ne précise pas l'utilisation d'une normal map, nous devons donc la charger manuellement
|
||||
// Pour commencer on récupère le matériau du mesh, celui-ci en possède plusieurs mais celui qui nous intéresse,
|
||||
// celui de la coque, est le second (Cela est bien entendu lié au modèle en lui-même)
|
||||
NzMaterial* material = spaceship.GetMaterial(1);
|
||||
NzMaterial* material = spaceship->GetMaterial(1);
|
||||
|
||||
// On lui indique ensuite le chemin vers la normal map
|
||||
if (!material->SetNormalMap("resources/Spaceship/Texture/normal.png"))
|
||||
|
|
@ -125,10 +129,6 @@ int main()
|
|||
std::cout << "Failed to load normal map" << std::endl;
|
||||
}
|
||||
|
||||
// Il nous reste à attacher le modèle à la scène, ce qui se fait simplement via cet appel
|
||||
spaceship.SetParent(scene);
|
||||
// Et voilà, à partir de maintenant le modèle fait partie de la hiérarchie de la scène, et sera donc rendu avec cette dernière
|
||||
|
||||
// Nous avons besoin également d'une caméra, pour des raisons évidentes, celle-ci sera à l'écart du modèle
|
||||
// regardant dans sa direction.
|
||||
|
||||
|
|
@ -160,18 +160,15 @@ int main()
|
|||
// -PointLight: Lumière située à un endroit précis, envoyant de la lumière finie dans toutes les directions
|
||||
// -SpotLight: Lumière située à un endroit précis, envoyant de la lumière vers un endroit donné, avec un angle de diffusion
|
||||
|
||||
// Nous choisissons une lumière directionnelle représentant la nébuleuse de notre skybox
|
||||
NzLight nebulaLight(nzLightType_Directional);
|
||||
// Nous créons une lumière directionnelle pour représenter la nébuleuse de notre skybox
|
||||
NzLight* nebulaLight = scene.CreateNode<NzLight>(nzLightType_Directional);
|
||||
|
||||
// Il nous faut ensuite configurer la lumière
|
||||
// Pour commencer, sa couleur, la nébuleuse étant d'une couleur jaune, j'ai choisi ces valeurs
|
||||
nebulaLight.SetColor(NzColor(255, 182, 90));
|
||||
nebulaLight->SetColor(NzColor(255, 182, 90));
|
||||
|
||||
// Nous appliquons ensuite une rotation de sorte que la lumière dans la même direction que la nébuleuse
|
||||
nebulaLight.SetRotation(NzEulerAnglesf(0.f, 102.f, 0.f));
|
||||
|
||||
// Et nous ajoutons la lumière à la scène
|
||||
nebulaLight.SetParent(scene);
|
||||
nebulaLight->SetRotation(NzEulerAnglesf(0.f, 102.f, 0.f));
|
||||
|
||||
// Nous allons maintenant créer la fenêtre, dans laquelle nous ferons nos rendus
|
||||
// Celle-ci demande des paramètres plus complexes
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Nazara Engine - Audio module
|
||||
|
||||
Copyright (C) 2014 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
Copyright (C) 2015 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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
@ -22,13 +22,12 @@ struct NzMusicParams
|
|||
|
||||
class NzMusic;
|
||||
class NzSoundStream;
|
||||
class NzThread;
|
||||
|
||||
using NzMusicLoader = NzResourceLoader<NzMusic, NzMusicParams>;
|
||||
|
||||
struct NzMusicImpl;
|
||||
|
||||
class NAZARA_API NzMusic : public NzResource, public NzSoundEmitter
|
||||
class NAZARA_API NzMusic : public NzResource, public NzSoundEmitter, NzNonCopyable
|
||||
{
|
||||
friend NzMusicLoader;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Core/ObjectListenerWrapper.hpp>
|
||||
#include <Nazara/Core/RefCounted.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
|
|
@ -26,7 +27,9 @@ struct NzSoundBufferParams
|
|||
class NzSound;
|
||||
class NzSoundBuffer;
|
||||
|
||||
using NzSoundBufferConstListener = NzObjectListenerWrapper<const NzSoundBuffer>;
|
||||
using NzSoundBufferConstRef = NzObjectRef<const NzSoundBuffer>;
|
||||
using NzSoundBufferListener = NzObjectListenerWrapper<NzSoundBuffer>;
|
||||
using NzSoundBufferLoader = NzResourceLoader<NzSoundBuffer, NzSoundBufferParams>;
|
||||
using NzSoundBufferRef = NzObjectRef<NzSoundBuffer>;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// This file was automatically generated on 11 Jul 2014 at 10:21:52
|
||||
// This file was automatically generated on 17 Jan 2015 at 00:38:08
|
||||
|
||||
/*
|
||||
Nazara Engine - Core module
|
||||
|
|
@ -46,6 +46,7 @@
|
|||
#include <Nazara/Core/File.hpp>
|
||||
#include <Nazara/Core/Format.hpp>
|
||||
#include <Nazara/Core/Functor.hpp>
|
||||
#include <Nazara/Core/GuillotineBinPack.hpp>
|
||||
#include <Nazara/Core/HardwareInfo.hpp>
|
||||
#include <Nazara/Core/Hash.hpp>
|
||||
#include <Nazara/Core/Hashable.hpp>
|
||||
|
|
@ -54,6 +55,7 @@
|
|||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/LockGuard.hpp>
|
||||
#include <Nazara/Core/Log.hpp>
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
#include <Nazara/Core/MemoryManager.hpp>
|
||||
#include <Nazara/Core/MemoryPool.hpp>
|
||||
#include <Nazara/Core/MemoryStream.hpp>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
@ -19,6 +19,7 @@ class NzCallOnExit : NzNonCopyable
|
|||
NzCallOnExit(Func func = nullptr);
|
||||
~NzCallOnExit();
|
||||
|
||||
void CallAndReset(Func func = nullptr);
|
||||
void Reset(Func func = nullptr);
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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 <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
inline NzCallOnExit::NzCallOnExit(Func func) :
|
||||
|
|
@ -15,6 +16,14 @@ inline NzCallOnExit::~NzCallOnExit()
|
|||
m_func();
|
||||
}
|
||||
|
||||
inline void NzCallOnExit::CallAndReset(Func func)
|
||||
{
|
||||
if (m_func)
|
||||
m_func();
|
||||
|
||||
Reset(func);
|
||||
}
|
||||
|
||||
inline void NzCallOnExit::Reset(Func func)
|
||||
{
|
||||
m_func = func;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
@ -19,6 +19,7 @@ class NAZARA_API NzClock
|
|||
{
|
||||
public:
|
||||
NzClock(nzUInt64 startingValue = 0, bool paused = false);
|
||||
NzClock(const NzClock& clock) = default;
|
||||
|
||||
float GetSeconds() const;
|
||||
nzUInt64 GetMicroseconds() const;
|
||||
|
|
@ -30,6 +31,8 @@ class NAZARA_API NzClock
|
|||
void Restart();
|
||||
void Unpause();
|
||||
|
||||
NzClock& operator=(const NzClock& clock) = default;
|
||||
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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 <Nazara/Core/StringStream.hpp>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <stdexcept>
|
||||
|
|
@ -235,7 +236,7 @@ inline void NzColor::ToCMYK(const NzColor& color, float* cyan, float* magenta, f
|
|||
float c, m, y;
|
||||
ToCMY(color, &c, &m, &y);
|
||||
|
||||
float k = std::min(std::min(std::min(1.f, c), m), y);
|
||||
float k = std::min({1.f, c, m, y});
|
||||
|
||||
if (NzNumberEquals(k, 1.f))
|
||||
{
|
||||
|
|
@ -260,8 +261,8 @@ inline void NzColor::ToHSL(const NzColor& color, nzUInt8* hue, nzUInt8* saturati
|
|||
float g = color.g / 255.f;
|
||||
float b = color.b / 255.f;
|
||||
|
||||
float min = std::min(std::min(r, g), b); // Min. value of RGB
|
||||
float max = std::max(std::max(r, g), b); // Max. value of RGB
|
||||
float min = std::min({r, g, b}); // Min. value of RGB
|
||||
float max = std::max({r, g, b}); // Max. value of RGB
|
||||
|
||||
float deltaMax = max - min; //Delta RGB value
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Nazara Engine - Core module
|
||||
|
||||
Copyright (C) 2014 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
Copyright (C) 2015 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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
#define NAZARA_DIRECTORY_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
|
|
@ -27,7 +28,7 @@
|
|||
|
||||
class NzDirectoryImpl;
|
||||
|
||||
class NAZARA_API NzDirectory
|
||||
class NAZARA_API NzDirectory : NzNonCopyable
|
||||
{
|
||||
public:
|
||||
NzDirectory();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,85 @@
|
|||
// Copyright (C) 2015 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
|
||||
|
||||
// Implémentation originale de Jukka Jylänki (Merci de sa contribution au domaine public)
|
||||
// http://clb.demon.fi/projects/even-more-rectangle-bin-packing
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_GUILLOTINEBINPACK_HPP
|
||||
#define NAZARA_GUILLOTINEBINPACK_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/SparsePtr.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <vector>
|
||||
|
||||
class NAZARA_API NzGuillotineBinPack
|
||||
{
|
||||
public:
|
||||
enum FreeRectChoiceHeuristic
|
||||
{
|
||||
RectBestAreaFit,
|
||||
RectBestLongSideFit,
|
||||
RectBestShortSideFit,
|
||||
RectWorstAreaFit,
|
||||
RectWorstLongSideFit,
|
||||
RectWorstShortSideFit
|
||||
};
|
||||
|
||||
enum GuillotineSplitHeuristic
|
||||
{
|
||||
SplitLongerAxis,
|
||||
SplitLongerLeftoverAxis,
|
||||
SplitMaximizeArea,
|
||||
SplitMinimizeArea,
|
||||
SplitShorterAxis,
|
||||
SplitShorterLeftoverAxis
|
||||
};
|
||||
|
||||
NzGuillotineBinPack();
|
||||
NzGuillotineBinPack(unsigned int width, unsigned int height);
|
||||
NzGuillotineBinPack(const NzVector2ui& size);
|
||||
NzGuillotineBinPack(const NzGuillotineBinPack&) = default;
|
||||
NzGuillotineBinPack(NzGuillotineBinPack&&) = default;
|
||||
~NzGuillotineBinPack() = default;
|
||||
|
||||
void Clear();
|
||||
|
||||
void Expand(unsigned int newWidth, unsigned newHeight);
|
||||
void Expand(const NzVector2ui& newSize);
|
||||
|
||||
void FreeRectangle(const NzRectui& rect);
|
||||
|
||||
unsigned int GetHeight() const;
|
||||
float GetOccupancy() const;
|
||||
NzVector2ui GetSize() const;
|
||||
unsigned int GetWidth() const;
|
||||
|
||||
bool Insert(NzRectui* rects, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod);
|
||||
bool Insert(NzRectui* rects, bool* flipped, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod);
|
||||
bool Insert(NzRectui* rects, bool* flipped, bool* inserted, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod);
|
||||
|
||||
bool MergeFreeRectangles();
|
||||
|
||||
void Reset();
|
||||
void Reset(unsigned int width, unsigned int height);
|
||||
void Reset(const NzVector2ui& size);
|
||||
|
||||
NzGuillotineBinPack& operator=(const NzGuillotineBinPack&) = default;
|
||||
NzGuillotineBinPack& operator=(NzGuillotineBinPack&&) = default;
|
||||
|
||||
private:
|
||||
void SplitFreeRectAlongAxis(const NzRectui& freeRect, const NzRectui& placedRect, bool splitHorizontal);
|
||||
void SplitFreeRectByHeuristic(const NzRectui& freeRect, const NzRectui& placedRect, GuillotineSplitHeuristic method);
|
||||
|
||||
static int ScoreByHeuristic(int width, int height, const NzRectui& freeRect, FreeRectChoiceHeuristic rectChoice);
|
||||
|
||||
std::vector<NzRectui> m_freeRectangles;
|
||||
unsigned int m_height;
|
||||
unsigned int m_usedArea;
|
||||
unsigned int m_width;
|
||||
};
|
||||
|
||||
#endif // NAZARA_GUILLOTINEBINPACK_HPP
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <ostream>
|
||||
#include <iosfwd>
|
||||
|
||||
class NAZARA_API NzHashDigest
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) 2015 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_MEMORYHELPER_HPP
|
||||
#define NAZARA_MEMORYHELPER_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
void NzOperatorDelete(void* ptr);
|
||||
void* NzOperatorNew(std::size_t size);
|
||||
|
||||
template<typename T, typename... Args>
|
||||
T* NzPlacementNew(void* ptr, Args... args);
|
||||
|
||||
#include <Nazara/Core/MemoryHelper.inl>
|
||||
|
||||
#endif // NAZARA_MEMORYHELPER_HPP
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright (C) 2015 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
|
||||
|
||||
// Je ne suis pas fier des cinq lignes qui suivent mais difficile de faire autrement pour le moment...
|
||||
#ifdef NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION
|
||||
#define NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION_DEFINED
|
||||
#else
|
||||
#define NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION
|
||||
#endif
|
||||
|
||||
#include <Nazara/Core/MemoryManager.hpp>
|
||||
#include <new>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
inline void NzOperatorDelete(void* ptr)
|
||||
{
|
||||
#if NAZARA_CORE_MANAGE_MEMORY
|
||||
NzMemoryManager::Free(ptr);
|
||||
#else
|
||||
operator delete(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void* NzOperatorNew(std::size_t size)
|
||||
{
|
||||
#if NAZARA_CORE_MANAGE_MEMORY
|
||||
return NzMemoryManager::Allocate(size);
|
||||
#else
|
||||
return operator new(size);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
T* NzPlacementNew(void* ptr, Args... args)
|
||||
{
|
||||
return new (ptr) T(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
||||
// Si c'est nous qui avons défini la constante, alors il nous faut l'enlever (Pour éviter que le moteur entier n'en souffre)
|
||||
#ifndef NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION_DEFINED
|
||||
#undef NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION
|
||||
#endif
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,8 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
// Je ne suis pas fier des cinq lignes qui suivent mais difficile de faire autrement pour le moment...
|
||||
#ifdef NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION
|
||||
#define NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION_DEFINED
|
||||
#else
|
||||
#define NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION
|
||||
#endif
|
||||
|
||||
#include <new>
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<unsigned int blockSize, bool canGrow>
|
||||
|
|
@ -58,7 +51,7 @@ void* NzMemoryPool<blockSize, canGrow>::Allocate(unsigned int size)
|
|||
}
|
||||
}
|
||||
|
||||
return operator new(size);
|
||||
return NzOperatorNew(size);
|
||||
}
|
||||
|
||||
template<unsigned int blockSize, bool canGrow>
|
||||
|
|
@ -93,7 +86,7 @@ void NzMemoryPool<blockSize, canGrow>::Free(void* ptr)
|
|||
if (m_next)
|
||||
m_next->Free(ptr);
|
||||
else
|
||||
operator delete(ptr);
|
||||
NzOperatorDelete(ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -111,8 +104,3 @@ unsigned int NzMemoryPool<blockSize, canGrow>::GetSize() const
|
|||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
||||
// Si c'est nous qui avons défini la constante, alors il nous faut l'enlever (Pour éviter que le moteur entier n'en souffre)
|
||||
#ifndef NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION_DEFINED
|
||||
#undef NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright (C) 2015 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_OBJECTLISTENERWRAPPER_HPP
|
||||
#define NAZARA_OBJECTLISTENERWRAPPER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ObjectListener.hpp>
|
||||
#include <Nazara/Core/RefCounted.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
template<typename T>
|
||||
class NzObjectListenerWrapper
|
||||
{
|
||||
static_assert(std::is_base_of<NzRefCounted, T>::value, "ObjListenerWrapper should only be used with RefCounted-derived type");
|
||||
|
||||
public:
|
||||
NzObjectListenerWrapper(NzObjectListener* listener, int index = 0, T* object = nullptr);
|
||||
NzObjectListenerWrapper(const NzObjectListenerWrapper& listener);
|
||||
NzObjectListenerWrapper(NzObjectListenerWrapper&& listener);
|
||||
~NzObjectListenerWrapper();
|
||||
|
||||
bool IsValid() const;
|
||||
void Reset(T* object = nullptr);
|
||||
|
||||
operator bool() const;
|
||||
operator T*() const;
|
||||
T* operator->() const;
|
||||
|
||||
NzObjectListenerWrapper& operator=(T* object);
|
||||
NzObjectListenerWrapper& operator=(const NzObjectListenerWrapper& listener);
|
||||
NzObjectListenerWrapper& operator=(NzObjectListenerWrapper&& listener);
|
||||
|
||||
private:
|
||||
T* m_object;
|
||||
NzObjectListener* m_listener;
|
||||
int m_index;
|
||||
};
|
||||
|
||||
#include <Nazara/Core/ObjectListenerWrapper.inl>
|
||||
|
||||
#endif // NAZARA_OBJECTLISTENERWRAPPER_HPP
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
// Copyright (C) 2015 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 <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<typename T>
|
||||
NzObjectListenerWrapper<T>::NzObjectListenerWrapper(NzObjectListener* listener, int index, T* object) :
|
||||
m_object(nullptr),
|
||||
m_listener(listener),
|
||||
m_index(index)
|
||||
{
|
||||
Reset(object);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzObjectListenerWrapper<T>::NzObjectListenerWrapper(const NzObjectListenerWrapper& listener) :
|
||||
m_object(nullptr),
|
||||
m_listener(listener.m_listener),
|
||||
m_index(listener.m_index)
|
||||
{
|
||||
Reset(listener.m_object);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzObjectListenerWrapper<T>::NzObjectListenerWrapper(NzObjectListenerWrapper&& listener) :
|
||||
m_object(listener.m_object),
|
||||
m_listener(listener.m_listener),
|
||||
m_index(listener.m_index)
|
||||
{
|
||||
listener.m_object = nullptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzObjectListenerWrapper<T>::~NzObjectListenerWrapper()
|
||||
{
|
||||
Reset(nullptr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzObjectListenerWrapper<T>::IsValid() const
|
||||
{
|
||||
return m_object != nullptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzObjectListenerWrapper<T>::Reset(T* object)
|
||||
{
|
||||
if (object)
|
||||
object->AddObjectListener(m_listener, m_index);
|
||||
|
||||
if (m_object)
|
||||
m_object->RemoveObjectListener(m_listener);
|
||||
|
||||
m_object = object;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzObjectListenerWrapper<T>::operator bool() const
|
||||
{
|
||||
return IsValid();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzObjectListenerWrapper<T>::operator T*() const
|
||||
{
|
||||
return m_object;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T* NzObjectListenerWrapper<T>::operator->() const
|
||||
{
|
||||
return m_object;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzObjectListenerWrapper<T>& NzObjectListenerWrapper<T>::operator=(T* object)
|
||||
{
|
||||
Reset(object);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzObjectListenerWrapper<T>& NzObjectListenerWrapper<T>::operator=(const NzObjectListenerWrapper& listener)
|
||||
{
|
||||
m_index = listener.m_index;
|
||||
m_listener = listener.m_listener;
|
||||
Reset(listener.m_object);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzObjectListenerWrapper<T>& NzObjectListenerWrapper<T>::operator=(NzObjectListenerWrapper&& listener)
|
||||
{
|
||||
Reset();
|
||||
|
||||
m_index = listener.m_index;
|
||||
m_listener = listener.m_listener;
|
||||
m_object = listener.m_object;
|
||||
|
||||
listener.m_object = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
@ -18,26 +18,26 @@ class NzObjectRef
|
|||
|
||||
public:
|
||||
NzObjectRef();
|
||||
NzObjectRef(T* resource);
|
||||
NzObjectRef(T* object);
|
||||
NzObjectRef(const NzObjectRef& ref);
|
||||
NzObjectRef(NzObjectRef&& ref) noexcept;
|
||||
~NzObjectRef();
|
||||
|
||||
bool IsValid() const;
|
||||
T* Release();
|
||||
bool Reset(T* resource = nullptr);
|
||||
bool Reset(T* object = nullptr);
|
||||
NzObjectRef& Swap(NzObjectRef& ref);
|
||||
|
||||
operator bool() const;
|
||||
operator T*() const;
|
||||
T* operator->() const;
|
||||
|
||||
NzObjectRef& operator=(T* resource);
|
||||
NzObjectRef& operator=(T* object);
|
||||
NzObjectRef& operator=(const NzObjectRef& ref);
|
||||
NzObjectRef& operator=(NzObjectRef&& ref) noexcept;
|
||||
|
||||
private:
|
||||
T* m_resource;
|
||||
T* m_object;
|
||||
};
|
||||
|
||||
#include <Nazara/Core/ObjectRef.inl>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
@ -7,70 +7,70 @@
|
|||
|
||||
template<typename T>
|
||||
NzObjectRef<T>::NzObjectRef() :
|
||||
m_resource(nullptr)
|
||||
m_object(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzObjectRef<T>::NzObjectRef(T* resource) :
|
||||
m_resource(resource)
|
||||
NzObjectRef<T>::NzObjectRef(T* object) :
|
||||
m_object(object)
|
||||
{
|
||||
if (m_resource)
|
||||
m_resource->AddReference();
|
||||
if (m_object)
|
||||
m_object->AddReference();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzObjectRef<T>::NzObjectRef(const NzObjectRef& ref) :
|
||||
m_resource(ref.m_resource)
|
||||
m_object(ref.m_object)
|
||||
{
|
||||
if (m_resource)
|
||||
m_resource->AddReference();
|
||||
if (m_object)
|
||||
m_object->AddReference();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzObjectRef<T>::NzObjectRef(NzObjectRef&& ref) noexcept :
|
||||
m_resource(ref.m_resource)
|
||||
m_object(ref.m_object)
|
||||
{
|
||||
ref.m_resource = nullptr; // On vole la référence
|
||||
ref.m_object = nullptr; // On vole la référence
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzObjectRef<T>::~NzObjectRef()
|
||||
{
|
||||
if (m_resource)
|
||||
m_resource->RemoveReference();
|
||||
if (m_object)
|
||||
m_object->RemoveReference();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzObjectRef<T>::IsValid() const
|
||||
{
|
||||
return m_resource != nullptr;
|
||||
return m_object != nullptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T* NzObjectRef<T>::Release()
|
||||
{
|
||||
T* resource = m_resource;
|
||||
m_resource = nullptr;
|
||||
T* object = m_object;
|
||||
m_object = nullptr;
|
||||
|
||||
return resource;
|
||||
return object;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzObjectRef<T>::Reset(T* resource)
|
||||
bool NzObjectRef<T>::Reset(T* object)
|
||||
{
|
||||
bool destroyed = false;
|
||||
if (m_resource != resource)
|
||||
if (m_object != object)
|
||||
{
|
||||
if (m_resource)
|
||||
if (m_object)
|
||||
{
|
||||
destroyed = m_resource->RemoveReference();
|
||||
m_resource = nullptr;
|
||||
destroyed = m_object->RemoveReference();
|
||||
m_object = nullptr;
|
||||
}
|
||||
|
||||
m_resource = resource;
|
||||
if (m_resource)
|
||||
m_resource->AddReference();
|
||||
m_object = object;
|
||||
if (m_object)
|
||||
m_object->AddReference();
|
||||
}
|
||||
|
||||
return destroyed;
|
||||
|
|
@ -79,7 +79,7 @@ bool NzObjectRef<T>::Reset(T* resource)
|
|||
template<typename T>
|
||||
NzObjectRef<T>& NzObjectRef<T>::Swap(NzObjectRef& ref)
|
||||
{
|
||||
std::swap(m_resource, ref.m_resource);
|
||||
std::swap(m_object, ref.m_object);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -93,19 +93,19 @@ NzObjectRef<T>::operator bool() const
|
|||
template<typename T>
|
||||
NzObjectRef<T>::operator T*() const
|
||||
{
|
||||
return m_resource;
|
||||
return m_object;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T* NzObjectRef<T>::operator->() const
|
||||
{
|
||||
return m_resource;
|
||||
return m_object;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzObjectRef<T>& NzObjectRef<T>::operator=(T* resource)
|
||||
NzObjectRef<T>& NzObjectRef<T>::operator=(T* object)
|
||||
{
|
||||
Reset(resource);
|
||||
Reset(object);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -113,7 +113,7 @@ NzObjectRef<T>& NzObjectRef<T>::operator=(T* resource)
|
|||
template<typename T>
|
||||
NzObjectRef<T>& NzObjectRef<T>::operator=(const NzObjectRef& ref)
|
||||
{
|
||||
Reset(ref.m_resource);
|
||||
Reset(ref.m_object);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -123,7 +123,7 @@ NzObjectRef<T>& NzObjectRef<T>::operator=(NzObjectRef&& ref) noexcept
|
|||
{
|
||||
Reset();
|
||||
|
||||
std::swap(m_resource, ref.m_resource);
|
||||
std::swap(m_object, ref.m_object);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ template <typename T, typename M> M NzImplGetMemberType(M T::*);
|
|||
template <typename T, typename R, R T::*M>
|
||||
constexpr std::size_t NzImplOffsetOf()
|
||||
{
|
||||
return reinterpret_cast<std::size_t>(&(((T*)0)->*M));
|
||||
return reinterpret_cast<std::size_t>(&((static_cast<T*>(0))->*M));
|
||||
}
|
||||
|
||||
#define NzOffsetOf(type, member) NzImplOffsetOf<decltype(NzImplGetClassType(&type::member)), decltype(NzImplGetMemberType(&type::member)), &type::member>()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ class NAZARA_API NzRefCounted
|
|||
{
|
||||
public:
|
||||
NzRefCounted(bool persistent = true);
|
||||
NzRefCounted(const NzRefCounted&) = delete;
|
||||
NzRefCounted(NzRefCounted&&) = delete;
|
||||
virtual ~NzRefCounted();
|
||||
|
||||
void AddObjectListener(NzObjectListener* listener, int index = 0) const;
|
||||
|
|
@ -37,6 +39,9 @@ class NAZARA_API NzRefCounted
|
|||
|
||||
bool SetPersistent(bool persistent = true, bool checkReferenceCount = false);
|
||||
|
||||
NzRefCounted& operator=(const NzRefCounted&) = delete;
|
||||
NzRefCounted& operator=(NzRefCounted&&) = delete;
|
||||
|
||||
protected:
|
||||
void NotifyCreated();
|
||||
void NotifyDestroy();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
@ -14,12 +14,17 @@ class NAZARA_API NzResource
|
|||
{
|
||||
public:
|
||||
NzResource() = default;
|
||||
NzResource(const NzResource&) = default;
|
||||
NzResource(NzResource&&) = default;
|
||||
virtual ~NzResource();
|
||||
|
||||
NzString GetFilePath() const;
|
||||
const NzString& GetFilePath() const;
|
||||
|
||||
void SetFilePath(const NzString& filePath);
|
||||
|
||||
NzResource& operator=(const NzResource&) = default;
|
||||
NzResource& operator=(NzResource&&) = default;
|
||||
|
||||
private:
|
||||
NzString m_filePath;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
@ -22,6 +22,7 @@ class NzResourceLoader
|
|||
public:
|
||||
using ExtensionGetter = bool (*)(const NzString& extension);
|
||||
using FileLoader = bool (*)(Type* resource, const NzString& filePath, const Parameters& parameters);
|
||||
using MemoryLoader = bool (*)(Type* resource, const void* data, std::size_t size, const Parameters& parameters);
|
||||
using StreamChecker = nzTernary (*)(NzInputStream& stream, const Parameters& parameters);
|
||||
using StreamLoader = bool (*)(Type* resource, NzInputStream& stream, const Parameters& parameters);
|
||||
|
||||
|
|
@ -31,10 +32,10 @@ class NzResourceLoader
|
|||
static bool LoadFromMemory(Type* resource, const void* data, unsigned int size, const Parameters& parameters = Parameters());
|
||||
static bool LoadFromStream(Type* resource, NzInputStream& stream, const Parameters& parameters = Parameters());
|
||||
|
||||
static void RegisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader = nullptr);
|
||||
static void UnregisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader = nullptr);
|
||||
static void RegisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader = nullptr, MemoryLoader memoryLoader = nullptr);
|
||||
static void UnregisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader = nullptr, MemoryLoader memoryLoader = nullptr);
|
||||
|
||||
using Loader = std::tuple<ExtensionGetter, StreamChecker, StreamLoader, FileLoader>;
|
||||
using Loader = std::tuple<ExtensionGetter, StreamChecker, StreamLoader, FileLoader, MemoryLoader>;
|
||||
using LoaderList = std::list<Loader>;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
@ -123,9 +123,77 @@ bool NzResourceLoader<Type, Parameters>::LoadFromFile(Type* resource, const NzSt
|
|||
template<typename Type, typename Parameters>
|
||||
bool NzResourceLoader<Type, Parameters>::LoadFromMemory(Type* resource, const void* data, unsigned int size, const Parameters& parameters)
|
||||
{
|
||||
#if NAZARA_CORE_SAFE
|
||||
if (!parameters.IsValid())
|
||||
{
|
||||
NazaraError("Invalid parameters");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
NazaraError("No data to load");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
NzMemoryStream stream(data, size);
|
||||
|
||||
return LoadFromStream(resource, stream, parameters);
|
||||
bool found = false;
|
||||
for (Loader& loader : Type::s_loaders)
|
||||
{
|
||||
StreamChecker checkFunc = std::get<1>(loader);
|
||||
StreamLoader streamLoader = std::get<2>(loader);
|
||||
MemoryLoader memoryLoader = std::get<4>(loader);
|
||||
|
||||
nzTernary recognized = nzTernary_Unknown;
|
||||
if (memoryLoader)
|
||||
{
|
||||
if (checkFunc)
|
||||
{
|
||||
stream.SetCursorPos(0);
|
||||
|
||||
recognized = checkFunc(stream, parameters);
|
||||
if (recognized == nzTernary_False)
|
||||
continue;
|
||||
else
|
||||
found = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
recognized = nzTernary_Unknown;
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (memoryLoader(resource, data, size, parameters))
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
stream.SetCursorPos(0);
|
||||
|
||||
recognized = checkFunc(stream, parameters);
|
||||
if (recognized == nzTernary_False)
|
||||
continue;
|
||||
else if (recognized == nzTernary_True)
|
||||
found = true;
|
||||
|
||||
stream.SetCursorPos(0);
|
||||
|
||||
if (streamLoader(resource, stream, parameters))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (recognized == nzTernary_True)
|
||||
NazaraWarning("Loader failed");
|
||||
}
|
||||
|
||||
if (found)
|
||||
NazaraError("Failed to load file: all loaders failed");
|
||||
else
|
||||
NazaraError("Failed to load file: no loader found");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
|
|
@ -181,7 +249,7 @@ bool NzResourceLoader<Type, Parameters>::LoadFromStream(Type* resource, NzInputS
|
|||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
void NzResourceLoader<Type, Parameters>::RegisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader)
|
||||
void NzResourceLoader<Type, Parameters>::RegisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader, MemoryLoader memoryLoader)
|
||||
{
|
||||
#if NAZARA_CORE_SAFE
|
||||
if (streamLoader)
|
||||
|
|
@ -192,20 +260,20 @@ void NzResourceLoader<Type, Parameters>::RegisterLoader(ExtensionGetter extensio
|
|||
return;
|
||||
}
|
||||
}
|
||||
else if (!fileLoader)
|
||||
else if (!fileLoader && !memoryLoader)
|
||||
{
|
||||
NazaraError("Neither FileLoader nor StreamLoader were present");
|
||||
NazaraError("Neither FileLoader nor MemoryLoader nor StreamLoader were present");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
Type::s_loaders.push_front(std::make_tuple(extensionGetter, checkFunc, streamLoader, fileLoader));
|
||||
Type::s_loaders.push_front(std::make_tuple(extensionGetter, checkFunc, streamLoader, fileLoader, memoryLoader));
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
void NzResourceLoader<Type, Parameters>::UnregisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader)
|
||||
void NzResourceLoader<Type, Parameters>::UnregisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader, MemoryLoader memoryLoader)
|
||||
{
|
||||
Type::s_loaders.remove(std::make_tuple(extensionGetter, checkFunc, streamLoader, fileLoader));
|
||||
Type::s_loaders.remove(std::make_tuple(extensionGetter, checkFunc, streamLoader, fileLoader, memoryLoader));
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
@ -10,30 +10,49 @@
|
|||
///FIXME: Est-ce que SparsePtr est vraiment le meilleur nom pour cette classe ?
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
template<typename T>
|
||||
class NzSparsePtr
|
||||
{
|
||||
public:
|
||||
using BytePtr = typename std::conditional<std::is_const<T>::value, const nzUInt8*, nzUInt8*>::type;
|
||||
using VoidPtr = typename std::conditional<std::is_const<T>::value, const void*, void*>::type;
|
||||
|
||||
NzSparsePtr();
|
||||
NzSparsePtr(void* ptr, unsigned int stride);
|
||||
NzSparsePtr(T* ptr);
|
||||
NzSparsePtr(VoidPtr ptr, int stride);
|
||||
template<typename U> NzSparsePtr(const NzSparsePtr<U>& ptr);
|
||||
NzSparsePtr(const NzSparsePtr& ptr) = default;
|
||||
~NzSparsePtr() = default;
|
||||
|
||||
void* Get() const;
|
||||
unsigned int GetStride() const;
|
||||
void Set(void* ptr);
|
||||
void SetStride(unsigned int stride);
|
||||
VoidPtr GetPtr() const;
|
||||
int GetStride() const;
|
||||
|
||||
void Reset();
|
||||
void Reset(T* ptr);
|
||||
void Reset(VoidPtr ptr, int stride);
|
||||
void Reset(const NzSparsePtr& ptr);
|
||||
template<typename U> void Reset(const NzSparsePtr<U>& ptr);
|
||||
|
||||
void SetPtr(VoidPtr ptr);
|
||||
void SetStride(int stride);
|
||||
|
||||
operator bool() const;
|
||||
operator T*() const;
|
||||
T& operator*() const;
|
||||
T& operator->() const;
|
||||
T& operator[](unsigned int index) const;
|
||||
T& operator[](int index) const;
|
||||
|
||||
NzSparsePtr operator+(int count) const;
|
||||
NzSparsePtr operator+(unsigned int count) const;
|
||||
NzSparsePtr operator-(int count) const;
|
||||
NzSparsePtr operator-(unsigned int count) const;
|
||||
std::ptrdiff_t operator-(const NzSparsePtr& ptr) const;
|
||||
|
||||
NzSparsePtr& operator+=(unsigned int count);
|
||||
NzSparsePtr& operator-=(unsigned int count);
|
||||
NzSparsePtr& operator+=(int count);
|
||||
NzSparsePtr& operator-=(int count);
|
||||
|
||||
NzSparsePtr& operator++();
|
||||
NzSparsePtr operator++(int);
|
||||
|
|
@ -51,8 +70,8 @@ class NzSparsePtr
|
|||
NzSparsePtr& operator=(const NzSparsePtr& ptr) = default;
|
||||
|
||||
private:
|
||||
nzUInt8* m_ptr;
|
||||
unsigned int m_stride;
|
||||
BytePtr m_ptr;
|
||||
int m_stride;
|
||||
};
|
||||
|
||||
#include <Nazara/Core/SparsePtr.inl>
|
||||
|
|
|
|||
|
|
@ -1,47 +1,108 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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 <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T>::NzSparsePtr() :
|
||||
m_ptr(nullptr),
|
||||
m_stride(0)
|
||||
NzSparsePtr<T>::NzSparsePtr()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T>::NzSparsePtr(void* ptr, unsigned int stride)
|
||||
NzSparsePtr<T>::NzSparsePtr(T* ptr)
|
||||
{
|
||||
Set(ptr);
|
||||
SetStride(stride);
|
||||
Reset(ptr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void* NzSparsePtr<T>::Get() const
|
||||
NzSparsePtr<T>::NzSparsePtr(VoidPtr ptr, int stride)
|
||||
{
|
||||
Reset(ptr, stride);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzSparsePtr<T>::NzSparsePtr(const NzSparsePtr<U>& ptr)
|
||||
{
|
||||
Reset(ptr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename NzSparsePtr<T>::VoidPtr NzSparsePtr<T>::GetPtr() const
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
unsigned int NzSparsePtr<T>::GetStride() const
|
||||
int NzSparsePtr<T>::GetStride() const
|
||||
{
|
||||
return m_stride;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzSparsePtr<T>::Set(void* ptr)
|
||||
void NzSparsePtr<T>::Reset()
|
||||
{
|
||||
m_ptr = reinterpret_cast<nzUInt8*>(ptr);
|
||||
SetPtr(nullptr);
|
||||
SetStride(0);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzSparsePtr<T>::SetStride(unsigned int stride)
|
||||
void NzSparsePtr<T>::Reset(T* ptr)
|
||||
{
|
||||
SetPtr(ptr);
|
||||
SetStride(sizeof(T));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzSparsePtr<T>::Reset(VoidPtr ptr, int stride)
|
||||
{
|
||||
SetPtr(ptr);
|
||||
SetStride(stride);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzSparsePtr<T>::Reset(const NzSparsePtr& ptr)
|
||||
{
|
||||
SetPtr(ptr.GetPtr());
|
||||
SetStride(ptr.GetStride());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
void NzSparsePtr<T>::Reset(const NzSparsePtr<U>& ptr)
|
||||
{
|
||||
static_assert(std::is_convertible<U*, T*>::value, "Source type pointer cannot be implicitely converted to target type pointer");
|
||||
|
||||
SetPtr(static_cast<T*>(ptr.GetPtr()));
|
||||
SetStride(ptr.GetStride());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzSparsePtr<T>::SetPtr(VoidPtr ptr)
|
||||
{
|
||||
m_ptr = reinterpret_cast<BytePtr>(ptr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzSparsePtr<T>::SetStride(int stride)
|
||||
{
|
||||
m_stride = stride;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T>::operator bool() const
|
||||
{
|
||||
return m_ptr != nullptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T>::operator T*() const
|
||||
{
|
||||
return reinterpret_cast<T*>(m_ptr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T& NzSparsePtr<T>::operator*() const
|
||||
{
|
||||
|
|
@ -55,17 +116,29 @@ T& NzSparsePtr<T>::operator->() const
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
T& NzSparsePtr<T>::operator[](unsigned int index) const
|
||||
T& NzSparsePtr<T>::operator[](int index) const
|
||||
{
|
||||
return *reinterpret_cast<T*>(m_ptr + index*m_stride);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T> NzSparsePtr<T>::operator+(int count) const
|
||||
{
|
||||
return NzSparsePtr(m_ptr + count*m_stride, m_stride);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T> NzSparsePtr<T>::operator+(unsigned int count) const
|
||||
{
|
||||
return NzSparsePtr(m_ptr + count*m_stride, m_stride);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T> NzSparsePtr<T>::operator-(int count) const
|
||||
{
|
||||
return NzSparsePtr(m_ptr - count*m_stride, m_stride);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T> NzSparsePtr<T>::operator-(unsigned int count) const
|
||||
{
|
||||
|
|
@ -73,16 +146,24 @@ NzSparsePtr<T> NzSparsePtr<T>::operator-(unsigned int count) const
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T>& NzSparsePtr<T>::operator+=(unsigned int count)
|
||||
std::ptrdiff_t NzSparsePtr<T>::operator-(const NzSparsePtr& ptr) const
|
||||
{
|
||||
return (m_ptr - ptr.m_ptr)/m_stride;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T>& NzSparsePtr<T>::operator+=(int count)
|
||||
{
|
||||
m_ptr += count*m_stride;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T>& NzSparsePtr<T>::operator-=(unsigned int count)
|
||||
NzSparsePtr<T>& NzSparsePtr<T>::operator-=(int count)
|
||||
{
|
||||
m_ptr -= count*m_stride;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -90,6 +171,7 @@ template<typename T>
|
|||
NzSparsePtr<T>& NzSparsePtr<T>::operator++()
|
||||
{
|
||||
m_ptr += m_stride;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// Copyright (C) 2015 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
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue