Refactored mathematics module

Added AABBs
Added code examples
Added experimental support for texture arrays (1D/2D)
Added initialisers (new way of initialising modules)
Added global headers (Plus a global header generator script)
Added pattern support for directory
Added support for spinlocks critical section on Windows
Added NzRenderWindow::SetFramerateLimit
Core project now includes Mathematics files
Fixed color implementation using double
Fixed declaration needing renderer include
Fixed MLT not clearing nextFree(File/Line) after Free
Fixed move operators not being noexcept
Fixed thread-safety (Now working correctly - If I'm lucky)
Moved Resource to core
New interface for modules
New interface for the renderer
Put some global functions to anonymous namespace
Removed empty modules
Renamed ThreadCondition to ConditionVariable
Replaced redirect to cerr log option by duplicate to cout
Setting mouse position relative to a window will make this window ignore
the event
Shaders sending methods no longer takes the uniform variable name (it's
using ID instead)
Using new OpenGL 4.3 header
This commit is contained in:
Lynix
2012-08-08 04:44:17 +02:00
parent 06eda4eba9
commit b442ab0bd2
142 changed files with 6861 additions and 2326 deletions

View File

@@ -8,10 +8,10 @@
#define NAZARA_BYTEARRAY_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Conig.hpp>
#include <Nazara/Core/Config.hpp>
#include <Nazara/Core/Hashable.hpp>
#if NAZARA_THREADSAFETY_BYTEARRAY
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_BYTEARRAY
#include <Nazara/Core/ThreadSafety.hpp>
#else
#include <Nazara/Core/ThreadSafetyOff.hpp>
@@ -28,7 +28,7 @@ class NAZARA_API NzByteArray : public NzHashable
NzByteArray();
NzByteArray(const nzUInt8* buffer, unsigned int bufferLength);
NzByteArray(const NzByteArray& buffer);
NzByteArray(NzByteArray&& buffer);
NzByteArray(NzByteArray&& buffer) noexcept;
NzByteArray(SharedArray* sharedArray);
~NzByteArray();
@@ -80,7 +80,7 @@ class NAZARA_API NzByteArray : public NzHashable
nzUInt8 operator[](unsigned int pos) const;
NzByteArray& operator=(const NzByteArray& byteArray);
NzByteArray& operator=(NzByteArray&& byteArray);
NzByteArray& operator=(NzByteArray&& byteArray) noexcept;
NzByteArray operator+(const NzByteArray& byteArray) const;
NzByteArray& operator+=(const NzByteArray& byteArray);
@@ -89,10 +89,7 @@ class NAZARA_API NzByteArray : public NzHashable
struct NAZARA_API SharedArray
{
SharedArray() :
refCount(1)
{
}
SharedArray() = default;
SharedArray(unsigned short referenceCount, unsigned int bufferSize, unsigned int arraySize, nzUInt8* ptr) :
capacity(bufferSize),
@@ -104,7 +101,7 @@ class NAZARA_API NzByteArray : public NzHashable
unsigned int capacity;
unsigned int size;
unsigned short refCount;
unsigned short refCount = 1;
nzUInt8* buffer;
NazaraMutex(mutex)

View File

@@ -9,7 +9,7 @@
#include <Nazara/Prerequesites.hpp>
#if NAZARA_THREADSAFETY_CLOCK
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_CLOCK
#include <Nazara/Core/ThreadSafety.hpp>
#else
#include <Nazara/Core/ThreadSafetyOff.hpp>

View File

@@ -8,7 +8,7 @@
#include <cmath>
#include <cstdlib>
#include <stdexcept>
#include <Nazara/Utility/Debug.hpp>
#include <Nazara/Core/Debug.hpp>
inline NzColor::NzColor()
{
@@ -198,26 +198,26 @@ inline NzColor NzColor::FromXYZ(float x, float y, float z)
y /= 100; // Y from 0 to 100.000
z /= 100; // Z from 0 to 108.883
double r = x * 3.2406 + y * -1.5372 + z * -0.4986;
double g = x * -0.9689 + y * 1.8758 + z * 0.0415;
double b = x * 0.0557 + y * -0.2040 + z * 1.0570;
float r = x * 3.2406f + y * -1.5372f + z * -0.4986f;
float g = x * -0.9689f + y * 1.8758f + z * 0.0415f;
float b = x * 0.0557f + y * -0.2040f + z * 1.0570f;
if (r > 0.0031308f)
r = 1.055 * (std::pow(r, 1.0/2.4)) - 0.055;
r = 1.055f * (std::pow(r, 1.f/2.4f)) - 0.055f;
else
r *= 12.92;
r *= 12.92f;
if (g > 0.0031308f)
g = 1.055 * (std::pow(g, 1.0/2.4)) - 0.055;
g = 1.055f * (std::pow(r, 1.f/2.4f)) - 0.055f;
else
g *= 12.92;
g *= 12.92f;
if (b > 0.0031308f)
b = 1.055 * (std::pow(b, 1.0/2.4)) - 0.055;
b = 1.055f * (std::pow(r, 1.f/2.4f)) - 0.055f;
else
b *= 12.92;
b *= 12.92f;
return NzColor(r * 255.0, g * 255.0, b * 255.0);
return NzColor(r * 255.f, g * 255.f, b * 255.f);
}
inline void NzColor::ToCMY(const NzColor& color, float* cyan, float* magenta, float* yellow)
@@ -409,4 +409,4 @@ inline std::ostream& operator<<(std::ostream& out, const NzColor& color)
return out << color.ToString();
}
#include <Nazara/Utility/DebugOff.hpp>
#include <Nazara/Core/DebugOff.hpp>

View File

@@ -4,19 +4,19 @@
#pragma once
#ifndef NAZARA_THREADCONDITION_HPP
#define NAZARA_THREADCONDITION_HPP
#ifndef NAZARA_CONDITIONVARIABLE_HPP
#define NAZARA_CONDITIONVARIABLE_HPP
#include <Nazara/Prerequesites.hpp>
class NzConditionVariableImpl;
class NzMutex;
class NzThreadConditionImpl;
class NAZARA_API NzThreadCondition
class NAZARA_API NzConditionVariable
{
public:
NzThreadCondition();
~NzThreadCondition();
NzConditionVariable();
~NzConditionVariable();
void Signal();
void SignalAll();
@@ -25,7 +25,7 @@ class NAZARA_API NzThreadCondition
bool Wait(NzMutex* mutex, nzUInt32 timeout);
private:
NzThreadConditionImpl* m_impl;
NzConditionVariableImpl* m_impl;
};
#endif // NAZARA_THREADCONDITION_HPP
#endif // NAZARA_CONDITIONVARIABLE_HPP

View File

@@ -44,34 +44,36 @@
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
#define NAZARA_CORE_MEMORYLEAKTRACKER 0
// Standardise les séparateurs des dossiers selon le système d'exploitation courant
// Standardise les séparateurs des dossiers selon le système d'exploitation courant (Léger coût à l'exécution)
#define NAZARA_CORE_NORMALIZE_DIRECTORY_SEPARATORS 1
// Précision des réels lors de la transformation en texte (Max. chiffres après la virgule)
#define NAZARA_CORE_REAL_PRECISION 6
// Redirige la sortie du log sur le flux d'erreur standard (cerr) en cas d'erreur d'écriture (ou d'ouverture du fichier)
#define NAZARA_CORE_REDIRECT_TO_CERR_ON_LOG_FAILURE 1
// Duplique la sortie du log sur le flux de sortie standard (cout)
#define NAZARA_CORE_DUPLICATE_TO_COUT 0
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
#define NAZARA_CORE_SAFE 1
// Protège le module des accès concurrentiels
// Protège les classes des accès concurrentiels
#define NAZARA_CORE_THREADSAFE 1
#if NAZARA_CORE_THREADSAFE
#define NAZARA_THREADSAFETY_BYTEARRAY 1 // NzByteArray (COW)
#define NAZARA_THREADSAFETY_CLOCK 0 // NzClock
#define NAZARA_THREADSAFETY_DIRECTORY 1 // NzDirectory
#define NAZARA_THREADSAFETY_DYNLIB 1 // NzDynLib
#define NAZARA_THREADSAFETY_FILE 1 // NzFile
#define NAZARA_THREADSAFETY_HASHDIGEST 0 // NzHashDigest
#define NAZARA_THREADSAFETY_LOG 1 // NzLog
#define NAZARA_THREADSAFETY_STRING 1 // NzString (COW)
#define NAZARA_THREADSAFETY_STRINGSTREAM 0 // NzStringStream
#endif
// Les classes à protéger des accès concurrentiels
#define NAZARA_THREADSAFETY_BYTEARRAY 1 // NzByteArray (COW)
#define NAZARA_THREADSAFETY_CLOCK 0 // NzClock
#define NAZARA_THREADSAFETY_DIRECTORY 1 // NzDirectory
#define NAZARA_THREADSAFETY_DYNLIB 1 // NzDynLib
#define NAZARA_THREADSAFETY_FILE 1 // NzFile
#define NAZARA_THREADSAFETY_HASHDIGEST 0 // NzHashDigest
#define NAZARA_THREADSAFETY_LOG 1 // NzLog
#define NAZARA_THREADSAFETY_STRING 1 // NzString (COW)
#define NAZARA_THREADSAFETY_STRINGSTREAM 0 // NzStringStream
// Optimise certaines parties du code avec les avancées venues de Windows Vista (Nécessite Vista ou supérieur et compilateur compatible)
// Le nombre de spinlocks à utiliser avec les critical sections de Windows (0 pour désactiver)
#define NAZARA_CORE_WINDOWS_CS_SPINLOCKS 4096
// Optimise certaines parties du code avec certaines avancées venues de Windows Vista (Casse la compatibilité XP mais n'affecte pas les autres OS)
#define NAZARA_CORE_WINDOWS_VISTA 0
/*

View File

@@ -0,0 +1,29 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_CORE_HPP
#define NAZARA_CORE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Initializer.hpp>
class NAZARA_API NzCore
{
public:
NzCore() = delete;
~NzCore() = delete;
static bool Initialize();
static bool IsInitialized();
static void Uninitialize();
private:
static unsigned int s_moduleReferenceCouter;
};
#endif // NAZARA_CORE_HPP

View File

@@ -19,7 +19,7 @@
#define NAZARA_DIRECTORY_SEPARATOR '/'
#endif
#if NAZARA_THREADSAFETY_DIRECTORY
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_DIRECTORY
#include <Nazara/Core/ThreadSafety.hpp>
#else
#include <Nazara/Core/ThreadSafetyOff.hpp>
@@ -36,10 +36,12 @@ class NAZARA_API NzDirectory
void Close();
NzString GetPattern() const;
NzString GetResultName() const;
NzString GetResultPath() const;
nzUInt64 GetResultSize() const;
bool IsOpen() const;
bool IsResultDirectory() const;
bool NextResult(bool skipDots = true);
@@ -47,6 +49,7 @@ class NAZARA_API NzDirectory
bool Open();
void SetDirectory(const NzString& dirPath);
void SetPattern(const NzString& pattern);
static bool Copy(const NzString& sourcePath, const NzString& destPath);
static bool Create(const NzString& dirPath, bool recursive = false);
@@ -59,7 +62,8 @@ class NAZARA_API NzDirectory
NazaraMutexAttrib(m_mutex, mutable)
NzString m_dirPath;
NzDirectoryImpl* m_impl;
NzString m_pattern;
NzDirectoryImpl* m_impl = nullptr;
};
#endif // NAZARA_DIRECTORY_HPP

View File

@@ -11,7 +11,7 @@
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/String.hpp>
#if NAZARA_THREADSAFETY_DYNLIB
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_DYNLIB
#include <Nazara/Core/ThreadSafety.hpp>
#else
#include <Nazara/Core/ThreadSafetyOff.hpp>

View File

@@ -16,7 +16,7 @@
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/String.hpp>
#if NAZARA_THREADSAFETY_FILE
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_FILE
#include <Nazara/Core/ThreadSafety.hpp>
#else
#include <Nazara/Core/ThreadSafetyOff.hpp>
@@ -50,7 +50,7 @@ class NAZARA_API NzFile : public NzHashable, public NzInputStream, NzNonCopyable
NzFile();
NzFile(const NzString& filePath);
NzFile(const NzString& filePath, unsigned long openMode);
NzFile(NzFile&& file);
NzFile(NzFile&& file) noexcept;
~NzFile();
bool Copy(const NzString& newFilePath);
@@ -92,7 +92,7 @@ class NAZARA_API NzFile : public NzHashable, public NzInputStream, NzNonCopyable
std::size_t Write(const void* buffer, std::size_t typeSize, unsigned int count);
NzFile& operator=(const NzString& filePath);
NzFile& operator=(NzFile&& file);
NzFile& operator=(NzFile&& file) noexcept;
static NzString AbsolutePath(const NzString& filePath);
static bool Copy(const NzString& sourcePath, const NzString& targetPath);

View File

@@ -17,7 +17,7 @@ class NAZARA_API NzHashDigest
NzHashDigest();
NzHashDigest(const NzString& hashName, const nzUInt8* digest, unsigned int length);
NzHashDigest(const NzHashDigest& rhs);
NzHashDigest(NzHashDigest&& rhs);
NzHashDigest(NzHashDigest&& rhs) noexcept;
~NzHashDigest();
bool IsValid() const;
@@ -31,7 +31,7 @@ class NAZARA_API NzHashDigest
nzUInt8 operator[](unsigned short pos) const;
NzHashDigest& operator=(const NzHashDigest& rhs);
NzHashDigest& operator=(NzHashDigest&& rhs);
NzHashDigest& operator=(NzHashDigest&& rhs) noexcept;
bool operator==(const NzHashDigest& rhs) const;
bool operator!=(const NzHashDigest& rhs) const;

View File

@@ -0,0 +1,26 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_INITIALIZER_HPP
#define NAZARA_INITIALIZER_HPP
#include <Nazara/Prerequesites.hpp>
template<typename T>
class NzInitializer
{
public:
template<typename... Args> NzInitializer(Args... args);
~NzInitializer();
bool IsInitialized() const;
operator bool() const;
};
#include <Nazara/Core/Initializer.inl>
#endif // NAZARA_INITIALIZER_HPP

View File

@@ -0,0 +1,35 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp
// http://www.easyrgb.com/index.php?X=MATH
#include <Nazara/Core/Initializer.hpp>
#include <Nazara/Core/Debug.hpp>
template<typename T>
template<typename... Args>
NzInitializer<T>::NzInitializer(Args... args)
{
T::Initialize(args...);
}
template<typename T>
NzInitializer<T>::~NzInitializer()
{
T::Uninitialize();
}
template<typename T>
bool NzInitializer<T>::IsInitialized() const
{
return T::IsInitialized();
}
template<typename T>
NzInitializer<T>::operator bool() const
{
return T::IsInitialized();
}
#include <Nazara/Core/DebugOff.hpp>

View File

@@ -12,7 +12,7 @@
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/String.hpp>
#if NAZARA_THREADSAFETY_LOG
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_LOG
#include <Nazara/Core/ThreadSafety.hpp>
#else
#include <Nazara/Core/ThreadSafetyOff.hpp>

View File

@@ -11,11 +11,11 @@
#include <Nazara/Core/NonCopyable.hpp>
class NzMutexImpl;
class NzThreadCondition;
class NzConditionVariable;
class NAZARA_API NzMutex : NzNonCopyable
{
friend class NzThreadCondition;
friend class NzConditionVariable;
public:
NzMutex();

View File

@@ -0,0 +1,30 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_RESOURCE_HPP
#define NAZARA_RESOURCE_HPP
#include <Nazara/Prerequesites.hpp>
class NAZARA_API NzResource
{
public:
NzResource(bool persistent = true);
NzResource(const NzResource& resource);
virtual ~NzResource();
void AddResourceReference() const;
bool IsPersistent() const;
void RemoveResourceReference() const;
void SetPersistent(bool persistent = true);
private:
// Je fais précéder le nom par 'resource' pour éviter les éventuels conflits de noms
mutable bool m_resourcePersistent;
mutable unsigned int m_resourceReferenceCount;
};
#endif // NAZARA_RESOURCE_HPP

View File

@@ -13,7 +13,7 @@
#include <string>
#include <vector>
#if NAZARA_THREADSAFETY_STRING
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_STRING
#include <Nazara/Core/ThreadSafety.hpp>
#else
#include <Nazara/Core/ThreadSafetyOff.hpp>
@@ -41,7 +41,7 @@ class NAZARA_API NzString : public NzHashable
NzString(const char* string);
NzString(const std::string& string);
NzString(const NzString& string);
NzString(NzString&& string);
NzString(NzString&& string) noexcept;
NzString(SharedString* sharedString);
~NzString();
@@ -112,8 +112,8 @@ class NAZARA_API NzString : public NzHashable
unsigned int Replace(const char* oldString, const char* replaceString, int start = 0, nzUInt32 flags = None);
unsigned int Replace(const NzString& oldString, const NzString& replaceString, int start = 0, nzUInt32 flags = None);
unsigned int ReplaceAny(const char* oldCharacters, char replaceCharacter, int start = 0, nzUInt32 flags = None);
unsigned int ReplaceAny(const char* oldCharacters, const char* replaceString, int start = 0, nzUInt32 flags = None);
unsigned int ReplaceAny(const NzString& oldCharacters, const NzString& replaceString, int start = 0, nzUInt32 flags = None);
//unsigned int ReplaceAny(const char* oldCharacters, const char* replaceString, int start = 0, nzUInt32 flags = None);
//unsigned int ReplaceAny(const NzString& oldCharacters, const NzString& replaceString, int start = 0, nzUInt32 flags = None);
void Reserve(unsigned int bufferSize);
@@ -184,7 +184,7 @@ class NAZARA_API NzString : public NzHashable
NzString& operator=(const char* string);
NzString& operator=(const std::string& string);
NzString& operator=(const NzString& string);
NzString& operator=(NzString&& string);
NzString& operator=(NzString&& string) noexcept;
NzString operator+(char character) const;
NzString operator+(const char* string) const;
@@ -282,10 +282,7 @@ class NAZARA_API NzString : public NzHashable
struct NAZARA_API SharedString
{
SharedString() :
refCount(1)
{
}
SharedString() = default;
SharedString(unsigned short referenceCount, unsigned int bufferSize, unsigned int stringSize, char* str) :
capacity(bufferSize),
@@ -299,7 +296,7 @@ class NAZARA_API NzString : public NzHashable
unsigned int size;
char* string;
unsigned short refCount;
unsigned short refCount = 1;
NazaraMutex(mutex)
};

View File

@@ -12,7 +12,7 @@
#include <string>
#include <vector>
#if NAZARA_THREADSAFETY_STRINGSTREAM
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_STRINGSTREAM
#include <Nazara/Core/ThreadSafety.hpp>
#else
#include <Nazara/Core/ThreadSafetyOff.hpp>

View File

@@ -26,7 +26,7 @@ class NAZARA_API NzThread : NzNonCopyable
friend class NzThreadImpl;
public:
Id() : m_handle(nullptr) {}
Id() = default;
Id(Id&& rhs) = default;
~Id();
@@ -38,7 +38,7 @@ class NAZARA_API NzThread : NzNonCopyable
Id(void* handle) : m_handle(handle) {}
Id(const NzThreadImpl* thread);
void* m_handle;
void* m_handle = nullptr;
};
template<typename F> NzThread(F function);