Added Meshes and Animations (And many more)

Added NzTexture::IsMipmappingSupported
Color::(FromTo)HSV now takes hue and saturation in degrees
Fixed Context::EnsureContext
Fixed COW thread-safety (String, Image, Matrix4)
Fixed Quatenion<T>::operator*(const Vector3<T>&)
Fixed ResourceLoader
Fixed String::Resize with a size of 0
Fixed Texture mipmapping crash
Fixed per-class thread-safety
IndexBuffer and VertexBuffer are now resources
It is now possible to use more than 8 texcoords per shader
Moved all enumerations into separate files (Core/Enums.hpp,
Utility/Enums.hpp, ..)
Removed NzContextParameters::defaultWindow
VertexDeclaration has been rewritten (New interface/COW)
This commit is contained in:
Lynix
2012-07-13 15:22:14 +02:00
parent 5f95f0b677
commit 06eda4eba9
75 changed files with 3385 additions and 861 deletions

View File

@@ -8,10 +8,14 @@
#define NAZARA_BYTEARRAY_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Conig.hpp>
#include <Nazara/Core/Hashable.hpp>
#define NAZARA_CLASS_BYTEARRAY
#if NAZARA_THREADSAFETY_BYTEARRAY
#include <Nazara/Core/ThreadSafety.hpp>
#else
#include <Nazara/Core/ThreadSafetyOff.hpp>
#endif
class NzAbstractHash;
class NzHashDigest;
@@ -122,6 +126,4 @@ namespace std
NAZARA_API void swap(NzByteArray& lhs, NzByteArray& rhs);
}
#undef NAZARA_CLASS_BYTEARRAY
#endif // NAZARA_BYTEARRAY_HPP

View File

