Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
25
include/Nazara/Core/Enums.hpp
Normal file
25
include/Nazara/Core/Enums.hpp
Normal 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
|
||||
@@ -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());
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
@@ -46,7 +49,7 @@ class NAZARA_API NzString : public NzHashable
|
||||
NzString& Append(const char* string);
|
||||
NzString& Append(const NzString& string);
|
||||
|
||||
void Clear();
|
||||
void Clear(bool keepBuffer = false);
|
||||
|
||||
bool Contains(char character, int start = 0, nzUInt32 flags = None) const;
|
||||
bool Contains(const char* string, int start = 0, nzUInt32 flags = None) const;
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
21
include/Nazara/Core/ThreadSafetyOff.hpp
Normal file
21
include/Nazara/Core/ThreadSafetyOff.hpp
Normal 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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -40,7 +40,7 @@ template<typename T> bool NzNumberEquals(T a, T b);
|
||||
inline NzString NzNumberToString(long long number, nzUInt8 radix = 10);
|
||||
template<typename T> T NzRadians(T radians);
|
||||
template<typename T> T NzRadianToDegree(T radians);
|
||||
inline long long NzStringToNumber(NzString str, nzUInt8 radix = 10);
|
||||
inline long long NzStringToNumber(NzString str, nzUInt8 radix = 10, bool* ok = nullptr);
|
||||
|
||||
#include <Nazara/Math/Basic.inl>
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ NzString NzNumberToString(long long number, nzUInt8 radix)
|
||||
if (number == 0)
|
||||
return '0';
|
||||
|
||||
static const char* symbols("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
static const char* symbols = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
bool negative;
|
||||
if (number < 0)
|
||||
@@ -238,12 +238,16 @@ T NzRadianToDegree(T radians)
|
||||
return radians * (180.0/M_PI);
|
||||
}
|
||||
|
||||
long long NzStringToNumber(NzString str, nzUInt8 radix)
|
||||
long long NzStringToNumber(NzString str, nzUInt8 radix, bool* ok)
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (radix < 2 || radix > 36)
|
||||
{
|
||||
NazaraError("Radix must be between 2 and 36");
|
||||
|
||||
if (ok)
|
||||
*ok = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -269,11 +273,18 @@ long long NzStringToNumber(NzString str, nzUInt8 radix)
|
||||
else
|
||||
{
|
||||
NazaraError("str is not a valid number");
|
||||
|
||||
if (ok)
|
||||
*ok = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
while (*++digit);
|
||||
|
||||
if (ok)
|
||||
*ok = true;
|
||||
|
||||
return (negative) ? -static_cast<long long>(total) : total;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
// Définit le radian comme l'unité utilisée pour les angles
|
||||
#define NAZARA_MATH_ANGLE_RADIAN 0
|
||||
|
||||
// Définit la disposition des matrices en colonnes
|
||||
// Définit la disposition des matrices en colonnes (Façon OpenGL)
|
||||
#define NAZARA_MATH_MATRIX_COLUMN_MAJOR 1
|
||||
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
|
||||
@@ -9,8 +9,11 @@
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#define NAZARA_CLASS_MATRIX4
|
||||
#include <Nazara/Math/ThreadSafety.hpp>
|
||||
#if NAZARA_THREADSAFETY_MATRIX4
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#else
|
||||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
template<typename T> class NzEulerAngles;
|
||||
template<typename T> class NzQuaternion;
|
||||
@@ -26,7 +29,7 @@ template<typename T> class NzMatrix4
|
||||
T r21, T r22, T r23, T r24,
|
||||
T r31, T r32, T r33, T r34,
|
||||
T r41, T r42, T r43, T r44);
|
||||
NzMatrix4(T matrix[16]);
|
||||
NzMatrix4(const T matrix[16]);
|
||||
//NzMatrix4(const NzMatrix3<T>& matrix);
|
||||
template<typename U> explicit NzMatrix4(const NzMatrix4<U>& matrix);
|
||||
NzMatrix4(const NzMatrix4& matrix);
|
||||
@@ -47,7 +50,7 @@ template<typename T> class NzMatrix4
|
||||
T r21, T r22, T r23, T r24,
|
||||
T r31, T r32, T r33, T r34,
|
||||
T r41, T r42, T r43, T r44);
|
||||
void Set(T matrix[16]);
|
||||
void Set(const T matrix[16]);
|
||||
//NzMatrix4(const NzMatrix3<T>& matrix);
|
||||
void Set(const NzMatrix4& matrix);
|
||||
void Set(NzMatrix4&& matrix);
|
||||
@@ -96,10 +99,10 @@ template<typename T> class NzMatrix4
|
||||
|
||||
struct SharedMatrix
|
||||
{
|
||||
T m11, m12, m13, m14;
|
||||
T m21, m22, m23, m24;
|
||||
T m31, m32, m33, m34;
|
||||
T m41, m42, m43, m44;
|
||||
T m11, m12, m13, m14,
|
||||
m21, m22, m23, m24,
|
||||
m31, m32, m33, m34,
|
||||
m41, m42, m43, m44;
|
||||
|
||||
unsigned short refCount = 1;
|
||||
NazaraMutex(mutex)
|
||||
@@ -117,8 +120,6 @@ template<typename T> std::ostream& operator<<(std::ostream& out, const NzMatrix4
|
||||
typedef NzMatrix4<double> NzMatrix4d;
|
||||
typedef NzMatrix4<float> NzMatrix4f;
|
||||
|
||||
#undef NAZARA_CLASS_MATRIX4
|
||||
|
||||
#include <Nazara/Math/Matrix4.inl>
|
||||
|
||||
#endif // NAZARA_MATRIX4_HPP
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
|
||||
#define NAZARA_CLASS_MATRIX4
|
||||
#include <Nazara/Math/ThreadSafety.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<typename T>
|
||||
@@ -40,7 +37,7 @@ m_sharedMatrix(nullptr)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzMatrix4<T>::NzMatrix4(T matrix[16]) :
|
||||
NzMatrix4<T>::NzMatrix4(const T matrix[16]) :
|
||||
m_sharedMatrix(nullptr)
|
||||
{
|
||||
Set(matrix);
|
||||
@@ -243,12 +240,12 @@ void NzMatrix4<T>::Set(T r11, T r12, T r13, T r14,
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzMatrix4<T>::Set(T matrix[16])
|
||||
void NzMatrix4<T>::Set(const T matrix[16])
|
||||
{
|
||||
EnsureOwnership();
|
||||
|
||||
// Ici nous sommes certains de la continuité des éléments en mémoire
|
||||
std::memcpy(&m_sharedMatrix->m41, matrix, 16*sizeof(T));
|
||||
std::memcpy(&m_sharedMatrix->m11, matrix, 16*sizeof(T));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -309,6 +306,7 @@ void NzMatrix4<T>::SetOrtho(T left, T top, T width, T height, T zNear, T zFar)
|
||||
template<typename T>
|
||||
void NzMatrix4<T>::SetLookAt(const NzVector3<T>& eye, const NzVector3<T>& center, const NzVector3<T>& up)
|
||||
{
|
||||
// http://www.opengl.org/sdk/docs/man/xhtml/gluLookAt.xml
|
||||
NzVector3<T> f = center - eye;
|
||||
f.Normalize();
|
||||
|
||||
@@ -316,14 +314,19 @@ void NzMatrix4<T>::SetLookAt(const NzVector3<T>& eye, const NzVector3<T>& center
|
||||
u.Normalize();
|
||||
|
||||
NzVector3<T> s = f.CrossProduct(u);
|
||||
s.Normalize();
|
||||
|
||||
u = s.CrossProduct(f);
|
||||
|
||||
#if NAZARA_MATH_MATRIX_COLUMN_MAJOR
|
||||
Set(s.x, s.y, s.z, 0.0,
|
||||
u.x, u.y, u.z, 0.0,
|
||||
-f.x, -f.y, -f.z, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0);
|
||||
#else
|
||||
Set(s.x, u.x, -f.x, 0.0,
|
||||
s.y, u.y, -f.y, 0.0,
|
||||
s.z, u.z, -f.z, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
operator*=(Translate(-eye));
|
||||
}
|
||||
@@ -587,34 +590,22 @@ NzMatrix4<T> NzMatrix4<T>::operator*(const NzMatrix4& matrix) const
|
||||
}
|
||||
#endif
|
||||
|
||||
NzMatrix4 mat;
|
||||
for(int k = 0; k < 4; k++)
|
||||
{
|
||||
for(int j = 0; j < 4; j++)
|
||||
{
|
||||
for(int i = 0; i < 4; i++)
|
||||
mat(j, k) += (*this)(j, i) * matrix(i, k);
|
||||
}
|
||||
}
|
||||
|
||||
return mat;
|
||||
/*return NzMatrix4(m11 * matrix.m11 + m21 * matrix.m12 + m31 * matrix.m13 + m41 * matrix.m14,
|
||||
m12 * matrix.m11 + m22 * matrix.m12 + m32 * matrix.m13 + m42 * matrix.m14,
|
||||
m13 * matrix.m11 + m23 * matrix.m12 + m33 * matrix.m13 + m43 * matrix.m14,
|
||||
m14 * matrix.m11 + m24 * matrix.m12 + m34 * matrix.m13 + m44 * matrix.m14,
|
||||
m11 * matrix.m21 + m21 * matrix.m22 + m31 * matrix.m23 + m41 * matrix.m24,
|
||||
m12 * matrix.m21 + m22 * matrix.m22 + m32 * matrix.m23 + m42 * matrix.m24,
|
||||
m13 * matrix.m21 + m23 * matrix.m22 + m33 * matrix.m23 + m43 * matrix.m24,
|
||||
m14 * matrix.m21 + m24 * matrix.m22 + m34 * matrix.m23 + m44 * matrix.m24,
|
||||
m11 * matrix.m31 + m21 * matrix.m32 + m31 * matrix.m33 + m41 * matrix.m34,
|
||||
m12 * matrix.m31 + m22 * matrix.m32 + m32 * matrix.m33 + m42 * matrix.m34,
|
||||
m13 * matrix.m31 + m23 * matrix.m32 + m33 * matrix.m33 + m43 * matrix.m34,
|
||||
m14 * matrix.m31 + m24 * matrix.m32 + m34 * matrix.m33 + m44 * matrix.m34,
|
||||
m11 * matrix.m41 + m21 * matrix.m42 + m31 * matrix.m43 + m41 * matrix.m44,
|
||||
m12 * matrix.m41 + m22 * matrix.m42 + m32 * matrix.m43 + m42 * matrix.m44,
|
||||
m13 * matrix.m41 + m23 * matrix.m42 + m33 * matrix.m43 + m43 * matrix.m44,
|
||||
m14 * matrix.m41 + m24 * matrix.m42 + m34 * matrix.m43 + m44 * matrix.m44);*/
|
||||
|
||||
return NzMatrix4(m_sharedMatrix->m11 * matrix.m_sharedMatrix->m11 + m_sharedMatrix->m21 * matrix.m_sharedMatrix->m12 + m_sharedMatrix->m31 * matrix.m_sharedMatrix->m13 + m_sharedMatrix->m41 * matrix.m_sharedMatrix->m14,
|
||||
m_sharedMatrix->m12 * matrix.m_sharedMatrix->m11 + m_sharedMatrix->m22 * matrix.m_sharedMatrix->m12 + m_sharedMatrix->m32 * matrix.m_sharedMatrix->m13 + m_sharedMatrix->m42 * matrix.m_sharedMatrix->m14,
|
||||
m_sharedMatrix->m13 * matrix.m_sharedMatrix->m11 + m_sharedMatrix->m23 * matrix.m_sharedMatrix->m12 + m_sharedMatrix->m33 * matrix.m_sharedMatrix->m13 + m_sharedMatrix->m43 * matrix.m_sharedMatrix->m14,
|
||||
m_sharedMatrix->m14 * matrix.m_sharedMatrix->m11 + m_sharedMatrix->m24 * matrix.m_sharedMatrix->m12 + m_sharedMatrix->m34 * matrix.m_sharedMatrix->m13 + m_sharedMatrix->m44 * matrix.m_sharedMatrix->m14,
|
||||
m_sharedMatrix->m11 * matrix.m_sharedMatrix->m21 + m_sharedMatrix->m21 * matrix.m_sharedMatrix->m22 + m_sharedMatrix->m31 * matrix.m_sharedMatrix->m23 + m_sharedMatrix->m41 * matrix.m_sharedMatrix->m24,
|
||||
m_sharedMatrix->m12 * matrix.m_sharedMatrix->m21 + m_sharedMatrix->m22 * matrix.m_sharedMatrix->m22 + m_sharedMatrix->m32 * matrix.m_sharedMatrix->m23 + m_sharedMatrix->m42 * matrix.m_sharedMatrix->m24,
|
||||
m_sharedMatrix->m13 * matrix.m_sharedMatrix->m21 + m_sharedMatrix->m23 * matrix.m_sharedMatrix->m22 + m_sharedMatrix->m33 * matrix.m_sharedMatrix->m23 + m_sharedMatrix->m43 * matrix.m_sharedMatrix->m24,
|
||||
m_sharedMatrix->m14 * matrix.m_sharedMatrix->m21 + m_sharedMatrix->m24 * matrix.m_sharedMatrix->m22 + m_sharedMatrix->m34 * matrix.m_sharedMatrix->m23 + m_sharedMatrix->m44 * matrix.m_sharedMatrix->m24,
|
||||
m_sharedMatrix->m11 * matrix.m_sharedMatrix->m31 + m_sharedMatrix->m21 * matrix.m_sharedMatrix->m32 + m_sharedMatrix->m31 * matrix.m_sharedMatrix->m33 + m_sharedMatrix->m41 * matrix.m_sharedMatrix->m34,
|
||||
m_sharedMatrix->m12 * matrix.m_sharedMatrix->m31 + m_sharedMatrix->m22 * matrix.m_sharedMatrix->m32 + m_sharedMatrix->m32 * matrix.m_sharedMatrix->m33 + m_sharedMatrix->m42 * matrix.m_sharedMatrix->m34,
|
||||
m_sharedMatrix->m13 * matrix.m_sharedMatrix->m31 + m_sharedMatrix->m23 * matrix.m_sharedMatrix->m32 + m_sharedMatrix->m33 * matrix.m_sharedMatrix->m33 + m_sharedMatrix->m43 * matrix.m_sharedMatrix->m34,
|
||||
m_sharedMatrix->m14 * matrix.m_sharedMatrix->m31 + m_sharedMatrix->m24 * matrix.m_sharedMatrix->m32 + m_sharedMatrix->m34 * matrix.m_sharedMatrix->m33 + m_sharedMatrix->m44 * matrix.m_sharedMatrix->m34,
|
||||
m_sharedMatrix->m11 * matrix.m_sharedMatrix->m41 + m_sharedMatrix->m21 * matrix.m_sharedMatrix->m42 + m_sharedMatrix->m31 * matrix.m_sharedMatrix->m43 + m_sharedMatrix->m41 * matrix.m_sharedMatrix->m44,
|
||||
m_sharedMatrix->m12 * matrix.m_sharedMatrix->m41 + m_sharedMatrix->m22 * matrix.m_sharedMatrix->m42 + m_sharedMatrix->m32 * matrix.m_sharedMatrix->m43 + m_sharedMatrix->m42 * matrix.m_sharedMatrix->m44,
|
||||
m_sharedMatrix->m13 * matrix.m_sharedMatrix->m41 + m_sharedMatrix->m23 * matrix.m_sharedMatrix->m42 + m_sharedMatrix->m33 * matrix.m_sharedMatrix->m43 + m_sharedMatrix->m43 * matrix.m_sharedMatrix->m44,
|
||||
m_sharedMatrix->m14 * matrix.m_sharedMatrix->m41 + m_sharedMatrix->m24 * matrix.m_sharedMatrix->m42 + m_sharedMatrix->m34 * matrix.m_sharedMatrix->m43 + m_sharedMatrix->m44 * matrix.m_sharedMatrix->m44);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -806,10 +797,10 @@ void NzMatrix4<T>::ReleaseMatrix()
|
||||
return;
|
||||
|
||||
NazaraMutexLock(m_sharedMatrix->mutex);
|
||||
m_sharedMatrix->refCount--;
|
||||
bool freeSharedMatrix = (--m_sharedMatrix->refCount == 0);
|
||||
NazaraMutexUnlock(m_sharedMatrix->mutex);
|
||||
|
||||
if (m_sharedMatrix->refCount == 0)
|
||||
if (freeSharedMatrix)
|
||||
delete m_sharedMatrix;
|
||||
|
||||
m_sharedMatrix = nullptr;
|
||||
|
||||
@@ -273,7 +273,7 @@ template<typename T>
|
||||
NzVector3<T> NzQuaternion<T>::operator*(const NzVector3<T>& vec) const
|
||||
{
|
||||
NzVector3<T> normal(vec);
|
||||
normal.Normalise();
|
||||
normal.Normalize();
|
||||
|
||||
NzQuaternion qvec(0.0, normal.x, normal.y, normal.z);
|
||||
NzQuaternion result = operator*(qvec * GetConjugate());
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
// 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
|
||||
|
||||
#include <Nazara/Math/Config.hpp>
|
||||
|
||||
// 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
|
||||
|
||||
#if NAZARA_MATH_THREADSAFE && (\
|
||||
(NAZARA_THREADSAFETY_MATRIX3 && (defined(NAZARA_MATRIX3) || defined(NAZARA_MATRIX3_INL))) || \
|
||||
(NAZARA_THREADSAFETY_MATRIX4 && (defined(NAZARA_MATRIX4) || defined(NAZARA_MATRIX4_INL))))
|
||||
|
||||
#include <Nazara/Core/Lock.hpp>
|
||||
#include <Nazara/Core/Mutex.hpp>
|
||||
|
||||
#define NazaraLock(mutex) NzLock 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
|
||||
@@ -17,7 +17,7 @@ template<typename T> class NzVector3
|
||||
NzVector3(T X, T Y, T Z);
|
||||
explicit NzVector3(T scale);
|
||||
NzVector3(T vec[3]);
|
||||
NzVector3(const NzVector2<T>& vec);
|
||||
NzVector3(const NzVector2<T>& vec, T Z = 0.0);
|
||||
template<typename U> explicit NzVector3(const NzVector3<U>& vec);
|
||||
NzVector3(const NzVector3& vec) = default;
|
||||
~NzVector3() = default;
|
||||
|
||||
@@ -39,10 +39,10 @@ z(vec[2])
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>::NzVector3(const NzVector2<T>& vec) :
|
||||
NzVector3<T>::NzVector3(const NzVector2<T>& vec, T Z) :
|
||||
x(vec.x),
|
||||
y(vec.y),
|
||||
z(0)
|
||||
z(Z)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
// Active une fenêtre de rendu (NzRenderWindow) lors de sa création
|
||||
#define NAZARA_RENDERER_ACTIVATE_RENDERWINDOW_ON_CREATION 1
|
||||
|
||||
// Force les buffers à posséder un stride multiple de 32 bytes (Gain de performances sur certaines cartes)
|
||||
// Force les buffers à posséder un stride multiple de 32 bytes (Gain de performances sur certaines cartes/plus de consommation mémoire)
|
||||
#define NAZARA_RENDERER_FORCE_DECLARATION_STRIDE_MULTIPLE_OF_32 0
|
||||
|
||||
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
|
||||
|
||||
@@ -23,7 +23,7 @@ struct NAZARA_API NzContextParameters
|
||||
minorVersion(defaultMinorVersion),
|
||||
stencilBits(parameters.stencilBits),
|
||||
shareContext(defaultShareContext),
|
||||
window(defaultWindow),
|
||||
window(0),
|
||||
compatibilityProfile(defaultCompatibilityProfile),
|
||||
debugMode(defaultDebugMode),
|
||||
doubleBuffered(defaultDoubleBuffered),
|
||||
@@ -47,7 +47,6 @@ struct NAZARA_API NzContextParameters
|
||||
static nzUInt8 defaultMajorVersion;
|
||||
static nzUInt8 defaultMinorVersion;
|
||||
static const NzContext* defaultShareContext;
|
||||
static NzWindowHandle defaultWindow;
|
||||
static bool defaultCompatibilityProfile;
|
||||
static bool defaultDebugMode;
|
||||
static bool defaultDoubleBuffered;
|
||||
|
||||
132
include/Nazara/Renderer/Enums.hpp
Normal file
132
include/Nazara/Renderer/Enums.hpp
Normal file
@@ -0,0 +1,132 @@
|
||||
// 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_RENDERER_HPP
|
||||
#define NAZARA_ENUMS_RENDERER_HPP
|
||||
|
||||
enum nzBlendFunc
|
||||
{
|
||||
nzBlendFunc_DestAlpha,
|
||||
nzBlendFunc_DestColor,
|
||||
nzBlendFunc_SrcAlpha,
|
||||
nzBlendFunc_SrcColor,
|
||||
nzBlendFunc_InvDestAlpha,
|
||||
nzBlendFunc_InvDestColor,
|
||||
nzBlendFunc_InvSrcAlpha,
|
||||
nzBlendFunc_InvSrcColor,
|
||||
nzBlendFunc_One,
|
||||
nzBlendFunc_Zero
|
||||
};
|
||||
|
||||
enum nzFaceCulling
|
||||
{
|
||||
nzFaceCulling_Back,
|
||||
nzFaceCulling_Front,
|
||||
nzFaceCulling_FrontAndBack
|
||||
};
|
||||
|
||||
enum nzFaceFilling
|
||||
{
|
||||
nzFaceFilling_Point,
|
||||
nzFaceFilling_Line,
|
||||
nzFaceFilling_Fill
|
||||
};
|
||||
|
||||
enum nzPixelBufferType
|
||||
{
|
||||
nzPixelBufferType_Pack,
|
||||
nzPixelBufferType_Unpack
|
||||
};
|
||||
|
||||
enum nzRendererCap
|
||||
{
|
||||
nzRendererCap_AnisotropicFilter,
|
||||
nzRendererCap_FP64,
|
||||
nzRendererCap_HardwareBuffer,
|
||||
nzRendererCap_MultipleRenderTargets,
|
||||
nzRendererCap_OcclusionQuery,
|
||||
nzRendererCap_PixelBufferObject,
|
||||
nzRendererCap_Texture3D,
|
||||
nzRendererCap_TextureCubemap,
|
||||
nzRendererCap_TextureMulti,
|
||||
nzRendererCap_TextureNPOT,
|
||||
|
||||
nzRendererCap_Max = nzRendererCap_TextureNPOT
|
||||
};
|
||||
|
||||
enum nzRendererClear
|
||||
{
|
||||
nzRendererClear_Color = 0x01,
|
||||
nzRendererClear_Depth = 0x02,
|
||||
nzRendererClear_Stencil = 0x04
|
||||
};
|
||||
|
||||
enum nzRendererComparison
|
||||
{
|
||||
nzRendererComparison_Always,
|
||||
nzRendererComparison_Equal,
|
||||
nzRendererComparison_Greater,
|
||||
nzRendererComparison_GreaterOrEqual,
|
||||
nzRendererComparison_Less,
|
||||
nzRendererComparison_LessOrEqual,
|
||||
nzRendererComparison_Never
|
||||
};
|
||||
|
||||
enum nzRendererParameter
|
||||
{
|
||||
nzRendererParameter_Blend,
|
||||
nzRendererParameter_ColorWrite,
|
||||
nzRendererParameter_DepthTest,
|
||||
nzRendererParameter_DepthWrite,
|
||||
nzRendererParameter_FaceCulling,
|
||||
nzRendererParameter_Stencil
|
||||
};
|
||||
|
||||
enum nzShaderLanguage
|
||||
{
|
||||
nzShaderLanguage_Unknown,
|
||||
|
||||
nzShaderLanguage_Cg,
|
||||
nzShaderLanguage_GLSL
|
||||
};
|
||||
|
||||
enum nzShaderType
|
||||
{
|
||||
nzShaderType_Fragment,
|
||||
nzShaderType_Geometry,
|
||||
nzShaderType_Vertex,
|
||||
|
||||
nzShaderType_Max = nzShaderType_Vertex
|
||||
};
|
||||
|
||||
enum nzStencilOperation
|
||||
{
|
||||
nzStencilOperation_Decrement,
|
||||
nzStencilOperation_DecrementToSaturation,
|
||||
nzStencilOperation_Increment,
|
||||
nzStencilOperation_IncrementToSaturation,
|
||||
nzStencilOperation_Invert,
|
||||
nzStencilOperation_Keep,
|
||||
nzStencilOperation_Replace,
|
||||
nzStencilOperation_Zero
|
||||
};
|
||||
|
||||
enum nzTextureFilter
|
||||
{
|
||||
nzTextureFilter_Bilinear,
|
||||
nzTextureFilter_Nearest,
|
||||
nzTextureFilter_Trilinear,
|
||||
nzTextureFilter_Unknown
|
||||
};
|
||||
|
||||
enum nzTextureWrap
|
||||
{
|
||||
nzTextureWrap_Clamp,
|
||||
nzTextureWrap_Repeat,
|
||||
nzTextureWrap_Unknown
|
||||
};
|
||||
|
||||
#endif // NAZARA_ENUMS_RENDERER_HPP
|
||||
@@ -37,6 +37,7 @@ class NAZARA_API NzOpenGL
|
||||
DebugOutput,
|
||||
FP64,
|
||||
FrameBufferObject,
|
||||
PixelBufferObject,
|
||||
SeparateShaderObjects,
|
||||
Texture3D,
|
||||
TextureCompression_s3tc,
|
||||
|
||||
@@ -24,14 +24,14 @@ class NAZARA_API NzRenderWindow : public NzRenderTarget, public NzWindow
|
||||
{
|
||||
public:
|
||||
NzRenderWindow();
|
||||
NzRenderWindow(NzVideoMode mode, const NzString& title, nzUInt32 style = NzWindow::Default, const NzContextParameters& parameters = NzContextParameters());
|
||||
NzRenderWindow(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default, const NzContextParameters& parameters = NzContextParameters());
|
||||
NzRenderWindow(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters());
|
||||
virtual ~NzRenderWindow();
|
||||
|
||||
bool CopyToImage(NzImage* image); ///TODO: Const
|
||||
bool CopyToTexture(NzTexture* texture); ///TODO: Const
|
||||
|
||||
bool Create(NzVideoMode mode, const NzString& title, nzUInt32 style = NzWindow::Default, const NzContextParameters& parameters = NzContextParameters());
|
||||
bool Create(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default, const NzContextParameters& parameters = NzContextParameters());
|
||||
bool Create(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters());
|
||||
|
||||
void Display();
|
||||
|
||||
@@ -9,105 +9,13 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <map>
|
||||
#include <tuple>
|
||||
|
||||
#define NazaraRenderer NzRenderer::Instance()
|
||||
|
||||
enum nzBlendFunc
|
||||
{
|
||||
nzBlendFunc_DestAlpha,
|
||||
nzBlendFunc_DestColor,
|
||||
nzBlendFunc_SrcAlpha,
|
||||
nzBlendFunc_SrcColor,
|
||||
nzBlendFunc_InvDestAlpha,
|
||||
nzBlendFunc_InvDestColor,
|
||||
nzBlendFunc_InvSrcAlpha,
|
||||
nzBlendFunc_InvSrcColor,
|
||||
nzBlendFunc_One,
|
||||
nzBlendFunc_Zero
|
||||
};
|
||||
|
||||
enum nzFaceCulling
|
||||
{
|
||||
nzFaceCulling_Back,
|
||||
nzFaceCulling_Front,
|
||||
nzFaceCulling_FrontAndBack
|
||||
};
|
||||
|
||||
enum nzFaceFilling
|
||||
{
|
||||
nzFaceFilling_Point,
|
||||
nzFaceFilling_Line,
|
||||
nzFaceFilling_Fill
|
||||
};
|
||||
|
||||
enum nzPrimitiveType
|
||||
{
|
||||
nzPrimitiveType_LineList,
|
||||
nzPrimitiveType_LineStrip,
|
||||
nzPrimitiveType_PointList,
|
||||
nzPrimitiveType_TriangleList,
|
||||
nzPrimitiveType_TriangleStrip,
|
||||
nzPrimitiveType_TriangleFan
|
||||
};
|
||||
|
||||
enum nzRendererCap
|
||||
{
|
||||
nzRendererCap_AnisotropicFilter,
|
||||
nzRendererCap_FP64,
|
||||
nzRendererCap_HardwareBuffer,
|
||||
nzRendererCap_MultipleRenderTargets,
|
||||
nzRendererCap_OcclusionQuery,
|
||||
nzRendererCap_SoftwareBuffer,
|
||||
nzRendererCap_Texture3D,
|
||||
nzRendererCap_TextureCubemap,
|
||||
nzRendererCap_TextureMulti,
|
||||
nzRendererCap_TextureNPOT,
|
||||
|
||||
nzRendererCap_Count
|
||||
};
|
||||
|
||||
enum nzRendererClear
|
||||
{
|
||||
nzRendererClear_Color = 0x01,
|
||||
nzRendererClear_Depth = 0x02,
|
||||
nzRendererClear_Stencil = 0x04
|
||||
};
|
||||
|
||||
enum nzRendererComparison
|
||||
{
|
||||
nzRendererComparison_Always,
|
||||
nzRendererComparison_Equal,
|
||||
nzRendererComparison_Greater,
|
||||
nzRendererComparison_GreaterOrEqual,
|
||||
nzRendererComparison_Less,
|
||||
nzRendererComparison_LessOrEqual,
|
||||
nzRendererComparison_Never
|
||||
};
|
||||
|
||||
enum nzRendererParameter
|
||||
{
|
||||
nzRendererParameter_Blend,
|
||||
nzRendererParameter_ColorWrite,
|
||||
nzRendererParameter_DepthTest,
|
||||
nzRendererParameter_DepthWrite,
|
||||
nzRendererParameter_FaceCulling,
|
||||
nzRendererParameter_Stencil
|
||||
};
|
||||
|
||||
enum nzStencilOperation
|
||||
{
|
||||
nzStencilOperation_Decrement,
|
||||
nzStencilOperation_DecrementToSaturation,
|
||||
nzStencilOperation_Increment,
|
||||
nzStencilOperation_IncrementToSaturation,
|
||||
nzStencilOperation_Invert,
|
||||
nzStencilOperation_Keep,
|
||||
nzStencilOperation_Replace,
|
||||
nzStencilOperation_Zero
|
||||
};
|
||||
|
||||
class NzColor;
|
||||
class NzContext;
|
||||
class NzIndexBuffer;
|
||||
@@ -183,7 +91,7 @@ class NAZARA_API NzRenderer
|
||||
const NzVertexBuffer* m_vertexBuffer;
|
||||
const NzVertexDeclaration* m_vertexDeclaration;
|
||||
bool m_vaoUpdated;
|
||||
bool m_capabilities[nzRendererCap_Count];
|
||||
bool m_capabilities[nzRendererCap_Max+1];
|
||||
bool m_stencilFuncUpdated;
|
||||
bool m_stencilOpUpdated;
|
||||
unsigned int m_maxAnisotropyLevel;
|
||||
|
||||
@@ -14,25 +14,9 @@
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Math/Vector4.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Utility/Resource.hpp>
|
||||
|
||||
enum nzShaderLanguage
|
||||
{
|
||||
nzShaderLanguage_Unknown,
|
||||
|
||||
nzShaderLanguage_Cg,
|
||||
nzShaderLanguage_GLSL
|
||||
};
|
||||
|
||||
enum nzShaderType
|
||||
{
|
||||
nzShaderType_Fragment,
|
||||
nzShaderType_Geometry,
|
||||
nzShaderType_Vertex,
|
||||
|
||||
nzShaderType_Count
|
||||
};
|
||||
|
||||
class NzRenderer;
|
||||
class NzShaderImpl;
|
||||
class NzTexture;
|
||||
|
||||
@@ -9,24 +9,10 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Utility/Image.hpp>
|
||||
#include <Nazara/Utility/PixelFormat.hpp>
|
||||
|
||||
enum nzTextureFilter
|
||||
{
|
||||
nzTextureFilter_Bilinear,
|
||||
nzTextureFilter_Nearest,
|
||||
nzTextureFilter_Trilinear,
|
||||
nzTextureFilter_Unknown
|
||||
};
|
||||
|
||||
enum nzTextureWrap
|
||||
{
|
||||
nzTextureWrap_Clamp,
|
||||
nzTextureWrap_Repeat,
|
||||
nzTextureWrap_Unknown
|
||||
};
|
||||
|
||||
class NzShader;
|
||||
struct NzTextureImpl;
|
||||
|
||||
@@ -92,6 +78,7 @@ class NAZARA_API NzTexture : public NzResource, NzNonCopyable
|
||||
|
||||
static unsigned int GetValidSize(unsigned int size);
|
||||
static bool IsFormatSupported(nzPixelFormat format);
|
||||
static bool IsMipmappingSupported();
|
||||
static bool IsTypeSupported(nzImageType type);
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
// 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
|
||||
|
||||
#ifndef NAZARA_VERTEXDECLARATION_HPP
|
||||
#define NAZARA_VERTEXDECLARATION_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <vector>
|
||||
|
||||
enum nzElementType
|
||||
{
|
||||
nzElementType_Color,
|
||||
nzElementType_Double1,
|
||||
nzElementType_Double2,
|
||||
nzElementType_Double3,
|
||||
nzElementType_Double4,
|
||||
nzElementType_Float1,
|
||||
nzElementType_Float2,
|
||||
nzElementType_Float3,
|
||||
nzElementType_Float4
|
||||
};
|
||||
|
||||
enum nzElementUsage
|
||||
{
|
||||
nzElementUsage_Diffuse,
|
||||
nzElementUsage_Normal,
|
||||
nzElementUsage_Position,
|
||||
nzElementUsage_Tangent,
|
||||
nzElementUsage_TexCoord
|
||||
};
|
||||
|
||||
struct NzVertexElement
|
||||
{
|
||||
NzVertexElement() : stream(0), usageIndex(0) {}
|
||||
|
||||
unsigned int offset;
|
||||
unsigned int stream;
|
||||
unsigned int usageIndex;
|
||||
nzElementType type;
|
||||
nzElementUsage usage;
|
||||
};
|
||||
|
||||
class NAZARA_API NzVertexDeclaration
|
||||
{
|
||||
public:
|
||||
struct Element
|
||||
{
|
||||
unsigned int offset;
|
||||
unsigned int usageIndex;
|
||||
nzElementType type;
|
||||
nzElementUsage usage;
|
||||
};
|
||||
|
||||
NzVertexDeclaration() = default;
|
||||
~NzVertexDeclaration() = default;
|
||||
|
||||
bool Create(const NzVertexElement* elements, unsigned int elementCount);
|
||||
|
||||
const Element* GetElement(unsigned int i, unsigned int stream = 0) const;
|
||||
unsigned int GetElementCount(unsigned int stream = 0) const;
|
||||
unsigned int GetStreamCount() const;
|
||||
unsigned int GetStride(unsigned int stream = 0) const;
|
||||
|
||||
private:
|
||||
struct Stream
|
||||
{
|
||||
std::vector<Element> elements;
|
||||
unsigned int stride;
|
||||
};
|
||||
|
||||
std::vector<Stream> m_streams;
|
||||
};
|
||||
|
||||
#endif // NAZARA_VERTEXDECLARATION_HPP
|
||||
81
include/Nazara/Utility/Animation.hpp
Normal file
81
include/Nazara/Utility/Animation.hpp
Normal file
@@ -0,0 +1,81 @@
|
||||
// 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_ANIMATION_HPP
|
||||
#define NAZARA_ANIMATION_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/Resource.hpp>
|
||||
#include <Nazara/Utility/ResourceLoader.hpp>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
struct NzAnimationParams
|
||||
{
|
||||
unsigned int endFrame = static_cast<unsigned int>(-1);
|
||||
unsigned int startFrame = 0;
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
|
||||
struct NzSequence
|
||||
{
|
||||
NzString name;
|
||||
unsigned int firstFrame;
|
||||
unsigned int lastFrame;
|
||||
unsigned int framePerSecond;
|
||||
};
|
||||
|
||||
class NzAnimation;
|
||||
|
||||
typedef NzResourceLoader<NzAnimation, NzAnimationParams> NzAnimationLoader;
|
||||
|
||||
struct NzAnimationImpl;
|
||||
|
||||
class NAZARA_API NzAnimation : public NzResource
|
||||
{
|
||||
friend class NzResourceLoader<NzAnimation, NzAnimationParams>;
|
||||
|
||||
public:
|
||||
NzAnimation() = default;
|
||||
~NzAnimation();
|
||||
|
||||
unsigned int AddSequence(const NzSequence& sequence);
|
||||
|
||||
bool Create(nzAnimationType type, unsigned int frameCount);
|
||||
void Destroy();
|
||||
|
||||
unsigned int GetFrameCount() const;
|
||||
NzSequence* GetSequence(const NzString& sequenceName);
|
||||
NzSequence* GetSequence(unsigned int index);
|
||||
const NzSequence* GetSequence(const NzString& sequenceName) const;
|
||||
const NzSequence* GetSequence(unsigned int index) const;
|
||||
unsigned int GetSequenceCount() const;
|
||||
nzAnimationType GetType() const;
|
||||
|
||||
bool HasSequence(const NzString& sequenceName) const;
|
||||
bool HasSequence(unsigned int index = 0) const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
bool LoadFromFile(const NzString& filePath, const NzAnimationParams& params = NzAnimationParams());
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const NzAnimationParams& params = NzAnimationParams());
|
||||
bool LoadFromStream(NzInputStream& stream, const NzAnimationParams& params = NzAnimationParams());
|
||||
|
||||
void RemoveSequence(const NzString& sequenceName);
|
||||
void RemoveSequence(unsigned int index);
|
||||
|
||||
private:
|
||||
NzAnimationImpl* m_impl = nullptr;
|
||||
|
||||
static std::list<NzAnimationLoader::MemoryLoader> s_memoryLoaders;
|
||||
static std::list<NzAnimationLoader::StreamLoader> s_streamLoaders;
|
||||
static std::multimap<NzString, NzAnimationLoader::LoadFileFunction> s_fileLoaders;
|
||||
};
|
||||
|
||||
#endif // NAZARA_ANIMATION_HPP
|
||||
@@ -9,57 +9,36 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/Resource.hpp>
|
||||
|
||||
enum nzBufferAccess
|
||||
{
|
||||
nzBufferAccess_DiscardAndWrite,
|
||||
nzBufferAccess_ReadOnly,
|
||||
nzBufferAccess_ReadWrite,
|
||||
nzBufferAccess_WriteOnly
|
||||
};
|
||||
|
||||
enum nzBufferStorage
|
||||
{
|
||||
nzBufferStorage_Hardware,
|
||||
nzBufferStorage_Software
|
||||
};
|
||||
|
||||
enum nzBufferType
|
||||
{
|
||||
nzBufferType_Index,
|
||||
nzBufferType_Vertex
|
||||
};
|
||||
|
||||
enum nzBufferUsage
|
||||
{
|
||||
nzBufferUsage_Dynamic,
|
||||
nzBufferUsage_Static
|
||||
};
|
||||
|
||||
class NzBufferImpl;
|
||||
class NzRenderer;
|
||||
class NzUtility;
|
||||
|
||||
class NAZARA_API NzBuffer : public NzResource, NzNonCopyable
|
||||
{
|
||||
friend class NzRenderer;
|
||||
friend class NzUtility;
|
||||
|
||||
public:
|
||||
typedef NzBufferImpl* (*BufferFunction)(NzBuffer* parent, nzBufferType type);
|
||||
|
||||
NzBuffer(nzBufferType type);
|
||||
NzBuffer(nzBufferType type, unsigned int length, nzUInt8 typeSize, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
NzBuffer(nzBufferType type, unsigned int length, nzUInt8 typeSize, nzBufferStorage storage = nzBufferStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
~NzBuffer();
|
||||
|
||||
bool CopyContent(NzBuffer& buffer);
|
||||
|
||||
bool Create(unsigned int length, nzUInt8 typeSize, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
bool Create(unsigned int length, nzUInt8 typeSize, nzBufferStorage storage = nzBufferStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
void Destroy();
|
||||
|
||||
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
||||
|
||||
void* GetBufferPtr();
|
||||
const void* GetBufferPtr() const;
|
||||
NzBufferImpl* GetImpl() const;
|
||||
unsigned int GetLength() const;
|
||||
void* GetPointer();
|
||||
const void* GetPointer() const;
|
||||
unsigned int GetSize() const;
|
||||
nzBufferStorage GetStorage() const;
|
||||
nzBufferType GetType() const;
|
||||
@@ -67,13 +46,21 @@ class NAZARA_API NzBuffer : public NzResource, NzNonCopyable
|
||||
nzBufferUsage GetUsage() const;
|
||||
|
||||
bool IsHardware() const;
|
||||
bool IsValid() const;
|
||||
|
||||
void* Map(nzBufferAccess access, unsigned int offset = 0, unsigned int length = 0);
|
||||
|
||||
bool SetStorage(nzBufferStorage storage);
|
||||
|
||||
bool Unmap();
|
||||
|
||||
static bool IsSupported(nzBufferStorage storage);
|
||||
static void SetBufferFunction(nzBufferStorage storage, BufferFunction func);
|
||||
|
||||
private:
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
nzBufferStorage m_storage;
|
||||
nzBufferType m_type;
|
||||
nzBufferUsage m_usage;
|
||||
@@ -81,6 +68,7 @@ class NAZARA_API NzBuffer : public NzResource, NzNonCopyable
|
||||
NzBufferImpl* m_impl;
|
||||
unsigned int m_length;
|
||||
|
||||
static BufferFunction s_bufferFunctions[nzBufferStorage_Max+1];
|
||||
};
|
||||
|
||||
#endif // NAZARA_BUFFER_HPP
|
||||
31
include/Nazara/Utility/BufferImpl.hpp
Normal file
31
include/Nazara/Utility/BufferImpl.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
// 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_BUFFERIMPL_HPP
|
||||
#define NAZARA_BUFFERIMPL_HPP
|
||||
|
||||
#include <Nazara/Utility/Buffer.hpp>
|
||||
|
||||
class NAZARA_API NzBufferImpl
|
||||
{
|
||||
public:
|
||||
NzBufferImpl() = default;
|
||||
virtual ~NzBufferImpl();
|
||||
|
||||
virtual bool Create(unsigned int size, nzBufferUsage usage = nzBufferUsage_Static) = 0;
|
||||
virtual void Destroy() = 0;
|
||||
|
||||
virtual bool Fill(const void* data, unsigned int offset, unsigned int size) = 0;
|
||||
|
||||
virtual void* GetPointer() = 0;
|
||||
|
||||
virtual bool IsHardware() const = 0;
|
||||
|
||||
virtual void* Map(nzBufferAccess access, unsigned int offset = 0, unsigned int size = 0) = 0;
|
||||
virtual bool Unmap() = 0;
|
||||
};
|
||||
|
||||
#endif // NAZARA_BUFFERIMPL_INCLUDED
|
||||
@@ -38,4 +38,12 @@
|
||||
// Fait tourner chaque fenêtre dans un thread séparé si le système le supporte
|
||||
#define NAZARA_UTILITY_THREADED_WINDOW 0 ///FIXME: Buggé depuis GCC 4.7
|
||||
|
||||
// Protège le module des accès concurrentiels
|
||||
#define NAZARA_UTILITY_THREADSAFE 1
|
||||
|
||||
#if NAZARA_UTILITY_THREADSAFE
|
||||
#define NAZARA_THREADSAFETY_IMAGE 1 // NzImage (COW)
|
||||
#define NAZARA_THREADSAFETY_VERTEXDECLARATION 1 // NzVertexDeclaration (COW)
|
||||
#endif
|
||||
|
||||
#endif // NAZARA_CONFIG_UTILITY_HPP
|
||||
|
||||
35
include/Nazara/Utility/Cursor.hpp
Normal file
35
include/Nazara/Utility/Cursor.hpp
Normal 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
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CURSOR_HPP
|
||||
#define NAZARA_CURSOR_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
|
||||
class NzCursorImpl;
|
||||
class NzImage;
|
||||
class NzWindowImpl;
|
||||
|
||||
class NAZARA_API NzCursor
|
||||
{
|
||||
friend class NzWindowImpl;
|
||||
|
||||
public:
|
||||
NzCursor();
|
||||
~NzCursor();
|
||||
|
||||
bool Create(const NzImage& cursor, int hotSpotX = 0, int hotSpotY = 0);
|
||||
bool Create(const NzImage& cursor, const NzVector2i& hotSpot);
|
||||
void Destroy();
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
private:
|
||||
NzCursorImpl* m_impl;
|
||||
};
|
||||
|
||||
#endif // NAZARA_CURSOR_HPP
|
||||
191
include/Nazara/Utility/Enums.hpp
Normal file
191
include/Nazara/Utility/Enums.hpp
Normal file
@@ -0,0 +1,191 @@
|
||||
// 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_UTILITY_HPP
|
||||
#define NAZARA_ENUMS_UTILITY_HPP
|
||||
|
||||
enum nzAnimationType
|
||||
{
|
||||
nzAnimationType_Keyframe,
|
||||
nzAnimationType_Skeletal,
|
||||
nzAnimationType_Static
|
||||
};
|
||||
|
||||
enum nzBufferAccess
|
||||
{
|
||||
nzBufferAccess_DiscardAndWrite,
|
||||
nzBufferAccess_ReadOnly,
|
||||
nzBufferAccess_ReadWrite,
|
||||
nzBufferAccess_WriteOnly
|
||||
};
|
||||
|
||||
enum nzBufferStorage
|
||||
{
|
||||
nzBufferStorage_Hardware,
|
||||
nzBufferStorage_Software,
|
||||
|
||||
nzBufferStorage_Max = nzBufferStorage_Software
|
||||
};
|
||||
|
||||
enum nzBufferType
|
||||
{
|
||||
nzBufferType_Index,
|
||||
nzBufferType_Vertex
|
||||
};
|
||||
|
||||
enum nzBufferUsage
|
||||
{
|
||||
nzBufferUsage_Dynamic,
|
||||
nzBufferUsage_Static
|
||||
};
|
||||
|
||||
enum nzCubemapFace
|
||||
{
|
||||
// L'ordre est X, -X, Y, -Y, Z, -Z
|
||||
// Cette énumération est prévue pour remplacer l'argument "z" des méthodes de NzImage contenant un cubemap
|
||||
nzCubemapFace_PositiveX = 0,
|
||||
nzCubemapFace_PositiveY = 2,
|
||||
nzCubemapFace_PositiveZ = 4,
|
||||
nzCubemapFace_NegativeX = 1,
|
||||
nzCubemapFace_NegativeY = 3,
|
||||
nzCubemapFace_NegativeZ = 5
|
||||
};
|
||||
|
||||
enum nzElementStream
|
||||
{
|
||||
nzElementStream_VertexData,
|
||||
nzElementStream_InstancedData,
|
||||
|
||||
nzElementStream_Max = nzElementStream_InstancedData
|
||||
};
|
||||
|
||||
enum nzElementType
|
||||
{
|
||||
nzElementType_Color,
|
||||
nzElementType_Double1,
|
||||
nzElementType_Double2,
|
||||
nzElementType_Double3,
|
||||
nzElementType_Double4,
|
||||
nzElementType_Float1,
|
||||
nzElementType_Float2,
|
||||
nzElementType_Float3,
|
||||
nzElementType_Float4
|
||||
};
|
||||
|
||||
enum nzElementUsage
|
||||
{
|
||||
nzElementUsage_Diffuse,
|
||||
nzElementUsage_Normal,
|
||||
nzElementUsage_Position,
|
||||
nzElementUsage_Tangent,
|
||||
nzElementUsage_TexCoord,
|
||||
|
||||
nzElementUsage_Max = nzElementUsage_TexCoord
|
||||
};
|
||||
|
||||
enum nzImageType
|
||||
{
|
||||
nzImageType_1D,
|
||||
nzImageType_2D,
|
||||
nzImageType_3D,
|
||||
nzImageType_Cubemap,
|
||||
|
||||
nzImageType_Max = nzImageType_Cubemap
|
||||
};
|
||||
|
||||
enum nzPixelFormat
|
||||
{
|
||||
nzPixelFormat_Undefined,
|
||||
|
||||
nzPixelFormat_BGR8, // 3*nzUInt8
|
||||
nzPixelFormat_BGRA8, // 4*nzUInt8
|
||||
nzPixelFormat_DXT1,
|
||||
nzPixelFormat_DXT3,
|
||||
nzPixelFormat_DXT5,
|
||||
nzPixelFormat_L8, // 1*nzUInt8
|
||||
nzPixelFormat_LA8, // 2*nzUInt8
|
||||
/*
|
||||
nzPixelFormat_RGB16F,
|
||||
nzPixelFormat_RGB16I, // 4*nzUInt16
|
||||
nzPixelFormat_RGB32F,
|
||||
nzPixelFormat_RGB32I, // 4*nzUInt32
|
||||
nzPixelFormat_RGBA16F,
|
||||
nzPixelFormat_RGBA16I, // 4*nzUInt16
|
||||
nzPixelFormat_RGBA32F,
|
||||
nzPixelFormat_RGBA32I, // 4*nzUInt32
|
||||
*/
|
||||
nzPixelFormat_RGBA4, // 1*nzUInt16
|
||||
nzPixelFormat_RGB5A1, // 1*nzUInt16
|
||||
nzPixelFormat_RGB8, // 3*nzUInt8
|
||||
nzPixelFormat_RGBA8, // 4*nzUInt8
|
||||
/*
|
||||
nzPixelFormat_Depth16,
|
||||
nzPixelFormat_Depth24,
|
||||
nzPixelFormat_Depth24Stencil8,
|
||||
nzPixelFormat_Depth32,
|
||||
nzPixelFormat_Stencil1,
|
||||
nzPixelFormat_Stencil4,
|
||||
nzPixelFormat_Stencil8,
|
||||
nzPixelFormat_Stencil16,
|
||||
*/
|
||||
|
||||
nzPixelFormat_Max = nzPixelFormat_RGBA8
|
||||
};
|
||||
|
||||
enum nzPixelFlipping
|
||||
{
|
||||
nzPixelFlipping_Horizontally,
|
||||
nzPixelFlipping_Vertically,
|
||||
|
||||
nzPixelFlipping_Max = nzPixelFlipping_Vertically
|
||||
};
|
||||
|
||||
enum nzPrimitiveType
|
||||
{
|
||||
nzPrimitiveType_LineList,
|
||||
nzPrimitiveType_LineStrip,
|
||||
nzPrimitiveType_PointList,
|
||||
nzPrimitiveType_TriangleList,
|
||||
nzPrimitiveType_TriangleStrip,
|
||||
nzPrimitiveType_TriangleFan
|
||||
};
|
||||
|
||||
enum nzWindowCursor
|
||||
{
|
||||
nzWindowCursor_None,
|
||||
nzWindowCursor_Default,
|
||||
|
||||
nzWindowCursor_Crosshair,
|
||||
nzWindowCursor_Hand,
|
||||
nzWindowCursor_Help,
|
||||
nzWindowCursor_Move,
|
||||
nzWindowCursor_Pointer,
|
||||
nzWindowCursor_Progress,
|
||||
nzWindowCursor_ResizeE,
|
||||
nzWindowCursor_ResizeN,
|
||||
nzWindowCursor_ResizeNE,
|
||||
nzWindowCursor_ResizeNW,
|
||||
nzWindowCursor_ResizeS,
|
||||
nzWindowCursor_ResizeSE,
|
||||
nzWindowCursor_ResizeSW,
|
||||
nzWindowCursor_ResizeW,
|
||||
nzWindowCursor_Text,
|
||||
nzWindowCursor_Wait
|
||||
};
|
||||
|
||||
enum nzWindowStyle
|
||||
{
|
||||
nzWindowStyle_None = 0x0,
|
||||
nzWindowStyle_Fullscreen = 0x1,
|
||||
|
||||
nzWindowStyle_Closable = 0x2,
|
||||
nzWindowStyle_Resizable = 0x4,
|
||||
nzWindowStyle_Titlebar = 0x4,
|
||||
|
||||
nzWindowStyle_Default = nzWindowStyle_Closable | nzWindowStyle_Resizable | nzWindowStyle_Titlebar
|
||||
};
|
||||
|
||||
#endif // NAZARA_ENUMS_UTILITY_HPP
|
||||
34
include/Nazara/Utility/Icon.hpp
Normal file
34
include/Nazara/Utility/Icon.hpp
Normal file
@@ -0,0 +1,34 @@
|
||||
// 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_ICON_HPP
|
||||
#define NAZARA_ICON_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
|
||||
class NzImage;
|
||||
class NzIconImpl;
|
||||
class NzWindowImpl;
|
||||
|
||||
class NAZARA_API NzIcon
|
||||
{
|
||||
friend class NzWindowImpl;
|
||||
|
||||
public:
|
||||
NzIcon();
|
||||
~NzIcon();
|
||||
|
||||
bool Create(const NzImage& icon);
|
||||
void Destroy();
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
private:
|
||||
NzIconImpl* m_impl;
|
||||
};
|
||||
|
||||
#endif // NAZARA_ICON_HPP
|
||||
@@ -13,46 +13,37 @@
|
||||
#include <Nazara/Math/Cube.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/ResourceLoader.hpp>
|
||||
#include <Nazara/Utility/PixelFormat.hpp>
|
||||
#include <Nazara/Utility/Resource.hpp>
|
||||
//#include <Nazara/Utility/ThreadSafety.hpp>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
enum nzCubemapFace
|
||||
{
|
||||
nzCubemapFace_PositiveX = 0,
|
||||
nzCubemapFace_NegativeX = 1,
|
||||
nzCubemapFace_PositiveY = 2,
|
||||
nzCubemapFace_NegativeY = 3,
|
||||
nzCubemapFace_PositiveZ = 4,
|
||||
nzCubemapFace_NegativeZ = 5
|
||||
};
|
||||
|
||||
enum nzImageType
|
||||
{
|
||||
nzImageType_1D,
|
||||
nzImageType_2D,
|
||||
nzImageType_3D,
|
||||
nzImageType_Cubemap,
|
||||
|
||||
nzImageType_Count
|
||||
};
|
||||
#if NAZARA_THREADSAFETY_IMAGE
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#else
|
||||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
struct NzImageParams
|
||||
{
|
||||
nzPixelFormat loadFormat = nzPixelFormat_Undefined;
|
||||
nzUInt8 levelCount = 0;
|
||||
|
||||
bool IsValid() const
|
||||
{
|
||||
return loadFormat == nzPixelFormat_Undefined || NzPixelFormat::IsValid(loadFormat);
|
||||
}
|
||||
bool IsValid() const;
|
||||
};
|
||||
|
||||
///TODO: Filtres
|
||||
|
||||
class NAZARA_API NzImage : public NzResource, public NzResourceLoader<NzImage, NzImageParams>
|
||||
class NzImage;
|
||||
|
||||
typedef NzResourceLoader<NzImage, NzImageParams> NzImageLoader;
|
||||
|
||||
class NAZARA_API NzImage : public NzResource
|
||||
{
|
||||
friend class NzResourceLoader<NzImage, NzImageParams>;
|
||||
|
||||
public:
|
||||
struct SharedImage;
|
||||
|
||||
@@ -109,12 +100,6 @@ class NAZARA_API NzImage : public NzResource, public NzResourceLoader<NzImage, N
|
||||
NzImage& operator=(NzImage&& image);
|
||||
|
||||
static nzUInt8 GetMaxLevel(unsigned int width, unsigned int height, unsigned int depth = 1);
|
||||
static void RegisterFileLoader(const NzString& extensions, LoadFileFunction loadFile);
|
||||
static void RegisterMemoryLoader(IsMemoryLoadingSupportedFunction isLoadingSupported, LoadMemoryFunction loadMemory);
|
||||
static void RegisterStreamLoader(IsStreamLoadingSupportedFunction isLoadingSupported, LoadStreamFunction loadStream);
|
||||
static void UnregisterFileLoader(const NzString& extensions, LoadFileFunction loadFile);
|
||||
static void UnregisterMemoryLoader(IsMemoryLoadingSupportedFunction isLoadingSupported, LoadMemoryFunction loadMemory);
|
||||
static void UnregisterStreamLoader(IsStreamLoadingSupportedFunction isLoadingSupported, LoadStreamFunction loadStream);
|
||||
|
||||
struct SharedImage
|
||||
{
|
||||
@@ -149,6 +134,10 @@ class NAZARA_API NzImage : public NzResource, public NzResourceLoader<NzImage, N
|
||||
void ReleaseImage();
|
||||
|
||||
SharedImage* m_sharedImage;
|
||||
|
||||
static std::list<NzImageLoader::MemoryLoader> s_memoryLoaders;
|
||||
static std::list<NzImageLoader::StreamLoader> s_streamLoaders;
|
||||
static std::multimap<NzString, NzImageLoader::LoadFileFunction> s_fileLoaders;
|
||||
};
|
||||
|
||||
#endif // NAZARA_IMAGE_HPP
|
||||
|
||||
@@ -8,29 +8,33 @@
|
||||
#define NAZARA_INDEXBUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/Buffer.hpp>
|
||||
#include <Nazara/Utility/Buffer.hpp>
|
||||
#include <Nazara/Utility/Resource.hpp>
|
||||
|
||||
class NAZARA_API NzIndexBuffer
|
||||
class NAZARA_API NzIndexBuffer : public NzResource
|
||||
{
|
||||
public:
|
||||
NzIndexBuffer(NzBuffer* buffer, unsigned int startIndex, unsigned int indexCount);
|
||||
NzIndexBuffer(unsigned int length, nzUInt8 indexSize, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
NzIndexBuffer(unsigned int length, nzUInt8 indexSize, nzBufferStorage storage = nzBufferStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
NzIndexBuffer(const NzIndexBuffer& indexBuffer);
|
||||
~NzIndexBuffer();
|
||||
|
||||
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
||||
|
||||
NzBuffer* GetBuffer() const;
|
||||
void* GetBufferPtr();
|
||||
const void* GetBufferPtr() const;
|
||||
nzUInt8 GetIndexSize() const;
|
||||
unsigned int GetIndexCount() const;
|
||||
void* GetPointer();
|
||||
const void* GetPointer() const;
|
||||
unsigned int GetStartIndex() const;
|
||||
|
||||
bool IsHardware() const;
|
||||
bool IsSequential() const;
|
||||
|
||||
void* Map(nzBufferAccess access, unsigned int offset = 0, unsigned int length = 0);
|
||||
|
||||
bool SetStorage(nzBufferStorage storage);
|
||||
|
||||
bool Unmap();
|
||||
|
||||
private:
|
||||
23
include/Nazara/Utility/KeyframeMesh.hpp
Normal file
23
include/Nazara/Utility/KeyframeMesh.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
// 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_KEYFRAMEMESH_HPP
|
||||
#define NAZARA_KEYFRAMEMESH_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
|
||||
class NzMesh;
|
||||
struct NzAnimation;
|
||||
|
||||
class NAZARA_API NzKeyframeMesh : public NzSubMesh
|
||||
{
|
||||
public:
|
||||
NzKeyframeMesh(const NzMesh* parent);
|
||||
virtual ~NzKeyframeMesh();
|
||||
};
|
||||
|
||||
#endif // NAZARA_KEYFRAMEMESH_HPP
|
||||
93
include/Nazara/Utility/Mesh.hpp
Normal file
93
include/Nazara/Utility/Mesh.hpp
Normal file
@@ -0,0 +1,93 @@
|
||||
// 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_MESH_HPP
|
||||
#define NAZARA_MESH_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Animation.hpp>
|
||||
#include <Nazara/Utility/ResourceLoader.hpp>
|
||||
#include <Nazara/Utility/Resource.hpp>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
class NzSubMesh;
|
||||
class NzVertexDeclaration;
|
||||
|
||||
struct NzMeshParams
|
||||
{
|
||||
NzAnimationParams animation;
|
||||
//const NzVertexDeclaration* declaration = nullptr;
|
||||
bool forceSoftware = false;
|
||||
bool loadAnimations = true;
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
|
||||
class NzMesh;
|
||||
|
||||
typedef NzResourceLoader<NzMesh, NzMeshParams> NzMeshLoader;
|
||||
|
||||
struct NzMeshImpl;
|
||||
|
||||
class NAZARA_API NzMesh : public NzResource
|
||||
{
|
||||
friend class NzResourceLoader<NzMesh, NzMeshParams>;
|
||||
|
||||
public:
|
||||
NzMesh() = default;
|
||||
~NzMesh();
|
||||
|
||||
unsigned int AddSkin(const NzString& skin, bool setDefault = false);
|
||||
nzUInt8 AddSubMesh(NzSubMesh* subMesh);
|
||||
nzUInt8 AddSubMesh(const NzString& identifier, NzSubMesh* subMesh);
|
||||
|
||||
void Animate(unsigned int frameA, unsigned int frameB, float interpolation);
|
||||
|
||||
bool Create(nzAnimationType type);
|
||||
void Destroy();
|
||||
|
||||
const NzAnimation* GetAnimation() const;
|
||||
nzAnimationType GetAnimationType() const;
|
||||
unsigned int GetFrameCount() const;
|
||||
NzString GetSkin(unsigned int index = 0) const;
|
||||
unsigned int GetSkinCount() const;
|
||||
NzSubMesh* GetSubMesh(const NzString& identifier);
|
||||
NzSubMesh* GetSubMesh(nzUInt8 index);
|
||||
const NzSubMesh* GetSubMesh(const NzString& identifier) const;
|
||||
const NzSubMesh* GetSubMesh(nzUInt8 index) const;
|
||||
nzUInt8 GetSubMeshCount() const;
|
||||
unsigned int GetVertexCount() const;
|
||||
|
||||
bool HasAnimation() const;
|
||||
bool HasSkin(unsigned int index = 0) const;
|
||||
bool HasSubMesh(const NzString& identifier) const;
|
||||
bool HasSubMesh(nzUInt8 index = 0) const;
|
||||
|
||||
bool IsAnimable() const;
|
||||
bool IsValid() const;
|
||||
|
||||
bool LoadFromFile(const NzString& filePath, const NzMeshParams& params = NzMeshParams());
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const NzMeshParams& params = NzMeshParams());
|
||||
bool LoadFromStream(NzInputStream& stream, const NzMeshParams& params = NzMeshParams());
|
||||
|
||||
void RemoveSkin(unsigned int index = 0);
|
||||
void RemoveSubMesh(const NzString& identifier);
|
||||
void RemoveSubMesh(nzUInt8 index = 0);
|
||||
|
||||
bool SetAnimation(const NzAnimation* animation);
|
||||
|
||||
private:
|
||||
NzMeshImpl* m_impl = nullptr;
|
||||
|
||||
static std::list<NzMeshLoader::MemoryLoader> s_memoryLoaders;
|
||||
static std::list<NzMeshLoader::StreamLoader> s_streamLoaders;
|
||||
static std::multimap<NzString, NzMeshLoader::LoadFileFunction> s_fileLoaders;
|
||||
};
|
||||
|
||||
#endif // NAZARA_MESH_HPP
|
||||
@@ -9,45 +9,8 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
enum nzPixelFormat
|
||||
{
|
||||
nzPixelFormat_Undefined,
|
||||
|
||||
nzPixelFormat_BGR8, // 3*nzUInt8
|
||||
nzPixelFormat_BGRA8, // 4*nzUInt8
|
||||
nzPixelFormat_DXT1,
|
||||
nzPixelFormat_DXT3,
|
||||
nzPixelFormat_DXT5,
|
||||
nzPixelFormat_L8, // 1*nzUInt8
|
||||
nzPixelFormat_LA8, // 2*nzUInt8
|
||||
/*
|
||||
nzPixelFormat_RGB16F,
|
||||
nzPixelFormat_RGB16I, // 4*nzUInt16
|
||||
nzPixelFormat_RGB32F,
|
||||
nzPixelFormat_RGB32I, // 4*nzUInt32
|
||||
nzPixelFormat_RGBA16F,
|
||||
nzPixelFormat_RGBA16I, // 4*nzUInt16
|
||||
nzPixelFormat_RGBA32F,
|
||||
nzPixelFormat_RGBA32I, // 4*nzUInt32
|
||||
*/
|
||||
nzPixelFormat_RGBA4, // 1*nzUInt16
|
||||
nzPixelFormat_RGB5A1, // 1*nzUInt16
|
||||
nzPixelFormat_RGB8, // 3*nzUInt8
|
||||
nzPixelFormat_RGBA8, // 4*nzUInt8
|
||||
/*
|
||||
nzPixelFormat_Depth16,
|
||||
nzPixelFormat_Depth24,
|
||||
nzPixelFormat_Depth24Stencil8,
|
||||
nzPixelFormat_Depth32,
|
||||
nzPixelFormat_Stencil1,
|
||||
nzPixelFormat_Stencil4,
|
||||
nzPixelFormat_Stencil8,
|
||||
nzPixelFormat_Stencil16,
|
||||
*/
|
||||
|
||||
nzPixelFormat_Count
|
||||
};
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <map>
|
||||
|
||||
class NzUtility;
|
||||
|
||||
@@ -57,10 +20,13 @@ class NzPixelFormat
|
||||
|
||||
public:
|
||||
typedef nzUInt8* (*ConvertFunction)(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst);
|
||||
typedef void (*FlipFunction)(unsigned int width, unsigned int height, unsigned int depth, const nzUInt8* src, nzUInt8* dst);
|
||||
|
||||
static bool Convert(nzPixelFormat srcFormat, nzPixelFormat dstFormat, const void* src, void* dst);
|
||||
static bool Convert(nzPixelFormat srcFormat, nzPixelFormat dstFormat, const void* start, const void* end, void* dst);
|
||||
|
||||
static bool Flip(nzPixelFlipping flipping, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst);
|
||||
|
||||
static nzUInt8 GetBPP(nzPixelFormat format);
|
||||
|
||||
static bool HasAlpha(nzPixelFormat format);
|
||||
@@ -69,7 +35,8 @@ class NzPixelFormat
|
||||
static bool IsConversionSupported(nzPixelFormat srcFormat, nzPixelFormat dstFormat);
|
||||
static bool IsValid(nzPixelFormat format);
|
||||
|
||||
static void SetConvertFunction(nzPixelFormat srcFormat, nzPixelFormat dstFormat, ConvertFunction);
|
||||
static void SetConvertFunction(nzPixelFormat srcFormat, nzPixelFormat dstFormat, ConvertFunction func);
|
||||
static void SetFlipFunction(nzPixelFlipping flipping, nzPixelFormat format, FlipFunction func);
|
||||
|
||||
static NzString ToString(nzPixelFormat format);
|
||||
|
||||
@@ -77,7 +44,8 @@ class NzPixelFormat
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
static NAZARA_API ConvertFunction s_convertFunctions[nzPixelFormat_Count][nzPixelFormat_Count];
|
||||
static NAZARA_API ConvertFunction s_convertFunctions[nzPixelFormat_Max+1][nzPixelFormat_Max+1];
|
||||
static NAZARA_API std::map<nzPixelFormat, FlipFunction> s_flipFunctions[nzPixelFlipping_Max+1];
|
||||
};
|
||||
|
||||
#include <Nazara/Utility/PixelFormat.inl>
|
||||
|
||||
@@ -68,6 +68,102 @@ inline bool NzPixelFormat::Convert(nzPixelFormat srcFormat, nzPixelFormat dstFor
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool NzPixelFormat::Flip(nzPixelFlipping flipping, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid(format))
|
||||
{
|
||||
NazaraError("Invalid pixel format");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
auto it = s_flipFunctions[flipping].find(format);
|
||||
if (it != s_flipFunctions[flipping].end())
|
||||
it->second(width, height, depth, reinterpret_cast<const nzUInt8*>(src), reinterpret_cast<nzUInt8*>(dst));
|
||||
else
|
||||
{
|
||||
// Flipping générique
|
||||
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (IsCompressed(format))
|
||||
{
|
||||
NazaraError("No function to flip compressed format");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
nzUInt8 bpp = GetBPP(format);
|
||||
unsigned int lineStride = width*bpp;
|
||||
switch (flipping)
|
||||
{
|
||||
case nzPixelFlipping_Horizontally:
|
||||
{
|
||||
if (src == dst)
|
||||
{
|
||||
for (unsigned int z = 0; z < depth; ++z)
|
||||
{
|
||||
nzUInt8* ptr = reinterpret_cast<nzUInt8*>(dst) + width*height*z;
|
||||
for (unsigned int y = 0; y < height; ++y)
|
||||
{
|
||||
for (unsigned int x = 0; x < width/2; ++x)
|
||||
std::swap_ranges(&ptr[x*bpp], &ptr[(x+1)*bpp], &ptr[(width-x)*bpp]);
|
||||
|
||||
ptr += lineStride;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int z = 0; z < depth; ++z)
|
||||
{
|
||||
nzUInt8* ptr = reinterpret_cast<nzUInt8*>(dst) + width*height*z;
|
||||
for (unsigned int y = 0; y < height; ++y)
|
||||
{
|
||||
for (unsigned int x = 0; x < width; ++x)
|
||||
std::memcpy(&ptr[x*bpp], &ptr[(width-x)*bpp], bpp);
|
||||
|
||||
ptr += lineStride;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case nzPixelFlipping_Vertically:
|
||||
{
|
||||
if (src == dst)
|
||||
{
|
||||
for (unsigned int z = 0; z < depth; ++z)
|
||||
{
|
||||
nzUInt8* ptr = reinterpret_cast<nzUInt8*>(dst) + width*height*z;
|
||||
for (unsigned int y = 0; y < height/2; ++y)
|
||||
std::swap_ranges(&ptr[y*lineStride], &ptr[(y+1)*lineStride-1], &ptr[(height-y-1)*lineStride]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int z = 0; z < depth; ++z)
|
||||
{
|
||||
const nzUInt8* srcPtr = reinterpret_cast<const nzUInt8*>(src);
|
||||
nzUInt8* dstPtr = reinterpret_cast<nzUInt8*>(dst) + (width-1)*height*depth*bpp;
|
||||
for (unsigned int y = 0; y < height; ++y)
|
||||
{
|
||||
std::memcpy(dstPtr, srcPtr, lineStride);
|
||||
|
||||
srcPtr += lineStride;
|
||||
dstPtr -= lineStride;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline nzUInt8 NzPixelFormat::GetBPP(nzPixelFormat format)
|
||||
{
|
||||
switch (format)
|
||||
@@ -129,7 +225,6 @@ inline nzUInt8 NzPixelFormat::GetBPP(nzPixelFormat format)
|
||||
case nzPixelFormat_RGBA8:
|
||||
return 4;
|
||||
|
||||
case nzPixelFormat_Count:
|
||||
case nzPixelFormat_Undefined:
|
||||
NazaraError("Invalid pixel format");
|
||||
return 0;
|
||||
@@ -159,7 +254,6 @@ inline bool NzPixelFormat::HasAlpha(nzPixelFormat format)
|
||||
case nzPixelFormat_RGB8:
|
||||
return false;
|
||||
|
||||
case nzPixelFormat_Count:
|
||||
case nzPixelFormat_Undefined:
|
||||
break;
|
||||
}
|
||||
@@ -192,15 +286,7 @@ inline bool NzPixelFormat::IsConversionSupported(nzPixelFormat srcFormat, nzPixe
|
||||
|
||||
inline bool NzPixelFormat::IsValid(nzPixelFormat format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case nzPixelFormat_Count:
|
||||
case nzPixelFormat_Undefined:
|
||||
return false;
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
return format != nzPixelFormat_Undefined;
|
||||
}
|
||||
|
||||
inline void NzPixelFormat::SetConvertFunction(nzPixelFormat srcFormat, nzPixelFormat dstFormat, ConvertFunction func)
|
||||
@@ -208,6 +294,11 @@ inline void NzPixelFormat::SetConvertFunction(nzPixelFormat srcFormat, nzPixelFo
|
||||
s_convertFunctions[srcFormat][dstFormat] = func;
|
||||
}
|
||||
|
||||
inline void NzPixelFormat::SetFlipFunction(nzPixelFlipping flipping, nzPixelFormat format, FlipFunction func)
|
||||
{
|
||||
s_flipFunctions[flipping][format] = func;
|
||||
}
|
||||
|
||||
inline NzString NzPixelFormat::ToString(nzPixelFormat format)
|
||||
{
|
||||
switch (format)
|
||||
@@ -269,7 +360,6 @@ inline NzString NzPixelFormat::ToString(nzPixelFormat format)
|
||||
case nzPixelFormat_RGBA8:
|
||||
return "RGBA8";
|
||||
|
||||
case nzPixelFormat_Count:
|
||||
case nzPixelFormat_Undefined:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#define NAZARA_RESOURCELOADER_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
class NzInputStream;
|
||||
@@ -18,30 +16,26 @@ template<typename Type, typename Parameters>
|
||||
class NzResourceLoader
|
||||
{
|
||||
public:
|
||||
typedef bool (*IsMemoryLoadingSupportedFunction)(const void* data, unsigned int size, const Parameters& parameters);
|
||||
typedef bool (*IsStreamLoadingSupportedFunction)(NzInputStream& stream, const Parameters& parameters);
|
||||
typedef bool (*LoadFileFunction)(Type* resource, const NzString& filePath, const Parameters& parameters);
|
||||
typedef bool (*LoadMemoryFunction)(Type* resource, const void* data, unsigned int size, const Parameters& parameters);
|
||||
typedef bool (*LoadStreamFunction)(Type* resource, NzInputStream& stream, const Parameters& parameters);
|
||||
using IdentifyMemoryFunction = bool (*)(const void* data, unsigned int size, const Parameters& parameters);
|
||||
using IdentifyStreamFunction = bool (*)(NzInputStream& stream, const Parameters& parameters);
|
||||
using LoadFileFunction = bool (*)(Type* resource, const NzString& filePath, const Parameters& parameters);
|
||||
using LoadMemoryFunction = bool (*)(Type* resource, const void* data, unsigned int size, const Parameters& parameters);
|
||||
using LoadStreamFunction = bool (*)(Type* resource, NzInputStream& stream, const Parameters& parameters);
|
||||
|
||||
protected:
|
||||
static bool LoadResourceFromFile(Type* resource, const NzString& filePath, const Parameters& parameters);
|
||||
static bool LoadResourceFromMemory(Type* resource, const void* data, unsigned int size, const Parameters& parameters);
|
||||
static bool LoadResourceFromStream(Type* resource, NzInputStream& stream, const Parameters& parameters);
|
||||
static void RegisterResourceFileLoader(const NzString& extensions, LoadFileFunction loadFile);
|
||||
static void RegisterResourceMemoryLoader(IsMemoryLoadingSupportedFunction isLoadingSupported, LoadMemoryFunction loadMemory);
|
||||
static void RegisterResourceStreamLoader(IsStreamLoadingSupportedFunction isLoadingSupported, LoadStreamFunction loadStream);
|
||||
static void UnregisterResourceFileLoader(const NzString& extensions, LoadFileFunction loadFile);
|
||||
static void UnregisterResourceMemoryLoader(IsMemoryLoadingSupportedFunction isLoadingSupported, LoadMemoryFunction loadMemory);
|
||||
static void UnregisterResourceStreamLoader(IsStreamLoadingSupportedFunction isLoadingSupported, LoadStreamFunction loadStream);
|
||||
static bool LoadFromFile(Type* resource, const NzString& filePath, const Parameters& parameters = Parameters());
|
||||
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());
|
||||
|
||||
private:
|
||||
typedef std::pair<IsMemoryLoadingSupportedFunction, LoadMemoryFunction> MemoryLoader;
|
||||
typedef std::pair<IsStreamLoadingSupportedFunction, LoadStreamFunction> StreamLoader;
|
||||
static void RegisterFileLoader(const NzString& extensions, LoadFileFunction loadFile);
|
||||
static void RegisterMemoryLoader(IdentifyMemoryFunction identifyMemory, LoadMemoryFunction loadMemory);
|
||||
static void RegisterStreamLoader(IdentifyStreamFunction identifyStream, LoadStreamFunction loadStream);
|
||||
|
||||
static std::list<MemoryLoader> s_memoryLoaders;
|
||||
static std::list<StreamLoader> s_streamLoaders;
|
||||
static std::multimap<NzString, LoadFileFunction> s_fileLoaders;
|
||||
static void UnregisterFileLoader(const NzString& extensions, LoadFileFunction loadFile);
|
||||
static void UnregisterMemoryLoader(IdentifyMemoryFunction identifyMemory, LoadMemoryFunction loadMemory);
|
||||
static void UnregisterStreamLoader(IdentifyStreamFunction identifyStream, LoadStreamFunction loadStream);
|
||||
|
||||
typedef std::pair<IdentifyMemoryFunction, LoadMemoryFunction> MemoryLoader;
|
||||
typedef std::pair<IdentifyStreamFunction, LoadStreamFunction> StreamLoader;
|
||||
};
|
||||
|
||||
#include <Nazara/Utility/ResourceLoader.inl>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
bool NzResourceLoader<Type, Parameters>::LoadResourceFromFile(Type* resource, const NzString& filePath, const Parameters& parameters)
|
||||
bool NzResourceLoader<Type, Parameters>::LoadFromFile(Type* resource, const NzString& filePath, const Parameters& parameters)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!parameters.IsValid())
|
||||
@@ -28,7 +28,7 @@ bool NzResourceLoader<Type, Parameters>::LoadResourceFromFile(Type* resource, co
|
||||
}
|
||||
|
||||
// Récupération de tous les loaders de cette extension
|
||||
auto range = s_fileLoaders.equal_range(ext);
|
||||
auto range = Type::s_fileLoaders.equal_range(ext);
|
||||
if (range.first == range.second)
|
||||
{
|
||||
NazaraError("No loader found for extension \"" + ext + '"');
|
||||
@@ -56,7 +56,7 @@ bool NzResourceLoader<Type, Parameters>::LoadResourceFromFile(Type* resource, co
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
bool NzResourceLoader<Type, Parameters>::LoadResourceFromMemory(Type* resource, const void* data, unsigned int size, const Parameters& parameters)
|
||||
bool NzResourceLoader<Type, Parameters>::LoadFromMemory(Type* resource, const void* data, unsigned int size, const Parameters& parameters)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!parameters.IsValid())
|
||||
@@ -72,7 +72,7 @@ bool NzResourceLoader<Type, Parameters>::LoadResourceFromMemory(Type* resource,
|
||||
}
|
||||
#endif
|
||||
|
||||
for (auto loader = s_memoryLoaders.rbegin(); loader != s_memoryLoaders.rend(); ++loader)
|
||||
for (auto loader = Type::s_memoryLoaders.rbegin(); loader != Type::s_memoryLoaders.rend(); ++loader)
|
||||
{
|
||||
// Le loader supporte-t-il les données ?
|
||||
if (!loader->first(data, size, parameters))
|
||||
@@ -90,7 +90,7 @@ bool NzResourceLoader<Type, Parameters>::LoadResourceFromMemory(Type* resource,
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
bool NzResourceLoader<Type, Parameters>::LoadResourceFromStream(Type* resource, NzInputStream& stream, const Parameters& parameters)
|
||||
bool NzResourceLoader<Type, Parameters>::LoadFromStream(Type* resource, NzInputStream& stream, const Parameters& parameters)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!parameters.IsValid())
|
||||
@@ -107,7 +107,7 @@ bool NzResourceLoader<Type, Parameters>::LoadResourceFromStream(Type* resource,
|
||||
#endif
|
||||
|
||||
nzUInt64 streamPos = stream.GetCursorPos();
|
||||
for (auto loader = s_streamLoaders.rbegin(); loader != s_streamLoaders.rend(); ++loader)
|
||||
for (auto loader = Type::s_streamLoaders.rbegin(); loader != Type::s_streamLoaders.rend(); ++loader)
|
||||
{
|
||||
stream.SetCursorPos(streamPos);
|
||||
|
||||
@@ -129,29 +129,29 @@ bool NzResourceLoader<Type, Parameters>::LoadResourceFromStream(Type* resource,
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
void NzResourceLoader<Type, Parameters>::RegisterResourceFileLoader(const NzString& extensions, LoadFileFunction loadFile)
|
||||
void NzResourceLoader<Type, Parameters>::RegisterFileLoader(const NzString& extensions, LoadFileFunction loadFile)
|
||||
{
|
||||
std::vector<NzString> exts;
|
||||
extensions.SplitAny(exts, " /\\*.,;|-_");
|
||||
|
||||
for (const NzString& ext : exts)
|
||||
s_fileLoaders.insert(std::make_pair(ext, loadFile));
|
||||
Type::s_fileLoaders.insert(std::make_pair(ext, loadFile));
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
void NzResourceLoader<Type, Parameters>::RegisterResourceMemoryLoader(IsMemoryLoadingSupportedFunction isLoadingSupported, LoadMemoryFunction loadMemory)
|
||||
void NzResourceLoader<Type, Parameters>::RegisterMemoryLoader(IdentifyMemoryFunction identifyMemory, LoadMemoryFunction loadMemory)
|
||||
{
|
||||
s_memoryLoaders.push_back(std::make_pair(isLoadingSupported, loadMemory));
|
||||
Type::s_memoryLoaders.push_back(std::make_pair(identifyMemory, loadMemory));
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
void NzResourceLoader<Type, Parameters>::RegisterResourceStreamLoader(IsStreamLoadingSupportedFunction isLoadingSupported, LoadStreamFunction loadStream)
|
||||
void NzResourceLoader<Type, Parameters>::RegisterStreamLoader(IdentifyStreamFunction identifyStream, LoadStreamFunction loadStream)
|
||||
{
|
||||
s_streamLoaders.push_back(std::make_pair(isLoadingSupported, loadStream));
|
||||
Type::s_streamLoaders.push_back(std::make_pair(identifyStream, loadStream));
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
void NzResourceLoader<Type, Parameters>::UnregisterResourceFileLoader(const NzString& extensions, LoadFileFunction loadFile)
|
||||
void NzResourceLoader<Type, Parameters>::UnregisterFileLoader(const NzString& extensions, LoadFileFunction loadFile)
|
||||
{
|
||||
std::vector<NzString> exts;
|
||||
extensions.SplitAny(exts, " /\\*.,;|-_");
|
||||
@@ -159,13 +159,13 @@ void NzResourceLoader<Type, Parameters>::UnregisterResourceFileLoader(const NzSt
|
||||
for (const NzString& ext : exts)
|
||||
{
|
||||
// Récupération de tous les loaders de cette extension
|
||||
auto range = s_fileLoaders.equal_range(ext);
|
||||
auto range = Type::s_fileLoaders.equal_range(ext);
|
||||
|
||||
for (auto it = range.first; it != range.second; ++it)
|
||||
{
|
||||
if (it->second == loadFile)
|
||||
{
|
||||
s_fileLoaders.erase(it);
|
||||
Type::s_fileLoaders.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -173,19 +173,15 @@ void NzResourceLoader<Type, Parameters>::UnregisterResourceFileLoader(const NzSt
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
void NzResourceLoader<Type, Parameters>::UnregisterResourceMemoryLoader(IsMemoryLoadingSupportedFunction isLoadingSupported, LoadMemoryFunction loadMemory)
|
||||
void NzResourceLoader<Type, Parameters>::UnregisterMemoryLoader(IdentifyMemoryFunction identifyMemory, LoadMemoryFunction loadMemory)
|
||||
{
|
||||
s_memoryLoaders.remove(std::make_pair(isLoadingSupported, loadMemory));
|
||||
Type::s_memoryLoaders.remove(std::make_pair(identifyMemory, loadMemory));
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
void NzResourceLoader<Type, Parameters>::UnregisterResourceStreamLoader(IsStreamLoadingSupportedFunction isLoadingSupported, LoadStreamFunction loadStream)
|
||||
void NzResourceLoader<Type, Parameters>::UnregisterStreamLoader(IdentifyStreamFunction identifyStream, LoadStreamFunction loadStream)
|
||||
{
|
||||
s_streamLoaders.remove(std::make_pair(isLoadingSupported, loadStream));
|
||||
Type::s_streamLoaders.remove(std::make_pair(identifyStream, loadStream));
|
||||
}
|
||||
|
||||
template<typename T, typename P> std::list<typename NzResourceLoader<T, P>::MemoryLoader> NzResourceLoader<T, P>::s_memoryLoaders;
|
||||
template<typename T, typename P> std::list<typename NzResourceLoader<T, P>::StreamLoader> NzResourceLoader<T, P>::s_streamLoaders;
|
||||
template<typename T, typename P> std::multimap<NzString, typename NzResourceLoader<T, P>::LoadFileFunction> NzResourceLoader<T, P>::s_fileLoaders;
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
|
||||
44
include/Nazara/Utility/StaticMesh.hpp
Normal file
44
include/Nazara/Utility/StaticMesh.hpp
Normal file
@@ -0,0 +1,44 @@
|
||||
// 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_STATICMESH_HPP
|
||||
#define NAZARA_STATICMESH_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
|
||||
class NAZARA_API NzStaticMesh final : public NzSubMesh
|
||||
{
|
||||
public:
|
||||
NzStaticMesh(const NzMesh* parent);
|
||||
NzStaticMesh(const NzMesh* parent, const NzVertexBuffer* vertexBuffer, const NzVertexDeclaration* vertexDeclaration, const NzIndexBuffer* indexBuffer = nullptr);
|
||||
virtual ~NzStaticMesh();
|
||||
|
||||
bool Create(const NzVertexBuffer* vertexBuffer, const NzVertexDeclaration* vertexDeclaration, const NzIndexBuffer* indexBuffer = nullptr);
|
||||
void Destroy();
|
||||
|
||||
nzAnimationType GetAnimationType() const;
|
||||
unsigned int GetFrameCount() const;
|
||||
const NzIndexBuffer* GetIndexBuffer() const;
|
||||
nzPrimitiveType GetPrimitiveType() const;
|
||||
const NzVertexBuffer* GetVertexBuffer() const;
|
||||
const NzVertexDeclaration* GetVertexDeclaration() const;
|
||||
|
||||
bool IsAnimated() const;
|
||||
bool IsValid() const;
|
||||
|
||||
void SetPrimitiveType(nzPrimitiveType primitiveType);
|
||||
|
||||
private:
|
||||
void AnimateImpl(unsigned int frameA, unsigned int frameB, float interpolation);
|
||||
|
||||
nzPrimitiveType m_primitiveType = nzPrimitiveType_TriangleList;
|
||||
const NzIndexBuffer* m_indexBuffer = nullptr;
|
||||
const NzVertexBuffer* m_vertexBuffer = nullptr;
|
||||
const NzVertexDeclaration* m_vertexDeclaration = nullptr;
|
||||
};
|
||||
|
||||
#endif // NAZARA_STATICMESH_HPP
|
||||
42
include/Nazara/Utility/SubMesh.hpp
Normal file
42
include/Nazara/Utility/SubMesh.hpp
Normal file
@@ -0,0 +1,42 @@
|
||||
// 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_SUBMESH_HPP
|
||||
#define NAZARA_SUBMESH_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/IndexBuffer.hpp>
|
||||
#include <Nazara/Utility/Resource.hpp>
|
||||
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||
|
||||
class NzMesh;
|
||||
|
||||
class NAZARA_API NzSubMesh : public NzResource
|
||||
{
|
||||
friend class NzMesh;
|
||||
|
||||
public:
|
||||
NzSubMesh(const NzMesh* parent);
|
||||
virtual ~NzSubMesh();
|
||||
|
||||
void Animate(unsigned int frameA, unsigned int frameB, float interpolation);
|
||||
|
||||
virtual const NzIndexBuffer* GetIndexBuffer() const = 0;
|
||||
const NzMesh* GetParent() const;
|
||||
virtual nzPrimitiveType GetPrimitiveType() const = 0;
|
||||
virtual const NzVertexBuffer* GetVertexBuffer() const = 0;
|
||||
virtual const NzVertexDeclaration* GetVertexDeclaration() const = 0;
|
||||
unsigned int GetVertexCount() const;
|
||||
|
||||
protected:
|
||||
virtual void AnimateImpl(unsigned int frameA, unsigned int frameB, float interpolation) = 0;
|
||||
|
||||
const NzMesh* m_parent;
|
||||
};
|
||||
|
||||
#endif // NAZARA_SUBMESH_HPP
|
||||
@@ -8,21 +8,22 @@
|
||||
#define NAZARA_VERTEXBUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/Buffer.hpp>
|
||||
#include <Nazara/Utility/Buffer.hpp>
|
||||
#include <Nazara/Utility/Resource.hpp>
|
||||
|
||||
class NAZARA_API NzVertexBuffer
|
||||
class NAZARA_API NzVertexBuffer : public NzResource
|
||||
{
|
||||
public:
|
||||
NzVertexBuffer(NzBuffer* buffer, unsigned int startVertex, unsigned int vertexCount);
|
||||
NzVertexBuffer(unsigned int length, nzUInt8 typeSize, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
NzVertexBuffer(unsigned int length, nzUInt8 typeSize, nzBufferStorage storage = nzBufferStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
NzVertexBuffer(const NzVertexBuffer& vertexBuffer);
|
||||
~NzVertexBuffer();
|
||||
|
||||
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
||||
|
||||
NzBuffer* GetBuffer() const;
|
||||
void* GetBufferPtr();
|
||||
const void* GetBufferPtr() const;
|
||||
void* GetPointer();
|
||||
const void* GetPointer() const;
|
||||
unsigned int GetStartVertex() const;
|
||||
nzUInt8 GetTypeSize() const;
|
||||
unsigned int GetVertexCount() const;
|
||||
@@ -30,6 +31,9 @@ class NAZARA_API NzVertexBuffer
|
||||
bool IsHardware() const;
|
||||
|
||||
void* Map(nzBufferAccess access, unsigned int offset = 0, unsigned int length = 0);
|
||||
|
||||
bool SetStorage(nzBufferStorage storage);
|
||||
|
||||
bool Unmap();
|
||||
|
||||
private:
|
||||
53
include/Nazara/Utility/VertexDeclaration.hpp
Normal file
53
include/Nazara/Utility/VertexDeclaration.hpp
Normal file
@@ -0,0 +1,53 @@
|
||||
// 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
|
||||
|
||||
#ifndef NAZARA_VERTEXDECLARATION_HPP
|
||||
#define NAZARA_VERTEXDECLARATION_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/Resource.hpp>
|
||||
|
||||
struct NzVertexElement
|
||||
{
|
||||
unsigned int offset;
|
||||
unsigned int usageIndex = 0;
|
||||
nzElementStream stream = nzElementStream_VertexData;
|
||||
nzElementType type;
|
||||
nzElementUsage usage;
|
||||
};
|
||||
|
||||
struct NzVertexDeclarationImpl;
|
||||
|
||||
class NAZARA_API NzVertexDeclaration : public NzResource
|
||||
{
|
||||
public:
|
||||
NzVertexDeclaration() = default;
|
||||
NzVertexDeclaration(const NzVertexElement* elements, unsigned int elementCount);
|
||||
NzVertexDeclaration(const NzVertexDeclaration& declaration);
|
||||
NzVertexDeclaration(NzVertexDeclaration&& declaration);
|
||||
~NzVertexDeclaration();
|
||||
|
||||
bool Create(const NzVertexElement* elements, unsigned int elementCount);
|
||||
void Destroy();
|
||||
|
||||
const NzVertexElement* GetElement(unsigned int i) const;
|
||||
const NzVertexElement* GetElement(nzElementStream stream, unsigned int i) const;
|
||||
const NzVertexElement* GetElement(nzElementStream stream, nzElementUsage usage, unsigned int usageIndex = 0) const;
|
||||
unsigned int GetElementCount() const;
|
||||
unsigned int GetElementCount(nzElementStream stream) const;
|
||||
unsigned int GetStride(nzElementStream stream) const;
|
||||
|
||||
bool HasStream(nzElementStream stream) const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
NzVertexDeclaration& operator=(const NzVertexDeclaration& declaration);
|
||||
NzVertexDeclaration& operator=(NzVertexDeclaration&& declaration);
|
||||
|
||||
private:
|
||||
NzVertexDeclarationImpl* m_sharedImpl = nullptr;
|
||||
};
|
||||
|
||||
#endif // NAZARA_VERTEXDECLARATION_HPP
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/Event.hpp>
|
||||
#include <Nazara/Utility/VideoMode.hpp>
|
||||
#include <Nazara/Utility/WindowHandle.hpp>
|
||||
@@ -24,6 +25,9 @@
|
||||
#include <Nazara/Core/ThreadCondition.hpp>
|
||||
#endif
|
||||
|
||||
class NzCursor;
|
||||
class NzImage;
|
||||
class NzIcon;
|
||||
class NzUtility;
|
||||
class NzWindowImpl;
|
||||
|
||||
@@ -33,26 +37,14 @@ class NAZARA_API NzWindow : NzNonCopyable
|
||||
friend class NzWindowImpl;
|
||||
|
||||
public:
|
||||
enum Style
|
||||
{
|
||||
None = 0x0,
|
||||
Fullscreen = 0x1,
|
||||
|
||||
Closable = 0x2,
|
||||
Resizable = 0x4,
|
||||
Titlebar = 0x8,
|
||||
|
||||
Default = Closable | Resizable | Titlebar
|
||||
};
|
||||
|
||||
NzWindow();
|
||||
NzWindow(NzVideoMode mode, const NzString& title, nzUInt32 style = Default);
|
||||
NzWindow(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default);
|
||||
NzWindow(NzWindowHandle handle);
|
||||
virtual ~NzWindow();
|
||||
|
||||
void Close();
|
||||
|
||||
bool Create(NzVideoMode mode, const NzString& title, nzUInt32 style = Default);
|
||||
bool Create(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default);
|
||||
bool Create(NzWindowHandle handle);
|
||||
|
||||
void EnableKeyRepeat(bool enable);
|
||||
@@ -73,8 +65,11 @@ class NAZARA_API NzWindow : NzNonCopyable
|
||||
|
||||
bool PollEvent(NzEvent* event);
|
||||
|
||||
void SetCursor(nzWindowCursor cursor);
|
||||
void SetCursor(const NzCursor& cursor);
|
||||
void SetEventListener(bool listener);
|
||||
void SetFocus();
|
||||
void SetIcon(const NzIcon& icon);
|
||||
void SetMaximumSize(const NzVector2i& maxSize);
|
||||
void SetMaximumSize(int width, int height);
|
||||
void SetMinimumSize(const NzVector2i& minSize);
|
||||
@@ -86,8 +81,6 @@ class NAZARA_API NzWindow : NzNonCopyable
|
||||
void SetTitle(const NzString& title);
|
||||
void SetVisible(bool visible);
|
||||
|
||||
void ShowMouseCursor(bool show);
|
||||
|
||||
void StayOnTop(bool stayOnTop);
|
||||
|
||||
bool WaitEvent(NzEvent* event);
|
||||
|
||||
Reference in New Issue
Block a user