@@ -9,8 +9,11 @@
#include <Nazara/Prerequesites.hpp>
#define NAZARA_CLASS_CLOCK
#if NAZARA_THREADSAFETY_CLOCK
#include <Nazara/Core/ThreadSafety.hpp>
#else
#include <Nazara/Core/ThreadSafetyOff.hpp>
#endif
class NAZARA_API NzClock
{
@@ -40,6 +43,4 @@ typedef nzUInt64 (*NzClockFunction)();
extern NAZARA_API NzClockFunction NzGetMicroseconds;
extern NAZARA_API NzClockFunction NzGetMilliseconds;
#undef NAZARA_CLASS_CLOCK
#endif // NAZARA_CLOCK_HPP

View File

@@ -35,13 +35,13 @@ class NzColor
static NzColor FromCMY(float cyan, float magenta, float yellow);
static NzColor FromCMYK(float cyan, float magenta, float yellow, float black);
static NzColor FromHSL(nzUInt8 hue, nzUInt8 saturation, nzUInt8 lightness);
static NzColor FromHSV(nzUInt8 hue, nzUInt8 saturation, float value);
static NzColor FromHSV(float hue, float saturation, float value);
static NzColor FromXYZ(const NzVector3f& vec);
static NzColor FromXYZ(float x, float y, float z);
static void ToCMY(const NzColor& color, float* cyan, float* magenta, float* yellow);
static void ToCMYK(const NzColor& color, float* cyan, float* magenta, float* yellow, float* black);
static void ToHSL(const NzColor& color, nzUInt8* hue, nzUInt8* saturation, nzUInt8* lightness);
static void ToHSV(const NzColor& color, nzUInt8* hue, nzUInt8* saturation, float* value);
static void ToHSV(const NzColor& color, float* hue, float* saturation, float* value);
static void ToXYZ(const NzColor& color, NzVector3f* vec);
static void ToXYZ(const NzColor& color, float* x, float* y, float* z);

View File

@@ -2,6 +2,8 @@
// 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/StringStream.hpp>
#include <cmath>
#include <cstdlib>
@@ -130,14 +132,14 @@ inline NzColor NzColor::FromHSL(nzUInt8 hue, nzUInt8 saturation, nzUInt8 lightne
}
}
inline NzColor NzColor::FromHSV(nzUInt8 hue, nzUInt8 saturation, float value)
inline NzColor NzColor::FromHSV(float hue, float saturation, float value)
{
if (saturation == 0)
if (NzNumberEquals(saturation, 0.f))
return NzColor(static_cast<nzUInt8>(value * 255.f));
else
{
float h = hue/240.f * 6.f;
float s = saturation/240.f;
float h = hue/360.f * 6.f;
float s = saturation/360.f;
if (NzNumberEquals(h, 6.f))
h = 0; // hue must be < 1
@@ -200,17 +202,17 @@ inline NzColor NzColor::FromXYZ(float x, float y, float z)
double g = x * -0.9689 + y * 1.8758 + z * 0.0415;
double b = x * 0.0557 + y * -0.2040 + z * 1.0570;
if (r > 0.0031308)
if (r > 0.0031308f)
r = 1.055 * (std::pow(r, 1.0/2.4)) - 0.055;
else
r *= 12.92;
if (g > 0.0031308)
if (g > 0.0031308f)
g = 1.055 * (std::pow(g, 1.0/2.4)) - 0.055;
else
g *= 12.92;
if (b > 0.0031308)
if (b > 0.0031308f)
b = 1.055 * (std::pow(b, 1.0/2.4)) - 0.055;
else
b *= 12.92;
@@ -300,7 +302,7 @@ inline void NzColor::ToHSL(const NzColor& color, nzUInt8* hue, nzUInt8* saturati
}
}
inline void NzColor::ToHSV(const NzColor& color, nzUInt8* hue, nzUInt8* saturation, float* value)
inline void NzColor::ToHSV(const NzColor& color, float* hue, float* saturation, float* value)
{
float r = color.r / 255.f;
float g = color.g / 255.f;
@@ -322,7 +324,7 @@ inline void NzColor::ToHSV(const NzColor& color, nzUInt8* hue, nzUInt8* saturati
else
{
//Chromatic data...
*saturation = deltaMax/max*240.f;
*saturation = deltaMax/max*360.f;
float deltaR = ((max - r)/6.f + deltaMax/2.f)/deltaMax;
float deltaG = ((max - g)/6.f + deltaMax/2.f)/deltaMax;
@@ -342,7 +344,7 @@ inline void NzColor::ToHSV(const NzColor& color, nzUInt8* hue, nzUInt8* saturati
else if (h > 1.f)
h -= 1.f;
*hue = h*240.f;
*hue = h*360.f;
}
}

View File

@@ -19,8 +19,11 @@
#define NAZARA_DIRECTORY_SEPARATOR '/'
#endif
#define NAZARA_CLASS_DIRECTORY
#if NAZARA_THREADSAFETY_DIRECTORY
#include <Nazara/Core/ThreadSafety.hpp>
#else
#include <Nazara/Core/ThreadSafetyOff.hpp>
#endif
class NzDirectoryImpl;
@@ -59,6 +62,4 @@ class NAZARA_API NzDirectory
NzDirectoryImpl* m_impl;
};
#undef NAZARA_CLASS_DIRECTORY
#endif // NAZARA_DIRECTORY_HPP

View File

@@ -11,8 +11,11 @@
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/String.hpp>
#define NAZARA_CLASS_DYNLIB
#if NAZARA_THREADSAFETY_DYNLIB
#include <Nazara/Core/ThreadSafety.hpp>
#else
#include <Nazara/Core/ThreadSafetyOff.hpp>
#endif
class NzDynLibImpl;
typedef int (*NzDynLibFunc)(); // Type "générique" de pointeur sur fonction
@@ -40,6 +43,4 @@ class NzDynLib : NzNonCopyable
NzDynLibImpl* m_impl;
};
#undef NAZARA_CLASS_DYNLIB
#endif // NAZARA_DYNLIB_HPP

View File

@@ -8,6 +8,7 @@
#define NAZARA_ENDIANNESS_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Enums.hpp>
#if !defined(NAZARA_BIG_ENDIAN) && !defined(NAZARA_LITTLE_ENDIAN)
// Détection automatique selon les macros du compilateur
@@ -23,13 +24,6 @@
#error You cannot define both NAZARA_BIG_ENDIAN and NAZARA_LITTLE_ENDIAN
#endif
enum nzEndianness
{
nzEndianness_BigEndian,
nzEndianness_LittleEndian,
nzEndianness_Unknown
};
inline void NzByteSwap(void* buffer, unsigned int size);
inline nzEndianness NzGetPlatformEndianness();

View File

@@ -0,0 +1,25 @@
// 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_ENUMS_CORE_HPP
#define NAZARA_ENUMS_CORE_HPP
enum nzEndianness
{
nzEndianness_BigEndian,
nzEndianness_LittleEndian,
nzEndianness_Unknown
};
enum nzErrorType
{
nzErrorType_AssertFailed,
nzErrorType_Internal,
nzErrorType_Normal,
nzErrorType_Warning
};
#endif // NAZARA_ENUMS_CORE_HPP

View File

@@ -9,6 +9,7 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Config.hpp>
#include <Nazara/Core/Enums.hpp>
#include <Nazara/Core/String.hpp>
#if NAZARA_CORE_ENABLE_ASSERTS || defined(NAZARA_DEBUG)
@@ -21,14 +22,6 @@
#define NazaraInternalError(err) NzError(nzErrorType_Internal, err, __LINE__, __FILE__, NAZARA_FUNCTION)
#define NazaraWarning(err) NzError(nzErrorType_Warning, err, __LINE__, __FILE__, NAZARA_FUNCTION)
enum nzErrorType
{
nzErrorType_AssertFailed,
nzErrorType_Internal,
nzErrorType_Normal,
nzErrorType_Warning
};
NAZARA_API void NzError(nzErrorType type, const NzString& error, unsigned int line, const char* file, const char* function);
NAZARA_API unsigned int NzGetLastSystemErrorCode();
NAZARA_API NzString NzGetLastSystemError(unsigned int code = NzGetLastSystemErrorCode());

View File

@@ -16,8 +16,11 @@
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/String.hpp>
#define NAZARA_CLASS_FILE
#if NAZARA_THREADSAFETY_FILE
#include <Nazara/Core/ThreadSafety.hpp>
#else
#include <Nazara/Core/ThreadSafetyOff.hpp>
#endif
class NzFileImpl;
@@ -117,6 +120,4 @@ class NAZARA_API NzFile : public NzHashable, public NzInputStream, NzNonCopyable
unsigned int m_openMode;
};
#undef NAZARA_CLASS_FILE
#endif // NAZARA_FILE_HPP

View File

@@ -12,8 +12,11 @@
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/String.hpp>
#define NAZARA_CLASS_LOG
#if NAZARA_THREADSAFETY_LOG
#include <Nazara/Core/ThreadSafety.hpp>
#else
#include <Nazara/Core/ThreadSafetyOff.hpp>
#endif
#define NazaraLog NzLog::Instance()
#define NazaraNotice(txt) NazaraLog->Write(txt)
@@ -51,6 +54,4 @@ class NAZARA_API NzLog : NzNonCopyable
bool m_writeTime;
};
#undef NAZARA_CLASS_LOG
#endif // NAZARA_LOGGER_HPP

View File

@@ -13,8 +13,11 @@
#include <string>
#include <vector>
#define NAZARA_CLASS_STRING
#if NAZARA_THREADSAFETY_STRING
#include <Nazara/Core/ThreadSafety.hpp>
#else
#include <Nazara/Core/ThreadSafetyOff.hpp>
#endif
class NzAbstractHash;
class NzHashDigest;
@@ -154,7 +157,7 @@ class NAZARA_API NzString : public NzHashable
NzString Trimmed(nzUInt32 flags = None) const;
NzString Trimmed(char character, nzUInt32 flags = None) const;
// Méthodes compatibles STD
// Méthodes STD
char* begin();
const char* begin() const;
char* end();
@@ -170,7 +173,7 @@ class NAZARA_API NzString : public NzHashable
typedef char* iterator;
//typedef char* reverse_iterator;
typedef char value_type;
// Méthodes compatibles STD
// Méthodes STD
operator std::string() const;
@@ -318,6 +321,4 @@ namespace std
NAZARA_API void swap(NzString& lhs, NzString& rhs);
}
#undef NAZARA_CLASS_STRING
#endif // NAZARA_STRING_HPP

View File

@@ -12,8 +12,11 @@
#include <string>
#include <vector>
#define NAZARA_CLASS_STRINGSTREAM
#if NAZARA_THREADSAFETY_STRINGSTREAM
#include <Nazara/Core/ThreadSafety.hpp>
#else
#include <Nazara/Core/ThreadSafetyOff.hpp>
#endif
class NAZARA_API NzStringStream
{
@@ -51,6 +54,4 @@ class NAZARA_API NzStringStream
unsigned int m_bufferSize;
};
#undef NAZARA_CLASS_STRINGSTREAM
#endif // NAZARA_STRINGSTREAM_HPP

View File

@@ -4,7 +4,8 @@
// Pas de header guard
#include <Nazara/Core/Config.hpp>
#include <Nazara/Core/LockGuard.hpp>
#include <Nazara/Core/Mutex.hpp>
// Ces macros peuvent changer pour n'importe quel fichier qui l'utilise dans une même unité de compilation
#undef NazaraLock
@@ -14,30 +15,9 @@
#undef NazaraMutexUnlock
#undef NazaraNamedLock
#if NAZARA_CORE_THREADSAFE && (\
(NAZARA_THREADSAFETY_BYTEARRAY && defined(NAZARA_CLASS_BYTEARRAY)) || \
(NAZARA_THREADSAFETY_CLOCK && defined(NAZARA_CLASS_CLOCK)) || \
(NAZARA_THREADSAFETY_DIRECTORY && defined(NAZARA_CLASS_DIRECTORY)) || \
(NAZARA_THREADSAFETY_DYNLIB && defined(NAZARA_CLASS_DYNLIB)) || \
(NAZARA_THREADSAFETY_FILE && defined(NAZARA_CLASS_FILE)) || \
(NAZARA_THREADSAFETY_LOG && defined(NAZARA_CLASS_LOG)) || \
(NAZARA_THREADSAFETY_STRING && defined(NAZARA_CLASS_STRING)) || \
(NAZARA_THREADSAFETY_STRINGSTREAM && defined(NAZARA_CLASS_STRINGSTREAM)))
#include <Nazara/Core/LockGuard.hpp>
#include <Nazara/Core/Mutex.hpp>
#define NazaraLock(mutex) NzLockGuard lock_mutex(mutex);
#define NazaraMutex(name) NzMutex name;
#define NazaraMutexAttrib(name, attribute) attribute NzMutex name;
#define NazaraMutexLock(mutex) mutex.Lock();
#define NazaraMutexUnlock(mutex) mutex.Unlock();
#define NazaraNamedLock(mutex, name) NzLock lock_##name(mutex);
#else
#define NazaraLock(mutex)
#define NazaraMutex(name)
#define NazaraMutexAttrib(name, attribute)
#define NazaraMutexLock(mutex)
#define NazaraMutexUnlock(mutex)
#define NazaraNamedLock(mutex, name)
#endif
#define NazaraLock(mutex) NzLockGuard lock_mutex(mutex);
#define NazaraMutex(name) NzMutex name;
#define NazaraMutexAttrib(name, attribute) attribute NzMutex name;
#define NazaraMutexLock(mutex) mutex.Lock();
#define NazaraMutexUnlock(mutex) mutex.Unlock();
#define NazaraNamedLock(mutex, name) NzLockGuard lock_##name(mutex);

View File

@@ -0,0 +1,21 @@
// 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
// Pas de header guard
// Ces macros peuvent changer pour n'importe quel fichier qui l'utilise dans une même unité de compilation
#undef NazaraLock
#undef NazaraMutex
#undef NazaraMutexAttrib
#undef NazaraMutexLock
#undef NazaraMutexUnlock
#undef NazaraNamedLock
#define NazaraLock(mutex)
#define NazaraMutex(name)
#define NazaraMutexAttrib(name, attribute)
#define NazaraMutexLock(mutex)
#define NazaraMutexUnlock(mutex)
#define NazaraNamedLock(mutex, name)

View File

@@ -9,98 +9,99 @@
#include <Nazara/Prerequesites.hpp>
namespace NzUnicode
class NzUnicode
{
/*
Catégorie Unicode:
-Les valeurs de 0x01 à 0x80 indiquent la catégorie.
-Les valeurs de 0x100 à 0x10000 indiquent la sous-catégorie.
*/
enum Category : nzUInt16
{
// Catégorie non-reconnue par Nazara
Category_NoCategory = 0,
public:
/*
Catégorie Unicode:
-Les valeurs de 0x01 à 0x80 indiquent la catégorie.
-Les valeurs de 0x100 à 0x10000 indiquent la sous-catégorie.
*/
enum Category : nzUInt16
{
// Catégorie non-reconnue par Nazara
Category_NoCategory = 0,
// Lettres
Category_Letter = 0x01, // L
Category_Letter_Lowercase = Category_Letter | 0x0100, // Ll
Category_Letter_Modifier = Category_Letter | 0x0200, // Lm
Category_Letter_Other = Category_Letter | 0x0400, // Lo
Category_Letter_Titlecase = Category_Letter | 0x0800, // Lt
Category_Letter_Uppercase = Category_Letter | 0x1000, // Lu
// Lettres
Category_Letter = 0x01, // L
Category_Letter_Lowercase = Category_Letter | 0x0100, // Ll
Category_Letter_Modifier = Category_Letter | 0x0200, // Lm
Category_Letter_Other = Category_Letter | 0x0400, // Lo
Category_Letter_Titlecase = Category_Letter | 0x0800, // Lt
Category_Letter_Uppercase = Category_Letter | 0x1000, // Lu
// Marques
Category_Mark = 0x02, // M
Category_Mark_Enclosing = Category_Mark | 0x100, // Me
Category_Mark_NonSpacing = Category_Mark | 0x200, // Mn
Category_Mark_SpacingCombining = Category_Mark | 0x400, // Mc
// Marques
Category_Mark = 0x02, // M
Category_Mark_Enclosing = Category_Mark | 0x100, // Me
Category_Mark_NonSpacing = Category_Mark | 0x200, // Mn
Category_Mark_SpacingCombining = Category_Mark | 0x400, // Mc
// Nombres
Category_Number = 0x04, // N
Category_Number_DecimalDigit = Category_Number | 0x100, // Nd
Category_Number_Letter = Category_Number | 0x200, // Nl
Category_Number_Other = Category_Number | 0x400, // No
// Nombres
Category_Number = 0x04, // N
Category_Number_DecimalDigit = Category_Number | 0x100, // Nd
Category_Number_Letter = Category_Number | 0x200, // Nl
Category_Number_Other = Category_Number | 0x400, // No
// Autres
Category_Other = 0x08, // C
Category_Other_Control = Category_Other | 0x0100, // Cc
Category_Other_Format = Category_Other | 0x0200, // Cf
Category_Other_NotAssigned = Category_Other | 0x0400, // Cn
Category_Other_PrivateUse = Category_Other | 0x0800, // Co
Category_Other_Surrogate = Category_Other | 0x1000, // Cs
// Autres
Category_Other = 0x08, // C
Category_Other_Control = Category_Other | 0x0100, // Cc
Category_Other_Format = Category_Other | 0x0200, // Cf
Category_Other_NotAssigned = Category_Other | 0x0400, // Cn
Category_Other_PrivateUse = Category_Other | 0x0800, // Co
Category_Other_Surrogate = Category_Other | 0x1000, // Cs
// Ponctuations
Category_Punctuation = 0x10, // P
Category_Punctuation_Close = Category_Punctuation | 0x0100, // Pe
Category_Punctuation_Connector = Category_Punctuation | 0x0200, // Pc
Category_Punctuation_Dash = Category_Punctuation | 0x0400, // Pd
Category_Punctuation_FinalQuote = Category_Punctuation | 0x0800, // Pf
Category_Punctuation_InitialQuote = Category_Punctuation | 0x1000, // Pi
Category_Punctuation_Open = Category_Punctuation | 0x2000, // Ps
Category_Punctuation_Other = Category_Punctuation | 0x4000, // Po
// Ponctuations
Category_Punctuation = 0x10, // P
Category_Punctuation_Close = Category_Punctuation | 0x0100, // Pe
Category_Punctuation_Connector = Category_Punctuation | 0x0200, // Pc
Category_Punctuation_Dash = Category_Punctuation | 0x0400, // Pd
Category_Punctuation_FinalQuote = Category_Punctuation | 0x0800, // Pf
Category_Punctuation_InitialQuote = Category_Punctuation | 0x1000, // Pi
Category_Punctuation_Open = Category_Punctuation | 0x2000, // Ps
Category_Punctuation_Other = Category_Punctuation | 0x4000, // Po
// Espacements
Category_Separator = 0x20, // Z
Category_Separator_Line = Category_Separator | 0x0100, // Zl
Category_Separator_Paragraph = Category_Separator | 0x0200, // Zp
Category_Separator_Space = Category_Separator | 0x0400, // Zs
// Espacements
Category_Separator = 0x20, // Z
Category_Separator_Line = Category_Separator | 0x0100, // Zl
Category_Separator_Paragraph = Category_Separator | 0x0200, // Zp
Category_Separator_Space = Category_Separator | 0x0400, // Zs
// Symboles
Category_Symbol = 0x40, // S
Category_Symbol_Currency = Category_Symbol | 0x0100, // Sc
Category_Symbol_Math = Category_Symbol | 0x0200, // Sm
Category_Symbol_Modifier = Category_Symbol | 0x0400, // Sk
Category_Symbol_Other = Category_Symbol | 0x0800 // So
};
// Symboles
Category_Symbol = 0x40, // S
Category_Symbol_Currency = Category_Symbol | 0x0100, // Sc
Category_Symbol_Math = Category_Symbol | 0x0200, // Sm
Category_Symbol_Modifier = Category_Symbol | 0x0400, // Sk
Category_Symbol_Other = Category_Symbol | 0x0800 // So
};
enum Direction : nzUInt8
{
Direction_Arabic_Letter, // AL
Direction_Arabic_Number, // AN
Direction_Boundary_Neutral, // BN
Direction_Common_Separator, // CS
Direction_European_Number, // EN
Direction_European_Separator, // ES
Direction_European_Terminator, // ET
Direction_Left_To_Right, // L
Direction_Left_To_Right_Embedding, // LRE
Direction_Left_To_Right_Override, // LRO
Direction_Nonspacing_Mark, // NSM
Direction_Other_Neutral, // ON
Direction_Paragraph_Separator, // B
Direction_Pop_Directional_Format, // PDF
Direction_Right_To_Left, // R
Direction_Right_To_Left_Embedding, // RLE
Direction_Right_To_Left_Override, // RLO
Direction_Segment_Separator, // S
Direction_White_Space // WS
};
enum Direction : nzUInt8
{
Direction_Arabic_Letter, // AL
Direction_Arabic_Number, // AN
Direction_Boundary_Neutral, // BN
Direction_Common_Separator, // CS
Direction_European_Number, // EN
Direction_European_Separator, // ES
Direction_European_Terminator, // ET
Direction_Left_To_Right, // L
Direction_Left_To_Right_Embedding, // LRE
Direction_Left_To_Right_Override, // LRO
Direction_Nonspacing_Mark, // NSM
Direction_Other_Neutral, // ON
Direction_Paragraph_Separator, // B
Direction_Pop_Directional_Format, // PDF
Direction_Right_To_Left, // R
Direction_Right_To_Left_Embedding, // RLE
Direction_Right_To_Left_Override, // RLO
Direction_Segment_Separator, // S
Direction_White_Space // WS
};
Category GetCategory(char32_t character);
Direction GetDirection(char32_t character);
char32_t GetLowercase(char32_t character);
char32_t GetTitlecase(char32_t character);
char32_t GetUppercase(char32_t character);
}
static Category GetCategory(char32_t character);
static Direction GetDirection(char32_t character);
static char32_t GetLowercase(char32_t character);
static char32_t GetTitlecase(char32_t character);
static char32_t GetUppercase(char32_t character);
};
#endif // NAZARA_UNICODE_HPP