Normalized line ending
Former-commit-id: bd061c48bdc8f0d26159dac3b41017defef5ae1e
This commit is contained in:
@@ -1,62 +1,62 @@
|
||||
// This file was automatically generated by Nazara
|
||||
|
||||
/*
|
||||
Nazara Engine - Core module
|
||||
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Nazara/Core/ByteArray.hpp>
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Core/ConditionVariable.hpp>
|
||||
#include <Nazara/Core/Config.hpp>
|
||||
#include <Nazara/Core/Core.hpp>
|
||||
#include <Nazara/Core/Directory.hpp>
|
||||
#include <Nazara/Core/DynLib.hpp>
|
||||
#include <Nazara/Core/Endianness.hpp>
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/File.hpp>
|
||||
#include <Nazara/Core/Format.hpp>
|
||||
#include <Nazara/Core/Functor.hpp>
|
||||
#include <Nazara/Core/Hash.hpp>
|
||||
#include <Nazara/Core/Hashable.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
#include <Nazara/Core/HashImpl.hpp>
|
||||
#include <Nazara/Core/Initializer.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/LockGuard.hpp>
|
||||
#include <Nazara/Core/Log.hpp>
|
||||
#include <Nazara/Core/MemoryStream.hpp>
|
||||
#include <Nazara/Core/Mutex.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceListener.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/Semaphore.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Core/Thread.hpp>
|
||||
#include <Nazara/Core/Tuple.hpp>
|
||||
#include <Nazara/Core/Unicode.hpp>
|
||||
// This file was automatically generated by Nazara
|
||||
|
||||
/*
|
||||
Nazara Engine - Core module
|
||||
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Nazara/Core/ByteArray.hpp>
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Core/ConditionVariable.hpp>
|
||||
#include <Nazara/Core/Config.hpp>
|
||||
#include <Nazara/Core/Core.hpp>
|
||||
#include <Nazara/Core/Directory.hpp>
|
||||
#include <Nazara/Core/DynLib.hpp>
|
||||
#include <Nazara/Core/Endianness.hpp>
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/File.hpp>
|
||||
#include <Nazara/Core/Format.hpp>
|
||||
#include <Nazara/Core/Functor.hpp>
|
||||
#include <Nazara/Core/Hash.hpp>
|
||||
#include <Nazara/Core/Hashable.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
#include <Nazara/Core/HashImpl.hpp>
|
||||
#include <Nazara/Core/Initializer.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/LockGuard.hpp>
|
||||
#include <Nazara/Core/Log.hpp>
|
||||
#include <Nazara/Core/MemoryStream.hpp>
|
||||
#include <Nazara/Core/Mutex.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceListener.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/Semaphore.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Core/Thread.hpp>
|
||||
#include <Nazara/Core/Tuple.hpp>
|
||||
#include <Nazara/Core/Unicode.hpp>
|
||||
|
||||
@@ -1,85 +1,85 @@
|
||||
/*
|
||||
Nazara Engine - Core module
|
||||
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONFIG_CORE_HPP
|
||||
#define NAZARA_CONFIG_CORE_HPP
|
||||
|
||||
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
|
||||
|
||||
// Appelle exit dès qu'une assertion est invalide
|
||||
#define NAZARA_CORE_EXIT_ON_ASSERT_FAILURE 1
|
||||
|
||||
// Teste les assertions
|
||||
#define NAZARA_CORE_ENABLE_ASSERTS 0
|
||||
|
||||
// Taille du buffer lors d'une lecture complète d'un fichier (ex: Hash)
|
||||
#define NAZARA_CORE_FILE_BUFFERSIZE 4096
|
||||
|
||||
// Le moteur doit-il incorporer les Unicode Character Data (Nécessaires pour faire fonctionner le flag NzString::HandleUTF8)
|
||||
#define NAZARA_CORE_INCLUDE_UNICODEDATA 0
|
||||
|
||||
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
|
||||
#define NAZARA_CORE_MEMORYLEAKTRACKER 0
|
||||
|
||||
// Standardise les séparateurs des dossiers selon le système d'exploitation courant (Léger coût à l'exécution)
|
||||
#define NAZARA_CORE_NORMALIZE_DIRECTORY_SEPARATORS 1
|
||||
|
||||
// Précision des réels lors de la transformation en texte (Max. chiffres après la virgule)
|
||||
#define NAZARA_CORE_REAL_PRECISION 6
|
||||
|
||||
// Duplique la sortie du log sur le flux de sortie standard (cout)
|
||||
#define NAZARA_CORE_DUPLICATE_TO_COUT 0
|
||||
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_CORE_SAFE 1
|
||||
|
||||
// Protège les classes des accès concurrentiels
|
||||
#define NAZARA_CORE_THREADSAFE 1
|
||||
|
||||
// Les classes à protéger des accès concurrentiels
|
||||
#define NAZARA_THREADSAFETY_BYTEARRAY 1 // NzByteArray (COW)
|
||||
#define NAZARA_THREADSAFETY_CLOCK 0 // NzClock
|
||||
#define NAZARA_THREADSAFETY_DIRECTORY 1 // NzDirectory
|
||||
#define NAZARA_THREADSAFETY_DYNLIB 1 // NzDynLib
|
||||
#define NAZARA_THREADSAFETY_FILE 1 // NzFile
|
||||
#define NAZARA_THREADSAFETY_HASHDIGEST 0 // NzHashDigest
|
||||
#define NAZARA_THREADSAFETY_LOG 1 // NzLog
|
||||
#define NAZARA_THREADSAFETY_RESOURCE 1 // NzResource
|
||||
#define NAZARA_THREADSAFETY_STRING 1 // NzString (COW)
|
||||
#define NAZARA_THREADSAFETY_STRINGSTREAM 0 // NzStringStream
|
||||
|
||||
// Le nombre de spinlocks à utiliser avec les critical sections de Windows (0 pour désactiver)
|
||||
#define NAZARA_CORE_WINDOWS_CS_SPINLOCKS 4096
|
||||
|
||||
// Optimise certaines parties du code avec certaines avancées venues de Windows Vista (Casse la compatibilité XP mais n'affecte pas les autres OS)
|
||||
#define NAZARA_CORE_WINDOWS_VISTA 0
|
||||
|
||||
/*
|
||||
// Règle le temps entre le réveil du thread des timers et l'activation d'un timer (En millisecondes)
|
||||
#define NAZARA_CORE_TIMER_WAKEUPTIME 10
|
||||
*/
|
||||
|
||||
#endif // NAZARA_CONFIG_CORE_HPP
|
||||
/*
|
||||
Nazara Engine - Core module
|
||||
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONFIG_CORE_HPP
|
||||
#define NAZARA_CONFIG_CORE_HPP
|
||||
|
||||
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
|
||||
|
||||
// Appelle exit dès qu'une assertion est invalide
|
||||
#define NAZARA_CORE_EXIT_ON_ASSERT_FAILURE 1
|
||||
|
||||
// Teste les assertions
|
||||
#define NAZARA_CORE_ENABLE_ASSERTS 0
|
||||
|
||||
// Taille du buffer lors d'une lecture complète d'un fichier (ex: Hash)
|
||||
#define NAZARA_CORE_FILE_BUFFERSIZE 4096
|
||||
|
||||
// Le moteur doit-il incorporer les Unicode Character Data (Nécessaires pour faire fonctionner le flag NzString::HandleUTF8)
|
||||
#define NAZARA_CORE_INCLUDE_UNICODEDATA 0
|
||||
|
||||
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
|
||||
#define NAZARA_CORE_MEMORYLEAKTRACKER 0
|
||||
|
||||
// Standardise les séparateurs des dossiers selon le système d'exploitation courant (Léger coût à l'exécution)
|
||||
#define NAZARA_CORE_NORMALIZE_DIRECTORY_SEPARATORS 1
|
||||
|
||||
// Précision des réels lors de la transformation en texte (Max. chiffres après la virgule)
|
||||
#define NAZARA_CORE_REAL_PRECISION 6
|
||||
|
||||
// Duplique la sortie du log sur le flux de sortie standard (cout)
|
||||
#define NAZARA_CORE_DUPLICATE_TO_COUT 0
|
||||
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_CORE_SAFE 1
|
||||
|
||||
// Protège les classes des accès concurrentiels
|
||||
#define NAZARA_CORE_THREADSAFE 1
|
||||
|
||||
// Les classes à protéger des accès concurrentiels
|
||||
#define NAZARA_THREADSAFETY_BYTEARRAY 1 // NzByteArray (COW)
|
||||
#define NAZARA_THREADSAFETY_CLOCK 0 // NzClock
|
||||
#define NAZARA_THREADSAFETY_DIRECTORY 1 // NzDirectory
|
||||
#define NAZARA_THREADSAFETY_DYNLIB 1 // NzDynLib
|
||||
#define NAZARA_THREADSAFETY_FILE 1 // NzFile
|
||||
#define NAZARA_THREADSAFETY_HASHDIGEST 0 // NzHashDigest
|
||||
#define NAZARA_THREADSAFETY_LOG 1 // NzLog
|
||||
#define NAZARA_THREADSAFETY_RESOURCE 1 // NzResource
|
||||
#define NAZARA_THREADSAFETY_STRING 1 // NzString (COW)
|
||||
#define NAZARA_THREADSAFETY_STRINGSTREAM 0 // NzStringStream
|
||||
|
||||
// Le nombre de spinlocks à utiliser avec les critical sections de Windows (0 pour désactiver)
|
||||
#define NAZARA_CORE_WINDOWS_CS_SPINLOCKS 4096
|
||||
|
||||
// Optimise certaines parties du code avec certaines avancées venues de Windows Vista (Casse la compatibilité XP mais n'affecte pas les autres OS)
|
||||
#define NAZARA_CORE_WINDOWS_VISTA 0
|
||||
|
||||
/*
|
||||
// Règle le temps entre le réveil du thread des timers et l'activation d'un timer (En millisecondes)
|
||||
#define NAZARA_CORE_TIMER_WAKEUPTIME 10
|
||||
*/
|
||||
|
||||
#endif // NAZARA_CONFIG_CORE_HPP
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_ENUMS_CORE_HPP
|
||||
#define NAZARA_ENUMS_CORE_HPP
|
||||
|
||||
enum nzEndianness
|
||||
{
|
||||
nzEndianness_Unknown = -1,
|
||||
|
||||
nzEndianness_BigEndian,
|
||||
nzEndianness_LittleEndian,
|
||||
|
||||
nzEndianness_Max = nzEndianness_LittleEndian
|
||||
};
|
||||
|
||||
enum nzErrorType
|
||||
{
|
||||
nzErrorType_AssertFailed,
|
||||
nzErrorType_Internal,
|
||||
nzErrorType_Normal,
|
||||
nzErrorType_Warning,
|
||||
|
||||
nzErrorType_Max = nzErrorType_Warning
|
||||
};
|
||||
|
||||
#endif // NAZARA_ENUMS_CORE_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_ENUMS_CORE_HPP
|
||||
#define NAZARA_ENUMS_CORE_HPP
|
||||
|
||||
enum nzEndianness
|
||||
{
|
||||
nzEndianness_Unknown = -1,
|
||||
|
||||
nzEndianness_BigEndian,
|
||||
nzEndianness_LittleEndian,
|
||||
|
||||
nzEndianness_Max = nzEndianness_LittleEndian
|
||||
};
|
||||
|
||||
enum nzErrorType
|
||||
{
|
||||
nzErrorType_AssertFailed,
|
||||
nzErrorType_Internal,
|
||||
nzErrorType_Normal,
|
||||
nzErrorType_Warning,
|
||||
|
||||
nzErrorType_Max = nzErrorType_Warning
|
||||
};
|
||||
|
||||
#endif // NAZARA_ENUMS_CORE_HPP
|
||||
|
||||
@@ -1,124 +1,124 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_FILE_HPP
|
||||
#define NAZARA_FILE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Directory.hpp>
|
||||
#include <Nazara/Core/Endianness.hpp>
|
||||
#include <Nazara/Core/Hashable.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_FILE
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#else
|
||||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
class NzFileImpl;
|
||||
|
||||
class NAZARA_API NzFile : public NzHashable, public NzInputStream, NzNonCopyable
|
||||
{
|
||||
public:
|
||||
enum CursorPosition
|
||||
{
|
||||
AtBegin, // Début du fichier
|
||||
AtCurrent, // Position du pointeur
|
||||
AtEnd // Fin du fichier
|
||||
};
|
||||
|
||||
enum OpenMode
|
||||
{
|
||||
Current = 0x00, // Utilise le mode d'ouverture actuel
|
||||
|
||||
Append = 0x01, // Empêche l'écriture sur la partie déjà existante et met le curseur à la fin
|
||||
Lock = 0x02, // Empêche le fichier d'être modifié tant qu'il est ouvert
|
||||
ReadOnly = 0x04, // Ouvre uniquement en lecture
|
||||
ReadWrite = 0x08, // Ouvre en lecture/écriture
|
||||
Text = 0x10, // Ouvre en mode texte
|
||||
Truncate = 0x20, // Créé le fichier s'il n'existe pas et le vide s'il existe
|
||||
WriteOnly = 0x40 // Ouvre uniquement en écriture, créé le fichier s'il n'existe pas
|
||||
};
|
||||
|
||||
NzFile();
|
||||
NzFile(const NzString& filePath);
|
||||
NzFile(const NzString& filePath, unsigned long openMode);
|
||||
NzFile(NzFile&& file) noexcept;
|
||||
~NzFile();
|
||||
|
||||
bool Copy(const NzString& newFilePath);
|
||||
void Close();
|
||||
|
||||
bool Delete();
|
||||
|
||||
bool EndOfFile() const;
|
||||
bool EndOfStream() const;
|
||||
|
||||
bool Exists() const;
|
||||
|
||||
void Flush();
|
||||
|
||||
time_t GetCreationTime() const;
|
||||
nzUInt64 GetCursorPos() const;
|
||||
NzString GetDirectoryPath() const;
|
||||
NzString GetFilePath() const;
|
||||
NzString GetFileName() const;
|
||||
time_t GetLastAccessTime() const;
|
||||
time_t GetLastWriteTime() const;
|
||||
NzString GetLine(unsigned int lineSize = 0) override;
|
||||
nzUInt64 GetSize() const;
|
||||
|
||||
bool IsOpen() const;
|
||||
|
||||
bool Open(unsigned long openMode = Current);
|
||||
|
||||
std::size_t Read(void* buffer, std::size_t size);
|
||||
std::size_t Read(void* buffer, std::size_t typeSize, unsigned int count);
|
||||
bool Rename(const NzString& newFilePath);
|
||||
|
||||
bool SetCursorPos(CursorPosition pos, nzInt64 offset = 0);
|
||||
bool SetCursorPos(nzUInt64 offset);
|
||||
void SetEndianness(nzEndianness endianness);
|
||||
bool SetFile(const NzString& filePath);
|
||||
bool SetOpenMode(unsigned int openMode);
|
||||
|
||||
bool Write(const NzString& string);
|
||||
std::size_t Write(const void* buffer, std::size_t typeSize, unsigned int count);
|
||||
|
||||
NzFile& operator=(const NzString& filePath);
|
||||
NzFile& operator=(NzFile&& file) noexcept;
|
||||
|
||||
static NzString AbsolutePath(const NzString& filePath);
|
||||
static bool Copy(const NzString& sourcePath, const NzString& targetPath);
|
||||
static bool Delete(const NzString& filePath);
|
||||
static bool Exists(const NzString& filePath);
|
||||
static time_t GetCreationTime(const NzString& filePath);
|
||||
static time_t GetLastAccessTime(const NzString& filePath);
|
||||
static time_t GetLastWriteTime(const NzString& filePath);
|
||||
static NzHashDigest GetHash(const NzString& filePath, nzHash hash);
|
||||
static NzHashDigest GetHash(const NzString& filePath, NzHashImpl* hash);
|
||||
static nzUInt64 GetSize(const NzString& filePath);
|
||||
static bool IsAbsolute(const NzString& path);
|
||||
static NzString NormalizePath(const NzString& filePath);
|
||||
static NzString NormalizeSeparators(const NzString& filePath);
|
||||
static bool Rename(const NzString& sourcePath, const NzString& targetPath);
|
||||
|
||||
private:
|
||||
bool FillHash(NzHashImpl* hash) const;
|
||||
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
nzEndianness m_endianness;
|
||||
NzString m_filePath;
|
||||
NzFileImpl* m_impl;
|
||||
unsigned int m_openMode;
|
||||
};
|
||||
|
||||
#endif // NAZARA_FILE_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_FILE_HPP
|
||||
#define NAZARA_FILE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Directory.hpp>
|
||||
#include <Nazara/Core/Endianness.hpp>
|
||||
#include <Nazara/Core/Hashable.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_FILE
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#else
|
||||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
class NzFileImpl;
|
||||
|
||||
class NAZARA_API NzFile : public NzHashable, public NzInputStream, NzNonCopyable
|
||||
{
|
||||
public:
|
||||
enum CursorPosition
|
||||
{
|
||||
AtBegin, // Début du fichier
|
||||
AtCurrent, // Position du pointeur
|
||||
AtEnd // Fin du fichier
|
||||
};
|
||||
|
||||
enum OpenMode
|
||||
{
|
||||
Current = 0x00, // Utilise le mode d'ouverture actuel
|
||||
|
||||
Append = 0x01, // Empêche l'écriture sur la partie déjà existante et met le curseur à la fin
|
||||
Lock = 0x02, // Empêche le fichier d'être modifié tant qu'il est ouvert
|
||||
ReadOnly = 0x04, // Ouvre uniquement en lecture
|
||||
ReadWrite = 0x08, // Ouvre en lecture/écriture
|
||||
Text = 0x10, // Ouvre en mode texte
|
||||
Truncate = 0x20, // Créé le fichier s'il n'existe pas et le vide s'il existe
|
||||
WriteOnly = 0x40 // Ouvre uniquement en écriture, créé le fichier s'il n'existe pas
|
||||
};
|
||||
|
||||
NzFile();
|
||||
NzFile(const NzString& filePath);
|
||||
NzFile(const NzString& filePath, unsigned long openMode);
|
||||
NzFile(NzFile&& file) noexcept;
|
||||
~NzFile();
|
||||
|
||||
bool Copy(const NzString& newFilePath);
|
||||
void Close();
|
||||
|
||||
bool Delete();
|
||||
|
||||
bool EndOfFile() const;
|
||||
bool EndOfStream() const;
|
||||
|
||||
bool Exists() const;
|
||||
|
||||
void Flush();
|
||||
|
||||
time_t GetCreationTime() const;
|
||||
nzUInt64 GetCursorPos() const;
|
||||
NzString GetDirectoryPath() const;
|
||||
NzString GetFilePath() const;
|
||||
NzString GetFileName() const;
|
||||
time_t GetLastAccessTime() const;
|
||||
time_t GetLastWriteTime() const;
|
||||
NzString GetLine(unsigned int lineSize = 0) override;
|
||||
nzUInt64 GetSize() const;
|
||||
|
||||
bool IsOpen() const;
|
||||
|
||||
bool Open(unsigned long openMode = Current);
|
||||
|
||||
std::size_t Read(void* buffer, std::size_t size);
|
||||
std::size_t Read(void* buffer, std::size_t typeSize, unsigned int count);
|
||||
bool Rename(const NzString& newFilePath);
|
||||
|
||||
bool SetCursorPos(CursorPosition pos, nzInt64 offset = 0);
|
||||
bool SetCursorPos(nzUInt64 offset);
|
||||
void SetEndianness(nzEndianness endianness);
|
||||
bool SetFile(const NzString& filePath);
|
||||
bool SetOpenMode(unsigned int openMode);
|
||||
|
||||
bool Write(const NzString& string);
|
||||
std::size_t Write(const void* buffer, std::size_t typeSize, unsigned int count);
|
||||
|
||||
NzFile& operator=(const NzString& filePath);
|
||||
NzFile& operator=(NzFile&& file) noexcept;
|
||||
|
||||
static NzString AbsolutePath(const NzString& filePath);
|
||||
static bool Copy(const NzString& sourcePath, const NzString& targetPath);
|
||||
static bool Delete(const NzString& filePath);
|
||||
static bool Exists(const NzString& filePath);
|
||||
static time_t GetCreationTime(const NzString& filePath);
|
||||
static time_t GetLastAccessTime(const NzString& filePath);
|
||||
static time_t GetLastWriteTime(const NzString& filePath);
|
||||
static NzHashDigest GetHash(const NzString& filePath, nzHash hash);
|
||||
static NzHashDigest GetHash(const NzString& filePath, NzHashImpl* hash);
|
||||
static nzUInt64 GetSize(const NzString& filePath);
|
||||
static bool IsAbsolute(const NzString& path);
|
||||
static NzString NormalizePath(const NzString& filePath);
|
||||
static NzString NormalizeSeparators(const NzString& filePath);
|
||||
static bool Rename(const NzString& sourcePath, const NzString& targetPath);
|
||||
|
||||
private:
|
||||
bool FillHash(NzHashImpl* hash) const;
|
||||
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
nzEndianness m_endianness;
|
||||
NzString m_filePath;
|
||||
NzFileImpl* m_impl;
|
||||
unsigned int m_openMode;
|
||||
};
|
||||
|
||||
#endif // NAZARA_FILE_HPP
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_INPUTSTREAM_HPP
|
||||
#define NAZARA_INPUTSTREAM_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
class NzString;
|
||||
|
||||
class NzInputStream
|
||||
{
|
||||
public:
|
||||
virtual ~NzInputStream();
|
||||
|
||||
virtual bool EndOfStream() const = 0;
|
||||
|
||||
virtual nzUInt64 GetCursorPos() const = 0;
|
||||
virtual NzString GetLine(unsigned int lineSize = 0);
|
||||
virtual nzUInt64 GetSize() const = 0;
|
||||
|
||||
virtual std::size_t Read(void* buffer, std::size_t size) = 0;
|
||||
|
||||
virtual bool SetCursorPos(nzUInt64 offset) = 0;
|
||||
};
|
||||
|
||||
#endif // NAZARA_INPUTSTREAM_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_INPUTSTREAM_HPP
|
||||
#define NAZARA_INPUTSTREAM_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
class NzString;
|
||||
|
||||
class NzInputStream
|
||||
{
|
||||
public:
|
||||
virtual ~NzInputStream();
|
||||
|
||||
virtual bool EndOfStream() const = 0;
|
||||
|
||||
virtual nzUInt64 GetCursorPos() const = 0;
|
||||
virtual NzString GetLine(unsigned int lineSize = 0);
|
||||
virtual nzUInt64 GetSize() const = 0;
|
||||
|
||||
virtual std::size_t Read(void* buffer, std::size_t size) = 0;
|
||||
|
||||
virtual bool SetCursorPos(nzUInt64 offset) = 0;
|
||||
};
|
||||
|
||||
#endif // NAZARA_INPUTSTREAM_HPP
|
||||
|
||||
@@ -1,72 +1,72 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RESOURCE_HPP
|
||||
#define NAZARA_RESOURCE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <set>
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_RESOURCE
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#else
|
||||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
class NzResourceListener;
|
||||
|
||||
struct NzResourceEntry
|
||||
{
|
||||
NzResourceEntry(NzResourceListener* resourceListener, int i = 0) :
|
||||
listener(resourceListener),
|
||||
index(i)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator<(const NzResourceEntry& rhs) const
|
||||
{
|
||||
return listener < rhs.listener;
|
||||
}
|
||||
|
||||
NzResourceListener* listener;
|
||||
int index;
|
||||
};
|
||||
|
||||
class NAZARA_API NzResource
|
||||
{
|
||||
public:
|
||||
NzResource(bool persistent = true);
|
||||
NzResource(const NzResource& resource);
|
||||
virtual ~NzResource();
|
||||
|
||||
void AddResourceListener(NzResourceListener* listener, int index = 0) const;
|
||||
void AddResourceReference() const;
|
||||
|
||||
bool IsPersistent() const;
|
||||
|
||||
void RemoveResourceListener(NzResourceListener* listener) const;
|
||||
void RemoveResourceReference() const;
|
||||
|
||||
void SetPersistent(bool persistent = true);
|
||||
|
||||
protected:
|
||||
void NotifyCreated();
|
||||
void NotifyDestroy();
|
||||
|
||||
private:
|
||||
void EnsureResourceListenerUpdate() const;
|
||||
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
// Je fais précéder le nom par 'resource' pour éviter les éventuels conflits de noms
|
||||
mutable std::set<NzResourceEntry> m_resourceListeners;
|
||||
mutable std::set<NzResourceEntry> m_resourceListenersCache;
|
||||
mutable bool m_resourceListenerUpdated;
|
||||
bool m_resourcePersistent;
|
||||
mutable unsigned int m_resourceReferenceCount;
|
||||
};
|
||||
|
||||
#endif // NAZARA_RESOURCE_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RESOURCE_HPP
|
||||
#define NAZARA_RESOURCE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <set>
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_RESOURCE
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#else
|
||||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
class NzResourceListener;
|
||||
|
||||
struct NzResourceEntry
|
||||
{
|
||||
NzResourceEntry(NzResourceListener* resourceListener, int i = 0) :
|
||||
listener(resourceListener),
|
||||
index(i)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator<(const NzResourceEntry& rhs) const
|
||||
{
|
||||
return listener < rhs.listener;
|
||||
}
|
||||
|
||||
NzResourceListener* listener;
|
||||
int index;
|
||||
};
|
||||
|
||||
class NAZARA_API NzResource
|
||||
{
|
||||
public:
|
||||
NzResource(bool persistent = true);
|
||||
NzResource(const NzResource& resource);
|
||||
virtual ~NzResource();
|
||||
|
||||
void AddResourceListener(NzResourceListener* listener, int index = 0) const;
|
||||
void AddResourceReference() const;
|
||||
|
||||
bool IsPersistent() const;
|
||||
|
||||
void RemoveResourceListener(NzResourceListener* listener) const;
|
||||
void RemoveResourceReference() const;
|
||||
|
||||
void SetPersistent(bool persistent = true);
|
||||
|
||||
protected:
|
||||
void NotifyCreated();
|
||||
void NotifyDestroy();
|
||||
|
||||
private:
|
||||
void EnsureResourceListenerUpdate() const;
|
||||
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
// Je fais précéder le nom par 'resource' pour éviter les éventuels conflits de noms
|
||||
mutable std::set<NzResourceEntry> m_resourceListeners;
|
||||
mutable std::set<NzResourceEntry> m_resourceListenersCache;
|
||||
mutable bool m_resourceListenerUpdated;
|
||||
bool m_resourcePersistent;
|
||||
mutable unsigned int m_resourceReferenceCount;
|
||||
};
|
||||
|
||||
#endif // NAZARA_RESOURCE_HPP
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RESOURCELISTENER_HPP
|
||||
#define NAZARA_RESOURCELISTENER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
class NzResource;
|
||||
|
||||
class NAZARA_API NzResourceListener
|
||||
{
|
||||
public:
|
||||
NzResourceListener() = default;
|
||||
virtual ~NzResourceListener();
|
||||
|
||||
virtual void OnResourceCreated(const NzResource* resource, int index);
|
||||
virtual void OnResourceDestroy(const NzResource* resource, int index);
|
||||
virtual void OnResourceReleased(const NzResource* resource, int index);
|
||||
};
|
||||
|
||||
#endif // NAZARA_RESOURCELISTENER_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RESOURCELISTENER_HPP
|
||||
#define NAZARA_RESOURCELISTENER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
class NzResource;
|
||||
|
||||
class NAZARA_API NzResourceListener
|
||||
{
|
||||
public:
|
||||
NzResourceListener() = default;
|
||||
virtual ~NzResourceListener();
|
||||
|
||||
virtual void OnResourceCreated(const NzResource* resource, int index);
|
||||
virtual void OnResourceDestroy(const NzResource* resource, int index);
|
||||
virtual void OnResourceReleased(const NzResource* resource, int index);
|
||||
};
|
||||
|
||||
#endif // NAZARA_RESOURCELISTENER_HPP
|
||||
|
||||
@@ -1,142 +1,142 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Config.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/File.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/MemoryStream.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
bool NzResourceLoader<Type, Parameters>::LoadFromFile(Type* resource, const NzString& filePath, const Parameters& parameters)
|
||||
{
|
||||
#if NAZARA_CORE_SAFE
|
||||
if (!parameters.IsValid())
|
||||
{
|
||||
NazaraError("Invalid parameters");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
NzString path = NzFile::NormalizePath(filePath);
|
||||
NzString ext = path.SubstrFrom('.', -1, true);
|
||||
if (ext.IsEmpty())
|
||||
{
|
||||
NazaraError("Failed to get file extension");
|
||||
return false;
|
||||
}
|
||||
|
||||
NzFile file(path, NzFile::ReadOnly);
|
||||
if (!file.IsOpen())
|
||||
{
|
||||
NazaraError("Failed to open file");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto loader = Type::s_loaders.begin(); loader != Type::s_loaders.end(); ++loader)
|
||||
{
|
||||
for (const NzString& loaderExt : std::get<0>(*loader))
|
||||
{
|
||||
int cmp = NzString::Compare(loaderExt, ext);
|
||||
if (cmp == 0)
|
||||
{
|
||||
if (!std::get<1>(*loader)(file, parameters))
|
||||
continue;
|
||||
|
||||
file.SetCursorPos(0);
|
||||
|
||||
// Chargement de la ressource
|
||||
if (std::get<2>(*loader)(resource, file, parameters))
|
||||
return true;
|
||||
|
||||
NazaraWarning("Loader failed");
|
||||
|
||||
file.SetCursorPos(0);
|
||||
}
|
||||
else if (cmp < 0) // S'il est encore possible que l'extension se situe après
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NazaraError("Failed to load file: no loader");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
bool NzResourceLoader<Type, Parameters>::LoadFromMemory(Type* resource, const void* data, unsigned int size, const Parameters& parameters)
|
||||
{
|
||||
NzMemoryStream stream(data, size);
|
||||
|
||||
return LoadFromStream(resource, stream, parameters);
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
bool NzResourceLoader<Type, Parameters>::LoadFromStream(Type* resource, NzInputStream& stream, const Parameters& parameters)
|
||||
{
|
||||
#if NAZARA_CORE_SAFE
|
||||
if (!parameters.IsValid())
|
||||
{
|
||||
NazaraError("Invalid parameters");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (stream.GetSize() == 0 || stream.GetCursorPos() >= stream.GetSize())
|
||||
{
|
||||
NazaraError("No data to load");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
nzUInt64 streamPos = stream.GetCursorPos();
|
||||
for (auto loader = Type::s_loaders.begin(); loader != Type::s_loaders.end(); ++loader)
|
||||
{
|
||||
// Le loader supporte-t-il les données ?
|
||||
if (!std::get<1>(*loader)(stream, parameters))
|
||||
continue;
|
||||
|
||||
// On repositionne le stream au début
|
||||
stream.SetCursorPos(streamPos);
|
||||
|
||||
// Chargement de la ressource
|
||||
if (std::get<2>(*loader)(resource, stream, parameters))
|
||||
return true;
|
||||
|
||||
NazaraWarning("Loader failed");
|
||||
stream.SetCursorPos(streamPos); // On repositionne au début
|
||||
}
|
||||
|
||||
NazaraError("Failed to load file: no loader");
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
void NzResourceLoader<Type, Parameters>::RegisterLoader(const NzString& fileExtensions, CheckFunction checkFunc, LoadFunction loadFunc)
|
||||
{
|
||||
///FIXME: Trouver une alternative à ce code monstrueux
|
||||
std::vector<NzString> exts;
|
||||
fileExtensions.SplitAny(exts, " /\\.,;|-_");
|
||||
|
||||
std::set<NzString> extensions;
|
||||
std::copy(exts.begin(), exts.end(), std::inserter(extensions, extensions.begin()));
|
||||
|
||||
Type::s_loaders.insert(std::make_tuple(std::move(extensions), checkFunc, loadFunc));
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
void NzResourceLoader<Type, Parameters>::UnregisterLoader(const NzString& fileExtensions, CheckFunction checkFunc, LoadFunction loadFunc)
|
||||
{
|
||||
std::vector<NzString> exts;
|
||||
fileExtensions.SplitAny(exts, " /\\.,;|-_");
|
||||
|
||||
std::set<NzString> extensions;
|
||||
std::copy(exts.begin(), exts.end(), std::inserter(extensions, extensions.begin()));
|
||||
|
||||
Type::s_loaders.erase(std::make_tuple(std::move(extensions), checkFunc, loadFunc));
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Config.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/File.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/MemoryStream.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
bool NzResourceLoader<Type, Parameters>::LoadFromFile(Type* resource, const NzString& filePath, const Parameters& parameters)
|
||||
{
|
||||
#if NAZARA_CORE_SAFE
|
||||
if (!parameters.IsValid())
|
||||
{
|
||||
NazaraError("Invalid parameters");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
NzString path = NzFile::NormalizePath(filePath);
|
||||
NzString ext = path.SubstrFrom('.', -1, true);
|
||||
if (ext.IsEmpty())
|
||||
{
|
||||
NazaraError("Failed to get file extension");
|
||||
return false;
|
||||
}
|
||||
|
||||
NzFile file(path, NzFile::ReadOnly);
|
||||
if (!file.IsOpen())
|
||||
{
|
||||
NazaraError("Failed to open file");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto loader = Type::s_loaders.begin(); loader != Type::s_loaders.end(); ++loader)
|
||||
{
|
||||
for (const NzString& loaderExt : std::get<0>(*loader))
|
||||
{
|
||||
int cmp = NzString::Compare(loaderExt, ext);
|
||||
if (cmp == 0)
|
||||
{
|
||||
if (!std::get<1>(*loader)(file, parameters))
|
||||
continue;
|
||||
|
||||
file.SetCursorPos(0);
|
||||
|
||||
// Chargement de la ressource
|
||||
if (std::get<2>(*loader)(resource, file, parameters))
|
||||
return true;
|
||||
|
||||
NazaraWarning("Loader failed");
|
||||
|
||||
file.SetCursorPos(0);
|
||||
}
|
||||
else if (cmp < 0) // S'il est encore possible que l'extension se situe après
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NazaraError("Failed to load file: no loader");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
bool NzResourceLoader<Type, Parameters>::LoadFromMemory(Type* resource, const void* data, unsigned int size, const Parameters& parameters)
|
||||
{
|
||||
NzMemoryStream stream(data, size);
|
||||
|
||||
return LoadFromStream(resource, stream, parameters);
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
bool NzResourceLoader<Type, Parameters>::LoadFromStream(Type* resource, NzInputStream& stream, const Parameters& parameters)
|
||||
{
|
||||
#if NAZARA_CORE_SAFE
|
||||
if (!parameters.IsValid())
|
||||
{
|
||||
NazaraError("Invalid parameters");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (stream.GetSize() == 0 || stream.GetCursorPos() >= stream.GetSize())
|
||||
{
|
||||
NazaraError("No data to load");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
nzUInt64 streamPos = stream.GetCursorPos();
|
||||
for (auto loader = Type::s_loaders.begin(); loader != Type::s_loaders.end(); ++loader)
|
||||
{
|
||||
// Le loader supporte-t-il les données ?
|
||||
if (!std::get<1>(*loader)(stream, parameters))
|
||||
continue;
|
||||
|
||||
// On repositionne le stream au début
|
||||
stream.SetCursorPos(streamPos);
|
||||
|
||||
// Chargement de la ressource
|
||||
if (std::get<2>(*loader)(resource, stream, parameters))
|
||||
return true;
|
||||
|
||||
NazaraWarning("Loader failed");
|
||||
stream.SetCursorPos(streamPos); // On repositionne au début
|
||||
}
|
||||
|
||||
NazaraError("Failed to load file: no loader");
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
void NzResourceLoader<Type, Parameters>::RegisterLoader(const NzString& fileExtensions, CheckFunction checkFunc, LoadFunction loadFunc)
|
||||
{
|
||||
///FIXME: Trouver une alternative à ce code monstrueux
|
||||
std::vector<NzString> exts;
|
||||
fileExtensions.SplitAny(exts, " /\\.,;|-_");
|
||||
|
||||
std::set<NzString> extensions;
|
||||
std::copy(exts.begin(), exts.end(), std::inserter(extensions, extensions.begin()));
|
||||
|
||||
Type::s_loaders.insert(std::make_tuple(std::move(extensions), checkFunc, loadFunc));
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
void NzResourceLoader<Type, Parameters>::UnregisterLoader(const NzString& fileExtensions, CheckFunction checkFunc, LoadFunction loadFunc)
|
||||
{
|
||||
std::vector<NzString> exts;
|
||||
fileExtensions.SplitAny(exts, " /\\.,;|-_");
|
||||
|
||||
std::set<NzString> extensions;
|
||||
std::copy(exts.begin(), exts.end(), std::inserter(extensions, extensions.begin()));
|
||||
|
||||
Type::s_loaders.erase(std::make_tuple(std::move(extensions), checkFunc, loadFunc));
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
||||
@@ -1,321 +1,320 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_STRING_HPP
|
||||
#define NAZARA_STRING_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Hashable.hpp>
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_STRING
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#else
|
||||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
class NzAbstractHash;
|
||||
class NzHashDigest;
|
||||
|
||||
class NAZARA_API NzString : public NzHashable
|
||||
{
|
||||
public:
|
||||
enum Flags
|
||||
{
|
||||
None = 0x00, // Mode par défaut
|
||||
CaseInsensitive = 0x01, // Insensible à la casse
|
||||
HandleUtf8 = 0x02, // Traite les octets comme une suite de caractères UTF-8
|
||||
TrimOnlyLeft = 0x04, // Trim(med), ne coupe que la partie gauche de la chaîne
|
||||
TrimOnlyRight = 0x08 // Trim(med), ne coupe que la partie droite de la chaîne
|
||||
};
|
||||
|
||||
struct SharedString;
|
||||
|
||||
NzString();
|
||||
NzString(char character);
|
||||
NzString(const char* string);
|
||||
NzString(const std::string& string);
|
||||
NzString(const NzString& string);
|
||||
NzString(NzString&& string) noexcept;
|
||||
NzString(SharedString* sharedString);
|
||||
~NzString();
|
||||
|
||||
NzString& Append(char character);
|
||||
NzString& Append(const char* string);
|
||||
NzString& Append(const NzString& string);
|
||||
|
||||
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;
|
||||
bool Contains(const NzString& string, int start = 0, nzUInt32 flags = None) const;
|
||||
|
||||
unsigned int Count(char character, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Count(const char* string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Count(const NzString& string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int CountAny(const char* string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int CountAny(const NzString& string, int start = 0, nzUInt32 flags = None) const;
|
||||
|
||||
bool EndsWith(char character, nzUInt32 flags = None) const;
|
||||
bool EndsWith(const char* string, nzUInt32 flags = None) const;
|
||||
bool EndsWith(const NzString& string, nzUInt32 flags = None) const;
|
||||
|
||||
unsigned int Find(char character, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Find(const char* string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Find(const NzString& string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int FindAny(const char* string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int FindAny(const NzString& string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int FindLast(char character, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindLast(const char *string, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindLast(const NzString& string, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindLastAny(const char* string, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindLastAny(const NzString& string, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindLastWord(const char* string, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindLastWord(const NzString& string, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindWord(const char* string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int FindWord(const NzString& string, int start = 0, nzUInt32 flags = None) const;
|
||||
|
||||
char* GetBuffer();
|
||||
unsigned int GetCapacity() const;
|
||||
const char* GetConstBuffer() const;
|
||||
unsigned int GetLength() const;
|
||||
unsigned int GetSize() const;
|
||||
char* GetUtf8Buffer(unsigned int* size = nullptr) const;
|
||||
char16_t* GetUtf16Buffer(unsigned int* size = nullptr) const;
|
||||
char32_t* GetUtf32Buffer(unsigned int* size = nullptr) const;
|
||||
wchar_t* GetWideBuffer(unsigned int* size = nullptr) const;
|
||||
|
||||
NzString GetWord(unsigned int index, nzUInt32 flags = None) const;
|
||||
unsigned int GetWordPosition(unsigned int index, nzUInt32 flags = None) const;
|
||||
|
||||
NzString& Insert(int pos, char character);
|
||||
NzString& Insert(int pos, const char* string);
|
||||
NzString& Insert(int pos, const NzString& string);
|
||||
|
||||
bool IsEmpty() const;
|
||||
bool IsNull() const;
|
||||
bool IsNumber(nzUInt8 radix = 10, nzUInt32 flags = CaseInsensitive) const;
|
||||
|
||||
bool Match(const char* pattern) const;
|
||||
bool Match(const NzString& pattern) const;
|
||||
|
||||
NzString& Prepend(char character);
|
||||
NzString& Prepend(const char* string);
|
||||
NzString& Prepend(const NzString& string);
|
||||
|
||||
unsigned int Replace(char oldCharacter, char newCharacter, int start = 0, nzUInt32 flags = None);
|
||||
unsigned int Replace(const char* oldString, const char* replaceString, int start = 0, nzUInt32 flags = None);
|
||||
unsigned int Replace(const NzString& oldString, const NzString& replaceString, int start = 0, nzUInt32 flags = None);
|
||||
unsigned int ReplaceAny(const char* oldCharacters, char replaceCharacter, int start = 0, nzUInt32 flags = None);
|
||||
//unsigned int ReplaceAny(const char* oldCharacters, const char* replaceString, int start = 0, nzUInt32 flags = None);
|
||||
//unsigned int ReplaceAny(const NzString& oldCharacters, const NzString& replaceString, int start = 0, nzUInt32 flags = None);
|
||||
|
||||
void Reserve(unsigned int bufferSize);
|
||||
|
||||
NzString& Resize(int size, char character = ' ');
|
||||
NzString Resized(int size, char character = ' ') const;
|
||||
|
||||
NzString& Reverse();
|
||||
NzString Reversed() const;
|
||||
|
||||
NzString Simplified(nzUInt32 flags = None) const;
|
||||
NzString& Simplify(nzUInt32 flags = None);
|
||||
|
||||
unsigned int Split(std::vector<NzString>& result, char separation = ' ', int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Split(std::vector<NzString>& result, const char* separation, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Split(std::vector<NzString>& result, const NzString& separation, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int SplitAny(std::vector<NzString>& result, const char* separations, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int SplitAny(std::vector<NzString>& result, const NzString& separations, int start = 0, nzUInt32 flags = None) const;
|
||||
|
||||
bool StartsWith(char character, nzUInt32 flags = None) const;
|
||||
bool StartsWith(const char* string, nzUInt32 flags = None) const;
|
||||
bool StartsWith(const NzString& string, nzUInt32 flags = None) const;
|
||||
|
||||
NzString Substr(int startPos, int endPos = -1) const;
|
||||
NzString SubstrFrom(char character, int startPos = 0, bool fromLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrFrom(const char *string, int startPos = 0, bool fromLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrFrom(const NzString& string, int startPos = 0, bool fromLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrTo(char character, int startPos = 0, bool toLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrTo(const char *string, int startPos = 0, bool toLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrTo(const NzString& string, int startPos = 0, bool toLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
|
||||
void Swap(NzString& str);
|
||||
|
||||
bool ToBool(bool* value, nzUInt32 flags = None) const;
|
||||
bool ToDouble(double* value) const;
|
||||
bool ToInteger(long long* value, nzUInt8 radix = 10) const;
|
||||
NzString ToLower(nzUInt32 flags = None) const;
|
||||
NzString ToUpper(nzUInt32 flags = None) const;
|
||||
|
||||
NzString& Trim(nzUInt32 flags = None);
|
||||
NzString& Trim(char character, nzUInt32 flags = None);
|
||||
NzString Trimmed(nzUInt32 flags = None) const;
|
||||
NzString Trimmed(char character, nzUInt32 flags = None) const;
|
||||
|
||||
// Méthodes STD
|
||||
char* begin();
|
||||
const char* begin() const;
|
||||
char* end();
|
||||
const char* end() const;
|
||||
void push_front(char c);
|
||||
void push_back(char c);
|
||||
/*char* rbegin();
|
||||
const char* rbegin() const;
|
||||
char* rend();
|
||||
const char* rend() const;*/
|
||||
|
||||
typedef const char& const_reference;
|
||||
typedef char* iterator;
|
||||
//typedef char* reverse_iterator;
|
||||
typedef char value_type;
|
||||
// Méthodes STD
|
||||
|
||||
operator std::string() const;
|
||||
|
||||
char& operator[](unsigned int pos);
|
||||
char operator[](unsigned int pos) const;
|
||||
|
||||
NzString& operator=(char character);
|
||||
NzString& operator=(const char* string);
|
||||
NzString& operator=(const std::string& string);
|
||||
NzString& operator=(const NzString& string);
|
||||
NzString& operator=(NzString&& string) noexcept;
|
||||
|
||||
NzString operator+(char character) const;
|
||||
NzString operator+(const char* string) const;
|
||||
NzString operator+(const std::string& string) const;
|
||||
NzString operator+(const NzString& string) const;
|
||||
|
||||
NzString& operator+=(char character);
|
||||
NzString& operator+=(const char* string);
|
||||
NzString& operator+=(const std::string& string);
|
||||
NzString& operator+=(const NzString& string);
|
||||
|
||||
bool operator==(char character) const;
|
||||
bool operator==(const char* string) const;
|
||||
bool operator==(const std::string& string) const;
|
||||
|
||||
bool operator!=(char character) const;
|
||||
bool operator!=(const char* string) const;
|
||||
bool operator!=(const std::string& string) const;
|
||||
|
||||
bool operator<(char character) const;
|
||||
bool operator<(const char* string) const;
|
||||
bool operator<(const std::string& string) const;
|
||||
|
||||
bool operator<=(char character) const;
|
||||
bool operator<=(const char* string) const;
|
||||
bool operator<=(const std::string& string) const;
|
||||
|
||||
bool operator>(char character) const;
|
||||
bool operator>(const char* string) const;
|
||||
bool operator>(const std::string& string) const;
|
||||
|
||||
bool operator>=(char character) const;
|
||||
bool operator>=(const char* string) const;
|
||||
bool operator>=(const std::string& string) const;
|
||||
|
||||
static NzString Boolean(bool boolean);
|
||||
static int Compare(const NzString& first, const NzString& second);
|
||||
static NzString Number(float number);
|
||||
static NzString Number(double number);
|
||||
static NzString Number(long double number);
|
||||
static NzString Number(signed char number, nzUInt8 radix = 10);
|
||||
static NzString Number(unsigned char number, nzUInt8 radix = 10);
|
||||
static NzString Number(short number, nzUInt8 radix = 10);
|
||||
static NzString Number(unsigned short number, nzUInt8 radix = 10);
|
||||
static NzString Number(int number, nzUInt8 radix = 10);
|
||||
static NzString Number(unsigned int number, nzUInt8 radix = 10);
|
||||
static NzString Number(long number, nzUInt8 radix = 10);
|
||||
static NzString Number(unsigned long number, nzUInt8 radix = 10);
|
||||
static NzString Number(long long number, nzUInt8 radix = 10);
|
||||
static NzString Number(unsigned long long number, nzUInt8 radix = 10);
|
||||
static NzString Pointer(const void* ptr);
|
||||
static NzString Unicode(char32_t character);
|
||||
static NzString Unicode(const char* u8String);
|
||||
static NzString Unicode(const char16_t* u16String);
|
||||
static NzString Unicode(const char32_t* u32String);
|
||||
static NzString Unicode(const wchar_t* wString);
|
||||
|
||||
NAZARA_API friend std::istream& operator>>(std::istream& in, NzString& string);
|
||||
NAZARA_API friend std::ostream& operator<<(std::ostream& out, const NzString& string);
|
||||
|
||||
NAZARA_API friend NzString operator+(char character, const NzString& string);
|
||||
NAZARA_API friend NzString operator+(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend NzString operator+(const std::string& string, const NzString& nstring);
|
||||
|
||||
NAZARA_API friend bool operator==(const NzString& first, const NzString& second);
|
||||
NAZARA_API friend bool operator!=(const NzString& first, const NzString& second);
|
||||
NAZARA_API friend bool operator<(const NzString& first, const NzString& second);
|
||||
NAZARA_API friend bool operator<=(const NzString& first, const NzString& second);
|
||||
NAZARA_API friend bool operator>(const NzString& first, const NzString& second);
|
||||
NAZARA_API friend bool operator>=(const NzString& first, const NzString& second);
|
||||
|
||||
NAZARA_API friend bool operator==(char character, const NzString& nstring);
|
||||
NAZARA_API friend bool operator==(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend bool operator==(const std::string& string, const NzString& nstring);
|
||||
|
||||
NAZARA_API friend bool operator!=(char character, const NzString& nstring);
|
||||
NAZARA_API friend bool operator!=(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend bool operator!=(const std::string& string, const NzString& nstring);
|
||||
|
||||
NAZARA_API friend bool operator<(char character, const NzString& nstring);
|
||||
NAZARA_API friend bool operator<(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend bool operator<(const std::string& string, const NzString& nstring);
|
||||
|
||||
NAZARA_API friend bool operator<=(char character, const NzString& nstring);
|
||||
NAZARA_API friend bool operator<=(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend bool operator<=(const std::string& string, const NzString& nstring);
|
||||
|
||||
NAZARA_API friend bool operator>(char character, const NzString& nstring);
|
||||
NAZARA_API friend bool operator>(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend bool operator>(const std::string& string, const NzString& nstring);
|
||||
|
||||
NAZARA_API friend bool operator>=(char character, const NzString& nstring);
|
||||
NAZARA_API friend bool operator>=(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend bool operator>=(const std::string& string, const NzString& nstring);
|
||||
|
||||
struct NAZARA_API SharedString
|
||||
{
|
||||
SharedString() = default;
|
||||
|
||||
SharedString(unsigned short referenceCount, unsigned int bufferSize, unsigned int stringSize, char* str) :
|
||||
capacity(bufferSize),
|
||||
size(stringSize),
|
||||
string(str),
|
||||
refCount(referenceCount)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int capacity;
|
||||
unsigned int size;
|
||||
char* string;
|
||||
|
||||
unsigned short refCount = 1;
|
||||
NazaraMutex(mutex)
|
||||
};
|
||||
|
||||
static SharedString emptyString;
|
||||
static const unsigned int npos;
|
||||
|
||||
private:
|
||||
void EnsureOwnership();
|
||||
bool FillHash(NzHashImpl* hash) const;
|
||||
void ReleaseString();
|
||||
|
||||
SharedString* m_sharedString;
|
||||
};
|
||||
|
||||
namespace std
|
||||
{
|
||||
NAZARA_API istream& getline(istream& is, NzString& str);
|
||||
NAZARA_API istream& getline(istream& is, NzString& str, char delim);
|
||||
NAZARA_API void swap(NzString& lhs, NzString& rhs);
|
||||
}
|
||||
|
||||
#endif // NAZARA_STRING_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_STRING_HPP
|
||||
#define NAZARA_STRING_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Hashable.hpp>
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_STRING
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
#else
|
||||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
class NzAbstractHash;
|
||||
class NzHashDigest;
|
||||
|
||||
class NAZARA_API NzString : public NzHashable
|
||||
{
|
||||
public:
|
||||
enum Flags
|
||||
{
|
||||
None = 0x00, // Mode par défaut
|
||||
CaseInsensitive = 0x01, // Insensible à la casse
|
||||
HandleUtf8 = 0x02, // Traite les octets comme une suite de caractères UTF-8
|
||||
TrimOnlyLeft = 0x04, // Trim(med), ne coupe que la partie gauche de la chaîne
|
||||
TrimOnlyRight = 0x08 // Trim(med), ne coupe que la partie droite de la chaîne
|
||||
};
|
||||
|
||||
struct SharedString;
|
||||
|
||||
NzString();
|
||||
NzString(char character);
|
||||
NzString(const char* string);
|
||||
NzString(const std::string& string);
|
||||
NzString(const NzString& string);
|
||||
NzString(NzString&& string) noexcept;
|
||||
NzString(SharedString* sharedString);
|
||||
~NzString();
|
||||
|
||||
NzString& Append(char character);
|
||||
NzString& Append(const char* string);
|
||||
NzString& Append(const NzString& string);
|
||||
|
||||
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;
|
||||
bool Contains(const NzString& string, int start = 0, nzUInt32 flags = None) const;
|
||||
|
||||
unsigned int Count(char character, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Count(const char* string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Count(const NzString& string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int CountAny(const char* string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int CountAny(const NzString& string, int start = 0, nzUInt32 flags = None) const;
|
||||
|
||||
bool EndsWith(char character, nzUInt32 flags = None) const;
|
||||
bool EndsWith(const char* string, nzUInt32 flags = None) const;
|
||||
bool EndsWith(const NzString& string, nzUInt32 flags = None) const;
|
||||
|
||||
unsigned int Find(char character, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Find(const char* string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Find(const NzString& string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int FindAny(const char* string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int FindAny(const NzString& string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int FindLast(char character, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindLast(const char *string, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindLast(const NzString& string, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindLastAny(const char* string, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindLastAny(const NzString& string, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindLastWord(const char* string, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindLastWord(const NzString& string, int start = -1, nzUInt32 flags = None) const;
|
||||
unsigned int FindWord(const char* string, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int FindWord(const NzString& string, int start = 0, nzUInt32 flags = None) const;
|
||||
|
||||
char* GetBuffer();
|
||||
unsigned int GetCapacity() const;
|
||||
const char* GetConstBuffer() const;
|
||||
unsigned int GetLength() const;
|
||||
unsigned int GetSize() const;
|
||||
char* GetUtf8Buffer(unsigned int* size = nullptr) const;
|
||||
char16_t* GetUtf16Buffer(unsigned int* size = nullptr) const;
|
||||
char32_t* GetUtf32Buffer(unsigned int* size = nullptr) const;
|
||||
wchar_t* GetWideBuffer(unsigned int* size = nullptr) const;
|
||||
NzString GetWord(unsigned int index, nzUInt32 flags = None) const;
|
||||
unsigned int GetWordPosition(unsigned int index, nzUInt32 flags = None) const;
|
||||
|
||||
NzString& Insert(int pos, char character);
|
||||
NzString& Insert(int pos, const char* string);
|
||||
NzString& Insert(int pos, const NzString& string);
|
||||
|
||||
bool IsEmpty() const;
|
||||
bool IsNull() const;
|
||||
bool IsNumber(nzUInt8 radix = 10, nzUInt32 flags = CaseInsensitive) const;
|
||||
|
||||
bool Match(const char* pattern) const;
|
||||
bool Match(const NzString& pattern) const;
|
||||
|
||||
NzString& Prepend(char character);
|
||||
NzString& Prepend(const char* string);
|
||||
NzString& Prepend(const NzString& string);
|
||||
|
||||
unsigned int Replace(char oldCharacter, char newCharacter, int start = 0, nzUInt32 flags = None);
|
||||
unsigned int Replace(const char* oldString, const char* replaceString, int start = 0, nzUInt32 flags = None);
|
||||
unsigned int Replace(const NzString& oldString, const NzString& replaceString, int start = 0, nzUInt32 flags = None);
|
||||
unsigned int ReplaceAny(const char* oldCharacters, char replaceCharacter, int start = 0, nzUInt32 flags = None);
|
||||
//unsigned int ReplaceAny(const char* oldCharacters, const char* replaceString, int start = 0, nzUInt32 flags = None);
|
||||
//unsigned int ReplaceAny(const NzString& oldCharacters, const NzString& replaceString, int start = 0, nzUInt32 flags = None);
|
||||
|
||||
void Reserve(unsigned int bufferSize);
|
||||
|
||||
NzString& Resize(int size, char character = ' ');
|
||||
NzString Resized(int size, char character = ' ') const;
|
||||
|
||||
NzString& Reverse();
|
||||
NzString Reversed() const;
|
||||
|
||||
NzString Simplified(nzUInt32 flags = None) const;
|
||||
NzString& Simplify(nzUInt32 flags = None);
|
||||
|
||||
unsigned int Split(std::vector<NzString>& result, char separation = ' ', int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Split(std::vector<NzString>& result, const char* separation, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Split(std::vector<NzString>& result, const NzString& separation, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int SplitAny(std::vector<NzString>& result, const char* separations, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int SplitAny(std::vector<NzString>& result, const NzString& separations, int start = 0, nzUInt32 flags = None) const;
|
||||
|
||||
bool StartsWith(char character, nzUInt32 flags = None) const;
|
||||
bool StartsWith(const char* string, nzUInt32 flags = None) const;
|
||||
bool StartsWith(const NzString& string, nzUInt32 flags = None) const;
|
||||
|
||||
NzString Substr(int startPos, int endPos = -1) const;
|
||||
NzString SubstrFrom(char character, int startPos = 0, bool fromLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrFrom(const char *string, int startPos = 0, bool fromLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrFrom(const NzString& string, int startPos = 0, bool fromLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrTo(char character, int startPos = 0, bool toLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrTo(const char *string, int startPos = 0, bool toLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrTo(const NzString& string, int startPos = 0, bool toLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
|
||||
void Swap(NzString& str);
|
||||
|
||||
bool ToBool(bool* value, nzUInt32 flags = None) const;
|
||||
bool ToDouble(double* value) const;
|
||||
bool ToInteger(long long* value, nzUInt8 radix = 10) const;
|
||||
NzString ToLower(nzUInt32 flags = None) const;
|
||||
NzString ToUpper(nzUInt32 flags = None) const;
|
||||
|
||||
NzString& Trim(nzUInt32 flags = None);
|
||||
NzString& Trim(char character, nzUInt32 flags = None);
|
||||
NzString Trimmed(nzUInt32 flags = None) const;
|
||||
NzString Trimmed(char character, nzUInt32 flags = None) const;
|
||||
|
||||
// Méthodes STD
|
||||
char* begin();
|
||||
const char* begin() const;
|
||||
char* end();
|
||||
const char* end() const;
|
||||
void push_front(char c);
|
||||
void push_back(char c);
|
||||
/*char* rbegin();
|
||||
const char* rbegin() const;
|
||||
char* rend();
|
||||
const char* rend() const;*/
|
||||
|
||||
typedef const char& const_reference;
|
||||
typedef char* iterator;
|
||||
//typedef char* reverse_iterator;
|
||||
typedef char value_type;
|
||||
// Méthodes STD
|
||||
|
||||
operator std::string() const;
|
||||
|
||||
char& operator[](unsigned int pos);
|
||||
char operator[](unsigned int pos) const;
|
||||
|
||||
NzString& operator=(char character);
|
||||
NzString& operator=(const char* string);
|
||||
NzString& operator=(const std::string& string);
|
||||
NzString& operator=(const NzString& string);
|
||||
NzString& operator=(NzString&& string) noexcept;
|
||||
|
||||
NzString operator+(char character) const;
|
||||
NzString operator+(const char* string) const;
|
||||
NzString operator+(const std::string& string) const;
|
||||
NzString operator+(const NzString& string) const;
|
||||
|
||||
NzString& operator+=(char character);
|
||||
NzString& operator+=(const char* string);
|
||||
NzString& operator+=(const std::string& string);
|
||||
NzString& operator+=(const NzString& string);
|
||||
|
||||
bool operator==(char character) const;
|
||||
bool operator==(const char* string) const;
|
||||
bool operator==(const std::string& string) const;
|
||||
|
||||
bool operator!=(char character) const;
|
||||
bool operator!=(const char* string) const;
|
||||
bool operator!=(const std::string& string) const;
|
||||
|
||||
bool operator<(char character) const;
|
||||
bool operator<(const char* string) const;
|
||||
bool operator<(const std::string& string) const;
|
||||
|
||||
bool operator<=(char character) const;
|
||||
bool operator<=(const char* string) const;
|
||||
bool operator<=(const std::string& string) const;
|
||||
|
||||
bool operator>(char character) const;
|
||||
bool operator>(const char* string) const;
|
||||
bool operator>(const std::string& string) const;
|
||||
|
||||
bool operator>=(char character) const;
|
||||
bool operator>=(const char* string) const;
|
||||
bool operator>=(const std::string& string) const;
|
||||
|
||||
static NzString Boolean(bool boolean);
|
||||
static int Compare(const NzString& first, const NzString& second);
|
||||
static NzString Number(float number);
|
||||
static NzString Number(double number);
|
||||
static NzString Number(long double number);
|
||||
static NzString Number(signed char number, nzUInt8 radix = 10);
|
||||
static NzString Number(unsigned char number, nzUInt8 radix = 10);
|
||||
static NzString Number(short number, nzUInt8 radix = 10);
|
||||
static NzString Number(unsigned short number, nzUInt8 radix = 10);
|
||||
static NzString Number(int number, nzUInt8 radix = 10);
|
||||
static NzString Number(unsigned int number, nzUInt8 radix = 10);
|
||||
static NzString Number(long number, nzUInt8 radix = 10);
|
||||
static NzString Number(unsigned long number, nzUInt8 radix = 10);
|
||||
static NzString Number(long long number, nzUInt8 radix = 10);
|
||||
static NzString Number(unsigned long long number, nzUInt8 radix = 10);
|
||||
static NzString Pointer(const void* ptr);
|
||||
static NzString Unicode(char32_t character);
|
||||
static NzString Unicode(const char* u8String);
|
||||
static NzString Unicode(const char16_t* u16String);
|
||||
static NzString Unicode(const char32_t* u32String);
|
||||
static NzString Unicode(const wchar_t* wString);
|
||||
|
||||
NAZARA_API friend std::istream& operator>>(std::istream& in, NzString& string);
|
||||
NAZARA_API friend std::ostream& operator<<(std::ostream& out, const NzString& string);
|
||||
|
||||
NAZARA_API friend NzString operator+(char character, const NzString& string);
|
||||
NAZARA_API friend NzString operator+(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend NzString operator+(const std::string& string, const NzString& nstring);
|
||||
|
||||
NAZARA_API friend bool operator==(const NzString& first, const NzString& second);
|
||||
NAZARA_API friend bool operator!=(const NzString& first, const NzString& second);
|
||||
NAZARA_API friend bool operator<(const NzString& first, const NzString& second);
|
||||
NAZARA_API friend bool operator<=(const NzString& first, const NzString& second);
|
||||
NAZARA_API friend bool operator>(const NzString& first, const NzString& second);
|
||||
NAZARA_API friend bool operator>=(const NzString& first, const NzString& second);
|
||||
|
||||
NAZARA_API friend bool operator==(char character, const NzString& nstring);
|
||||
NAZARA_API friend bool operator==(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend bool operator==(const std::string& string, const NzString& nstring);
|
||||
|
||||
NAZARA_API friend bool operator!=(char character, const NzString& nstring);
|
||||
NAZARA_API friend bool operator!=(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend bool operator!=(const std::string& string, const NzString& nstring);
|
||||
|
||||
NAZARA_API friend bool operator<(char character, const NzString& nstring);
|
||||
NAZARA_API friend bool operator<(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend bool operator<(const std::string& string, const NzString& nstring);
|
||||
|
||||
NAZARA_API friend bool operator<=(char character, const NzString& nstring);
|
||||
NAZARA_API friend bool operator<=(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend bool operator<=(const std::string& string, const NzString& nstring);
|
||||
|
||||
NAZARA_API friend bool operator>(char character, const NzString& nstring);
|
||||
NAZARA_API friend bool operator>(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend bool operator>(const std::string& string, const NzString& nstring);
|
||||
|
||||
NAZARA_API friend bool operator>=(char character, const NzString& nstring);
|
||||
NAZARA_API friend bool operator>=(const char* string, const NzString& nstring);
|
||||
NAZARA_API friend bool operator>=(const std::string& string, const NzString& nstring);
|
||||
|
||||
struct NAZARA_API SharedString
|
||||
{
|
||||
SharedString() = default;
|
||||
|
||||
SharedString(unsigned short referenceCount, unsigned int bufferSize, unsigned int stringSize, char* str) :
|
||||
capacity(bufferSize),
|
||||
size(stringSize),
|
||||
string(str),
|
||||
refCount(referenceCount)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int capacity;
|
||||
unsigned int size;
|
||||
char* string;
|
||||
|
||||
unsigned short refCount = 1;
|
||||
NazaraMutex(mutex)
|
||||
};
|
||||
|
||||
static SharedString emptyString;
|
||||
static const unsigned int npos;
|
||||
|
||||
private:
|
||||
void EnsureOwnership();
|
||||
bool FillHash(NzHashImpl* hash) const;
|
||||
void ReleaseString();
|
||||
|
||||
SharedString* m_sharedString;
|
||||
};
|
||||
|
||||
namespace std
|
||||
{
|
||||
NAZARA_API istream& getline(istream& is, NzString& str);
|
||||
NAZARA_API istream& getline(istream& is, NzString& str, char delim);
|
||||
NAZARA_API void swap(NzString& lhs, NzString& rhs);
|
||||
}
|
||||
|
||||
#endif // NAZARA_STRING_HPP
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
/*
|
||||
Nazara Engine - Mathematics module
|
||||
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
Rémi "overdrivr" Bèges (remi.beges@laposte.net)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONFIG_MATH_HPP
|
||||
#define NAZARA_CONFIG_MATH_HPP
|
||||
|
||||
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
|
||||
|
||||
// Définit le radian comme l'unité utilisée pour les angles
|
||||
#define NAZARA_MATH_ANGLE_RADIAN 0
|
||||
|
||||
// Optimise les opérations entre matrices affines (Demande plusieurs comparaisons pour déterminer si une matrice est affine)
|
||||
#define NAZARA_MATH_MATRIX4_CHECK_AFFINE 0
|
||||
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_MATH_SAFE 1
|
||||
|
||||
// Protège les classes des accès concurrentiels
|
||||
#define NAZARA_MATH_THREADSAFE 1
|
||||
|
||||
// Les classes à protéger des accès concurrentiels
|
||||
#define NAZARA_THREADSAFETY_MATRIX3 1 // NzMatrix3 (COW)
|
||||
#define NAZARA_THREADSAFETY_MATRIX4 1 // NzMatrix4 (COW)
|
||||
|
||||
#endif // NAZARA_CONFIG_MATH_HPP
|
||||
/*
|
||||
Nazara Engine - Mathematics module
|
||||
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
Rémi "overdrivr" Bèges (remi.beges@laposte.net)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONFIG_MATH_HPP
|
||||
#define NAZARA_CONFIG_MATH_HPP
|
||||
|
||||
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
|
||||
|
||||
// Définit le radian comme l'unité utilisée pour les angles
|
||||
#define NAZARA_MATH_ANGLE_RADIAN 0
|
||||
|
||||
// Optimise les opérations entre matrices affines (Demande plusieurs comparaisons pour déterminer si une matrice est affine)
|
||||
#define NAZARA_MATH_MATRIX4_CHECK_AFFINE 0
|
||||
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_MATH_SAFE 1
|
||||
|
||||
// Protège les classes des accès concurrentiels
|
||||
#define NAZARA_MATH_THREADSAFE 1
|
||||
|
||||
// Les classes à protéger des accès concurrentiels
|
||||
#define NAZARA_THREADSAFETY_MATRIX3 1 // NzMatrix3 (COW)
|
||||
#define NAZARA_THREADSAFETY_MATRIX4 1 // NzMatrix4 (COW)
|
||||
|
||||
#endif // NAZARA_CONFIG_MATH_HPP
|
||||
|
||||
@@ -1,145 +1,145 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_MATRIX4_HPP
|
||||
#define NAZARA_MATRIX4_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Config.hpp>
|
||||
|
||||
#if NAZARA_MATH_THREADSAFE && 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;
|
||||
template<typename T> class NzVector2;
|
||||
template<typename T> class NzVector3;
|
||||
template<typename T> class NzVector4;
|
||||
|
||||
template<typename T> class NzMatrix4
|
||||
{
|
||||
public:
|
||||
NzMatrix4();
|
||||
NzMatrix4(T r11, T r12, T r13, T r14,
|
||||
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(const T matrix[16]);
|
||||
//NzMatrix4(const NzMatrix3<T>& matrix);
|
||||
template<typename U> explicit NzMatrix4(const NzMatrix4<U>& matrix);
|
||||
NzMatrix4(const NzMatrix4& matrix);
|
||||
NzMatrix4(NzMatrix4&& matrix) noexcept;
|
||||
~NzMatrix4();
|
||||
|
||||
NzMatrix4 Concatenate(const NzMatrix4& matrix) const;
|
||||
NzMatrix4 ConcatenateAffine(const NzMatrix4& matrix) const;
|
||||
|
||||
T GetDeterminant() const;
|
||||
NzMatrix4 GetInverse() const;
|
||||
NzQuaternion<T> GetRotation() const;
|
||||
//NzMatrix3 GetRotationMatrix() const;
|
||||
NzVector3<T> GetScale() const;
|
||||
NzVector3<T> GetTranslation() const;
|
||||
NzMatrix4 GetTransposed() const;
|
||||
|
||||
bool HasNegativeScale() const;
|
||||
bool HasScale() const;
|
||||
|
||||
bool IsAffine() const;
|
||||
bool IsDefined() const;
|
||||
|
||||
void MakeIdentity();
|
||||
void MakeLookAt(const NzVector3<T>& eye, const NzVector3<T>& target, const NzVector3<T>& up = NzVector3<T>::Up());
|
||||
void MakeOrtho(T left, T top, T width, T height, T zNear = -1.0, T zFar = 1.0);
|
||||
void MakePerspective(T angle, T ratio, T zNear, T zFar);
|
||||
void MakeRotation(const NzQuaternion<T>& rotation);
|
||||
void MakeScale(const NzVector3<T>& scale);
|
||||
void MakeTranslation(const NzVector3<T>& translation);
|
||||
void MakeZero();
|
||||
|
||||
void Set(T r11, T r12, T r13, T r14,
|
||||
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(const T matrix[16]);
|
||||
//NzMatrix4(const NzMatrix3<T>& matrix);
|
||||
void Set(const NzMatrix4& matrix);
|
||||
void Set(NzMatrix4&& matrix);
|
||||
template<typename U> void Set(const NzMatrix4<U>& matrix);
|
||||
void SetRotation(const NzQuaternion<T>& rotation);
|
||||
void SetScale(const NzVector3<T>& scale);
|
||||
void SetTranslation(const NzVector3<T>& translation);
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
NzVector2<T> Transform(const NzVector2<T>& vector, T z = 0.0, T w = 1.0) const;
|
||||
NzVector3<T> Transform(const NzVector3<T>& vector, T w = 1.0) const;
|
||||
NzVector4<T> Transform(const NzVector4<T>& vector) const;
|
||||
|
||||
NzMatrix4& Transpose();
|
||||
|
||||
operator NzString() const;
|
||||
|
||||
operator T*();
|
||||
operator const T*() const;
|
||||
|
||||
T& operator()(unsigned int x, unsigned int y);
|
||||
const T& operator()(unsigned int x, unsigned int y) const;
|
||||
|
||||
NzMatrix4& operator=(const NzMatrix4& matrix);
|
||||
NzMatrix4& operator=(NzMatrix4&& matrix) noexcept;
|
||||
|
||||
NzMatrix4 operator*(const NzMatrix4& matrix) const;
|
||||
NzVector2<T> operator*(const NzVector2<T>& vector) const;
|
||||
NzVector3<T> operator*(const NzVector3<T>& vector) const;
|
||||
NzVector4<T> operator*(const NzVector4<T>& vector) const;
|
||||
NzMatrix4 operator*(T scalar) const;
|
||||
|
||||
NzMatrix4& operator*=(const NzMatrix4& matrix);
|
||||
NzMatrix4& operator*=(T scalar);
|
||||
|
||||
static NzMatrix4 Concatenate(const NzMatrix4& m1, const NzMatrix4& m2);
|
||||
static NzMatrix4 ConcatenateAffine(const NzMatrix4& m1, const NzMatrix4& m2);
|
||||
static NzMatrix4 Identity();
|
||||
static NzMatrix4 LookAt(const NzVector3<T>& eye, const NzVector3<T>& target, const NzVector3<T>& up = NzVector3<T>::Up());
|
||||
static NzMatrix4 Ortho(T left, T top, T width, T height, T zNear = -1.0, T zFar = 1.0);
|
||||
static NzMatrix4 Perspective(T angle, T ratio, T zNear, T zFar);
|
||||
static NzMatrix4 Rotate(const NzQuaternion<T>& rotation);
|
||||
static NzMatrix4 Scale(const NzVector3<T>& scale);
|
||||
static NzMatrix4 Translate(const NzVector3<T>& translation);
|
||||
static NzMatrix4 Zero();
|
||||
|
||||
struct SharedMatrix
|
||||
{
|
||||
T m11, m12, m13, m14,
|
||||
m21, m22, m23, m24,
|
||||
m31, m32, m33, m34,
|
||||
m41, m42, m43, m44;
|
||||
|
||||
unsigned short refCount = 1;
|
||||
NazaraMutex(mutex)
|
||||
};
|
||||
|
||||
private:
|
||||
void EnsureOwnership();
|
||||
void ReleaseMatrix();
|
||||
|
||||
SharedMatrix* m_sharedMatrix = nullptr;
|
||||
};
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const NzMatrix4<T>& matrix);
|
||||
|
||||
template<typename T> NzMatrix4<T> operator*(T scale, const NzMatrix4<T>& matrix);
|
||||
|
||||
typedef NzMatrix4<double> NzMatrix4d;
|
||||
typedef NzMatrix4<float> NzMatrix4f;
|
||||
|
||||
#include <Nazara/Math/Matrix4.inl>
|
||||
|
||||
#endif // NAZARA_MATRIX4_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_MATRIX4_HPP
|
||||
#define NAZARA_MATRIX4_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Config.hpp>
|
||||
|
||||
#if NAZARA_MATH_THREADSAFE && 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;
|
||||
template<typename T> class NzVector2;
|
||||
template<typename T> class NzVector3;
|
||||
template<typename T> class NzVector4;
|
||||
|
||||
template<typename T> class NzMatrix4
|
||||
{
|
||||
public:
|
||||
NzMatrix4();
|
||||
NzMatrix4(T r11, T r12, T r13, T r14,
|
||||
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(const T matrix[16]);
|
||||
//NzMatrix4(const NzMatrix3<T>& matrix);
|
||||
template<typename U> explicit NzMatrix4(const NzMatrix4<U>& matrix);
|
||||
NzMatrix4(const NzMatrix4& matrix);
|
||||
NzMatrix4(NzMatrix4&& matrix) noexcept;
|
||||
~NzMatrix4();
|
||||
|
||||
NzMatrix4 Concatenate(const NzMatrix4& matrix) const;
|
||||
NzMatrix4 ConcatenateAffine(const NzMatrix4& matrix) const;
|
||||
|
||||
T GetDeterminant() const;
|
||||
NzMatrix4 GetInverse() const;
|
||||
NzQuaternion<T> GetRotation() const;
|
||||
//NzMatrix3 GetRotationMatrix() const;
|
||||
NzVector3<T> GetScale() const;
|
||||
NzVector3<T> GetTranslation() const;
|
||||
NzMatrix4 GetTransposed() const;
|
||||
|
||||
bool HasNegativeScale() const;
|
||||
bool HasScale() const;
|
||||
|
||||
bool IsAffine() const;
|
||||
bool IsDefined() const;
|
||||
|
||||
void MakeIdentity();
|
||||
void MakeLookAt(const NzVector3<T>& eye, const NzVector3<T>& target, const NzVector3<T>& up = NzVector3<T>::Up());
|
||||
void MakeOrtho(T left, T top, T width, T height, T zNear = -1.0, T zFar = 1.0);
|
||||
void MakePerspective(T angle, T ratio, T zNear, T zFar);
|
||||
void MakeRotation(const NzQuaternion<T>& rotation);
|
||||
void MakeScale(const NzVector3<T>& scale);
|
||||
void MakeTranslation(const NzVector3<T>& translation);
|
||||
void MakeZero();
|
||||
|
||||
void Set(T r11, T r12, T r13, T r14,
|
||||
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(const T matrix[16]);
|
||||
//NzMatrix4(const NzMatrix3<T>& matrix);
|
||||
void Set(const NzMatrix4& matrix);
|
||||
void Set(NzMatrix4&& matrix);
|
||||
template<typename U> void Set(const NzMatrix4<U>& matrix);
|
||||
void SetRotation(const NzQuaternion<T>& rotation);
|
||||
void SetScale(const NzVector3<T>& scale);
|
||||
void SetTranslation(const NzVector3<T>& translation);
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
NzVector2<T> Transform(const NzVector2<T>& vector, T z = 0.0, T w = 1.0) const;
|
||||
NzVector3<T> Transform(const NzVector3<T>& vector, T w = 1.0) const;
|
||||
NzVector4<T> Transform(const NzVector4<T>& vector) const;
|
||||
|
||||
NzMatrix4& Transpose();
|
||||
|
||||
operator NzString() const;
|
||||
|
||||
operator T*();
|
||||
operator const T*() const;
|
||||
|
||||
T& operator()(unsigned int x, unsigned int y);
|
||||
const T& operator()(unsigned int x, unsigned int y) const;
|
||||
|
||||
NzMatrix4& operator=(const NzMatrix4& matrix);
|
||||
NzMatrix4& operator=(NzMatrix4&& matrix) noexcept;
|
||||
|
||||
NzMatrix4 operator*(const NzMatrix4& matrix) const;
|
||||
NzVector2<T> operator*(const NzVector2<T>& vector) const;
|
||||
NzVector3<T> operator*(const NzVector3<T>& vector) const;
|
||||
NzVector4<T> operator*(const NzVector4<T>& vector) const;
|
||||
NzMatrix4 operator*(T scalar) const;
|
||||
|
||||
NzMatrix4& operator*=(const NzMatrix4& matrix);
|
||||
NzMatrix4& operator*=(T scalar);
|
||||
|
||||
static NzMatrix4 Concatenate(const NzMatrix4& m1, const NzMatrix4& m2);
|
||||
static NzMatrix4 ConcatenateAffine(const NzMatrix4& m1, const NzMatrix4& m2);
|
||||
static NzMatrix4 Identity();
|
||||
static NzMatrix4 LookAt(const NzVector3<T>& eye, const NzVector3<T>& target, const NzVector3<T>& up = NzVector3<T>::Up());
|
||||
static NzMatrix4 Ortho(T left, T top, T width, T height, T zNear = -1.0, T zFar = 1.0);
|
||||
static NzMatrix4 Perspective(T angle, T ratio, T zNear, T zFar);
|
||||
static NzMatrix4 Rotate(const NzQuaternion<T>& rotation);
|
||||
static NzMatrix4 Scale(const NzVector3<T>& scale);
|
||||
static NzMatrix4 Translate(const NzVector3<T>& translation);
|
||||
static NzMatrix4 Zero();
|
||||
|
||||
struct SharedMatrix
|
||||
{
|
||||
T m11, m12, m13, m14,
|
||||
m21, m22, m23, m24,
|
||||
m31, m32, m33, m34,
|
||||
m41, m42, m43, m44;
|
||||
|
||||
unsigned short refCount = 1;
|
||||
NazaraMutex(mutex)
|
||||
};
|
||||
|
||||
private:
|
||||
void EnsureOwnership();
|
||||
void ReleaseMatrix();
|
||||
|
||||
SharedMatrix* m_sharedMatrix = nullptr;
|
||||
};
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const NzMatrix4<T>& matrix);
|
||||
|
||||
template<typename T> NzMatrix4<T> operator*(T scale, const NzMatrix4<T>& matrix);
|
||||
|
||||
typedef NzMatrix4<double> NzMatrix4d;
|
||||
typedef NzMatrix4<float> NzMatrix4f;
|
||||
|
||||
#include <Nazara/Math/Matrix4.inl>
|
||||
|
||||
#endif // NAZARA_MATRIX4_HPP
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,93 +1,93 @@
|
||||
// Copyright (C) 2012 Rémi Bèges - Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_QUATERNION_HPP
|
||||
#define NAZARA_QUATERNION_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
template<typename T> class NzEulerAngles;
|
||||
template<typename T> class NzVector3;
|
||||
|
||||
template<typename T> class NzQuaternion
|
||||
{
|
||||
public:
|
||||
NzQuaternion();
|
||||
NzQuaternion(T W, T X, T Y, T Z);
|
||||
NzQuaternion(T quat[4]);
|
||||
NzQuaternion(T angle, const NzVector3<T>& axis);
|
||||
NzQuaternion(const NzEulerAngles<T>& angles);
|
||||
//NzQuaternion(const NzMatrix3<T>& mat);
|
||||
template<typename U> explicit NzQuaternion(const NzQuaternion<U>& quat);
|
||||
NzQuaternion(const NzQuaternion& quat) = default;
|
||||
~NzQuaternion() = default;
|
||||
|
||||
T DotProduct(const NzQuaternion& vec) const;
|
||||
|
||||
NzQuaternion GetConjugate() const;
|
||||
NzQuaternion GetInverse() const;
|
||||
NzQuaternion GetNormal() const;
|
||||
|
||||
void Inverse();
|
||||
|
||||
void MakeIdentity();
|
||||
void MakeZero();
|
||||
|
||||
T Magnitude() const;
|
||||
|
||||
T Normalize();
|
||||
|
||||
void Set(T W, T X, T Y, T Z);
|
||||
void Set(T quat[4]);
|
||||
void Set(T angle, const NzVector3<T>& normalizedAxis);
|
||||
void Set(const NzEulerAngles<T>& angles);
|
||||
//void Set(const NzMatrix3<T>& mat);
|
||||
void Set(const NzQuaternion& quat);
|
||||
template<typename U> void Set(const NzQuaternion<U>& quat);
|
||||
|
||||
T SquaredMagnitude() const;
|
||||
|
||||
NzEulerAngles<T> ToEulerAngles() const;
|
||||
//NzMatrix3<T> ToRotationMatrix() const;
|
||||
NzString ToString() const;
|
||||
|
||||
operator NzString() const;
|
||||
|
||||
NzQuaternion& operator=(const NzQuaternion& quat);
|
||||
|
||||
NzQuaternion operator+(const NzQuaternion& quat) const;
|
||||
NzQuaternion operator*(const NzQuaternion& quat) const;
|
||||
NzVector3<T> operator*(const NzVector3<T>& vec) const;
|
||||
NzQuaternion operator*(T scale) const;
|
||||
NzQuaternion operator/(const NzQuaternion& quat) const;
|
||||
|
||||
NzQuaternion& operator+=(const NzQuaternion& quat);
|
||||
NzQuaternion& operator*=(const NzQuaternion& quat);
|
||||
NzQuaternion& operator*=(T scale);
|
||||
NzQuaternion& operator/=(const NzQuaternion& quat);
|
||||
|
||||
bool operator==(const NzQuaternion& quat) const;
|
||||
bool operator!=(const NzQuaternion& quat) const;
|
||||
bool operator<(const NzQuaternion& quat) const;
|
||||
bool operator<=(const NzQuaternion& quat) const;
|
||||
bool operator>(const NzQuaternion& quat) const;
|
||||
bool operator>=(const NzQuaternion& quat) const;
|
||||
|
||||
static NzQuaternion Identity();
|
||||
static NzQuaternion Slerp(const NzQuaternion& quatA, const NzQuaternion& quatB, T interp);
|
||||
static NzQuaternion Zero();
|
||||
|
||||
T w, x, y, z;
|
||||
};
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const NzQuaternion<T>& quat);
|
||||
|
||||
typedef NzQuaternion<double> NzQuaterniond;
|
||||
typedef NzQuaternion<float> NzQuaternionf;
|
||||
|
||||
#include <Nazara/Math/Quaternion.inl>
|
||||
|
||||
#endif // NAZARA_QUATERNION_HPP
|
||||
// Copyright (C) 2012 Rémi Bèges - Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_QUATERNION_HPP
|
||||
#define NAZARA_QUATERNION_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
template<typename T> class NzEulerAngles;
|
||||
template<typename T> class NzVector3;
|
||||
|
||||
template<typename T> class NzQuaternion
|
||||
{
|
||||
public:
|
||||
NzQuaternion();
|
||||
NzQuaternion(T W, T X, T Y, T Z);
|
||||
NzQuaternion(T quat[4]);
|
||||
NzQuaternion(T angle, const NzVector3<T>& axis);
|
||||
NzQuaternion(const NzEulerAngles<T>& angles);
|
||||
//NzQuaternion(const NzMatrix3<T>& mat);
|
||||
template<typename U> explicit NzQuaternion(const NzQuaternion<U>& quat);
|
||||
NzQuaternion(const NzQuaternion& quat) = default;
|
||||
~NzQuaternion() = default;
|
||||
|
||||
T DotProduct(const NzQuaternion& vec) const;
|
||||
|
||||
NzQuaternion GetConjugate() const;
|
||||
NzQuaternion GetInverse() const;
|
||||
NzQuaternion GetNormal() const;
|
||||
|
||||
void Inverse();
|
||||
|
||||
void MakeIdentity();
|
||||
void MakeZero();
|
||||
|
||||
T Magnitude() const;
|
||||
|
||||
T Normalize();
|
||||
|
||||
void Set(T W, T X, T Y, T Z);
|
||||
void Set(T quat[4]);
|
||||
void Set(T angle, const NzVector3<T>& normalizedAxis);
|
||||
void Set(const NzEulerAngles<T>& angles);
|
||||
//void Set(const NzMatrix3<T>& mat);
|
||||
void Set(const NzQuaternion& quat);
|
||||
template<typename U> void Set(const NzQuaternion<U>& quat);
|
||||
|
||||
T SquaredMagnitude() const;
|
||||
|
||||
NzEulerAngles<T> ToEulerAngles() const;
|
||||
//NzMatrix3<T> ToRotationMatrix() const;
|
||||
NzString ToString() const;
|
||||
|
||||
operator NzString() const;
|
||||
|
||||
NzQuaternion& operator=(const NzQuaternion& quat);
|
||||
|
||||
NzQuaternion operator+(const NzQuaternion& quat) const;
|
||||
NzQuaternion operator*(const NzQuaternion& quat) const;
|
||||
NzVector3<T> operator*(const NzVector3<T>& vec) const;
|
||||
NzQuaternion operator*(T scale) const;
|
||||
NzQuaternion operator/(const NzQuaternion& quat) const;
|
||||
|
||||
NzQuaternion& operator+=(const NzQuaternion& quat);
|
||||
NzQuaternion& operator*=(const NzQuaternion& quat);
|
||||
NzQuaternion& operator*=(T scale);
|
||||
NzQuaternion& operator/=(const NzQuaternion& quat);
|
||||
|
||||
bool operator==(const NzQuaternion& quat) const;
|
||||
bool operator!=(const NzQuaternion& quat) const;
|
||||
bool operator<(const NzQuaternion& quat) const;
|
||||
bool operator<=(const NzQuaternion& quat) const;
|
||||
bool operator>(const NzQuaternion& quat) const;
|
||||
bool operator>=(const NzQuaternion& quat) const;
|
||||
|
||||
static NzQuaternion Identity();
|
||||
static NzQuaternion Slerp(const NzQuaternion& quatA, const NzQuaternion& quatB, T interp);
|
||||
static NzQuaternion Zero();
|
||||
|
||||
T w, x, y, z;
|
||||
};
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const NzQuaternion<T>& quat);
|
||||
|
||||
typedef NzQuaternion<double> NzQuaterniond;
|
||||
typedef NzQuaternion<float> NzQuaternionf;
|
||||
|
||||
#include <Nazara/Math/Quaternion.inl>
|
||||
|
||||
#endif // NAZARA_QUATERNION_HPP
|
||||
|
||||
@@ -1,428 +1,428 @@
|
||||
// Copyright (C) 2012 Rémi Bèges - Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Math/Basic.hpp>
|
||||
#include <Nazara/Math/Config.hpp>
|
||||
#include <Nazara/Math/EulerAngles.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <limits>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
#define F(a) static_cast<T>(a)
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion(T W, T X, T Y, T Z)
|
||||
{
|
||||
Set(W, X, Y, Z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion(T quat[4])
|
||||
{
|
||||
Set(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion(T angle, const NzVector3<T>& axis)
|
||||
{
|
||||
Set(angle, axis);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion(const NzEulerAngles<T>& angles)
|
||||
{
|
||||
Set(angles);
|
||||
}
|
||||
/*
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion(const NzMatrix3<T>& mat)
|
||||
{
|
||||
Set(mat);
|
||||
}
|
||||
*/
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzQuaternion<T>::NzQuaternion(const NzQuaternion<U>& quat)
|
||||
{
|
||||
Set(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzQuaternion<T>::DotProduct(const NzQuaternion& quat) const
|
||||
{
|
||||
return w*quat.w + x*quat.x + y*quat.y + z*quat.z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::GetConjugate() const
|
||||
{
|
||||
return NzQuaternion(w, -x, -y, -z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::GetInverse() const
|
||||
{
|
||||
NzQuaternion<T> quat(*this);
|
||||
quat.Inverse();
|
||||
|
||||
return quat;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::GetNormal() const
|
||||
{
|
||||
NzQuaternion<T> quat(*this);
|
||||
quat.Normalize();
|
||||
|
||||
return quat;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Inverse()
|
||||
{
|
||||
T norm = SquaredMagnitude();
|
||||
if (norm > F(0.0))
|
||||
{
|
||||
T invNorm = F(1.0) / norm;
|
||||
|
||||
w *= invNorm;
|
||||
x *= -invNorm;
|
||||
y *= -invNorm;
|
||||
z *= -invNorm;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::MakeIdentity()
|
||||
{
|
||||
Set(F(1.0), F(0.0), F(0.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::MakeZero()
|
||||
{
|
||||
Set(F(0.0), F(0.0), F(0.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzQuaternion<T>::Magnitude() const
|
||||
{
|
||||
return std::sqrt(SquaredMagnitude());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzQuaternion<T>::Normalize()
|
||||
{
|
||||
T squaredMagnitude = SquaredMagnitude();
|
||||
|
||||
// Inutile de vérifier si la magnitude au carrée est négative (Elle ne peut pas l'être)
|
||||
if (!NzNumberEquals(squaredMagnitude, F(1.0)))
|
||||
{
|
||||
T norm = std::sqrt(squaredMagnitude);
|
||||
T invNorm = F(1.0) / norm;
|
||||
|
||||
w *= invNorm;
|
||||
x *= invNorm;
|
||||
y *= invNorm;
|
||||
z *= invNorm;
|
||||
|
||||
return norm;
|
||||
}
|
||||
else
|
||||
return F(1.0); // Le quaternion est déjà normalisé
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(T W, T X, T Y, T Z)
|
||||
{
|
||||
w = W;
|
||||
x = X;
|
||||
y = Y;
|
||||
z = Z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(T quat[4])
|
||||
{
|
||||
w = quat[0];
|
||||
x = quat[1];
|
||||
y = quat[2];
|
||||
z = quat[3];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(T angle, const NzVector3<T>& axis)
|
||||
{
|
||||
angle /= F(2.0);
|
||||
|
||||
#if !NAZARA_MATH_ANGLE_RADIAN
|
||||
angle = NzDegreeToRadian(angle);
|
||||
#endif
|
||||
|
||||
NzVector3<T> normalizedAxis = axis.GetNormal();
|
||||
|
||||
T sinAngle = std::sin(angle);
|
||||
|
||||
w = std::cos(angle);
|
||||
x = normalizedAxis.x * sinAngle;
|
||||
y = normalizedAxis.y * sinAngle;
|
||||
z = normalizedAxis.z * sinAngle;
|
||||
|
||||
Normalize();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(const NzEulerAngles<T>& angles)
|
||||
{
|
||||
Set(angles.ToQuaternion());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
void NzQuaternion<T>::Set(const NzQuaternion<U>& quat)
|
||||
{
|
||||
w = static_cast<T>(quat.w);
|
||||
x = static_cast<T>(quat.x);
|
||||
y = static_cast<T>(quat.y);
|
||||
z = static_cast<T>(quat.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(const NzQuaternion& quat)
|
||||
{
|
||||
w = quat.w;
|
||||
x = quat.x;
|
||||
y = quat.y;
|
||||
z = quat.z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzQuaternion<T>::SquaredMagnitude() const
|
||||
{
|
||||
return w*w + x*x + y*y + z*z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzEulerAngles<T> NzQuaternion<T>::ToEulerAngles() const
|
||||
{
|
||||
T test = x*y + z*w;
|
||||
if (test > F(0.499))
|
||||
// singularity at north pole
|
||||
return NzEulerAngles<T>(NzDegrees(F(90.0)), NzRadians(F(2.0) * std::atan2(x, w)), F(0.0));
|
||||
|
||||
if (test < F(-0.499))
|
||||
return NzEulerAngles<T>(NzDegrees(F(-90.0)), NzRadians(F(-2.0) * std::atan2(x, w)), F(0.0));
|
||||
|
||||
return NzEulerAngles<T>(NzRadians(std::atan2(F(2.0)*x*w - F(2.0)*y*z, F(1.0) - F(2.0)*x* - F(2.0)*z*z)),
|
||||
NzRadians(std::atan2(F(2.0)*y*w - F(2.0)*x*z, F(1.0) - F(2.0)*y*y - F(2.0)*z*z)),
|
||||
NzRadians(std::asin(F(2.0)*test)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzString NzQuaternion<T>::ToString() const
|
||||
{
|
||||
NzStringStream ss;
|
||||
|
||||
return ss << "Quaternion(" << w << " | " << x << ", " << y << ", " << z << ')';
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::operator NzString() const
|
||||
{
|
||||
return ToString();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>& NzQuaternion<T>::operator=(const NzQuaternion& quat)
|
||||
{
|
||||
Set(quat);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::operator+(const NzQuaternion& quat) const
|
||||
{
|
||||
return NzQuaternion(w + quat.w,
|
||||
x + quat.x,
|
||||
y + quat.y,
|
||||
z + quat.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::operator*(const NzQuaternion& quat) const
|
||||
{
|
||||
return NzQuaternion(w*quat.w - x*quat.x - y*quat.y - z*quat.z,
|
||||
w*quat.x + x*quat.w + y*quat.z - z*quat.y,
|
||||
w*quat.y + y*quat.w + z*quat.x - x*quat.z,
|
||||
w*quat.z + z*quat.w + x*quat.y - y*quat.x);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzQuaternion<T>::operator*(const NzVector3<T>& vec) const
|
||||
{
|
||||
NzVector3f quatVec(x, y, z);
|
||||
NzVector3f uv = quatVec.CrossProduct(vec);
|
||||
NzVector3f uuv = quatVec.CrossProduct(uv);
|
||||
uv *= F(2.0) * w;
|
||||
uuv *= F(2.0);
|
||||
|
||||
return vec + uv + uuv;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::operator*(T scale) const
|
||||
{
|
||||
return NzQuaternion(w * scale,
|
||||
x * scale,
|
||||
y * scale,
|
||||
z * scale);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::operator/(const NzQuaternion& quat) const
|
||||
{
|
||||
return GetConjugate(quat) * (*this);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>& NzQuaternion<T>::operator+=(const NzQuaternion& quat)
|
||||
{
|
||||
return operator=(operator+(quat));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>& NzQuaternion<T>::operator*=(const NzQuaternion& quat)
|
||||
{
|
||||
return operator=(operator*(quat));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>& NzQuaternion<T>::operator*=(T scale)
|
||||
{
|
||||
return operator=(operator*(scale));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>& NzQuaternion<T>::operator/=(const NzQuaternion& quat)
|
||||
{
|
||||
return operator=(operator/(quat));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzQuaternion<T>::operator==(const NzQuaternion& quat) const
|
||||
{
|
||||
return NzNumberEquals(w, quat.w) &&
|
||||
NzNumberEquals(x, quat.x) &&
|
||||
NzNumberEquals(y, quat.y) &&
|
||||
NzNumberEquals(z, quat.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzQuaternion<T>::operator!=(const NzQuaternion& quat) const
|
||||
{
|
||||
return !operator==(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzQuaternion<T>::operator<(const NzQuaternion& quat) const
|
||||
{
|
||||
return w < quat.w && x < quat.x && y < quat.y && z < quat.z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzQuaternion<T>::operator<=(const NzQuaternion& quat) const
|
||||
{
|
||||
return operator<(quat) || operator==(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzQuaternion<T>::operator>(const NzQuaternion& quat) const
|
||||
{
|
||||
return !operator<=(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzQuaternion<T>::operator>=(const NzQuaternion& quat) const
|
||||
{
|
||||
return !operator<(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::Identity()
|
||||
{
|
||||
NzQuaternion quaternion;
|
||||
quaternion.MakeIdentity();
|
||||
|
||||
return quaternion;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::Slerp(const NzQuaternion& quatA, const NzQuaternion& quatB, T interp)
|
||||
{
|
||||
if (interp <= F(0.0))
|
||||
return quatA;
|
||||
|
||||
if (interp >= F(1.0))
|
||||
return quatB;
|
||||
|
||||
NzQuaternion q;
|
||||
|
||||
T cosOmega = quatA.DotProduct(quatB);
|
||||
if (cosOmega < F(0.0))
|
||||
{
|
||||
// On inverse tout
|
||||
q.Set(-quatB.w, -quatB.x, -quatB.y, -quatB.z);
|
||||
cosOmega = -cosOmega;
|
||||
}
|
||||
else
|
||||
q.Set(quatB);
|
||||
|
||||
T k0, k1;
|
||||
if (cosOmega > F(0.9999))
|
||||
{
|
||||
// Interpolation linéaire pour éviter une division par zéro
|
||||
k0 = F(1.0) - interp;
|
||||
k1 = interp;
|
||||
}
|
||||
else
|
||||
{
|
||||
T sinOmega = std::sqrt(F(1.0) - cosOmega*cosOmega);
|
||||
T omega = std::atan2(sinOmega, cosOmega);
|
||||
|
||||
// Pour éviter deux divisions
|
||||
sinOmega = F(1.0)/sinOmega;
|
||||
|
||||
k0 = std::sin((F(1.0) - interp) * omega) * sinOmega;
|
||||
k1 = std::sin(interp*omega) * sinOmega;
|
||||
}
|
||||
|
||||
NzQuaternion result(k0 * quatA.w, k0 * quatA.x, k0 * quatA.y, k0 * quatA.z);
|
||||
return result += q*k1;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::Zero()
|
||||
{
|
||||
NzQuaternion quaternion;
|
||||
quaternion.MakeZero();
|
||||
|
||||
return quaternion;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzQuaternion<T>& quat)
|
||||
{
|
||||
return out << quat.ToString();
|
||||
}
|
||||
|
||||
#undef F
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
// Copyright (C) 2012 Rémi Bèges - Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Math/Basic.hpp>
|
||||
#include <Nazara/Math/Config.hpp>
|
||||
#include <Nazara/Math/EulerAngles.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <limits>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
#define F(a) static_cast<T>(a)
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion(T W, T X, T Y, T Z)
|
||||
{
|
||||
Set(W, X, Y, Z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion(T quat[4])
|
||||
{
|
||||
Set(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion(T angle, const NzVector3<T>& axis)
|
||||
{
|
||||
Set(angle, axis);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion(const NzEulerAngles<T>& angles)
|
||||
{
|
||||
Set(angles);
|
||||
}
|
||||
/*
|
||||
template<typename T>
|
||||
NzQuaternion<T>::NzQuaternion(const NzMatrix3<T>& mat)
|
||||
{
|
||||
Set(mat);
|
||||
}
|
||||
*/
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzQuaternion<T>::NzQuaternion(const NzQuaternion<U>& quat)
|
||||
{
|
||||
Set(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzQuaternion<T>::DotProduct(const NzQuaternion& quat) const
|
||||
{
|
||||
return w*quat.w + x*quat.x + y*quat.y + z*quat.z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::GetConjugate() const
|
||||
{
|
||||
return NzQuaternion(w, -x, -y, -z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::GetInverse() const
|
||||
{
|
||||
NzQuaternion<T> quat(*this);
|
||||
quat.Inverse();
|
||||
|
||||
return quat;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::GetNormal() const
|
||||
{
|
||||
NzQuaternion<T> quat(*this);
|
||||
quat.Normalize();
|
||||
|
||||
return quat;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Inverse()
|
||||
{
|
||||
T norm = SquaredMagnitude();
|
||||
if (norm > F(0.0))
|
||||
{
|
||||
T invNorm = F(1.0) / norm;
|
||||
|
||||
w *= invNorm;
|
||||
x *= -invNorm;
|
||||
y *= -invNorm;
|
||||
z *= -invNorm;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::MakeIdentity()
|
||||
{
|
||||
Set(F(1.0), F(0.0), F(0.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::MakeZero()
|
||||
{
|
||||
Set(F(0.0), F(0.0), F(0.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzQuaternion<T>::Magnitude() const
|
||||
{
|
||||
return std::sqrt(SquaredMagnitude());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzQuaternion<T>::Normalize()
|
||||
{
|
||||
T squaredMagnitude = SquaredMagnitude();
|
||||
|
||||
// Inutile de vérifier si la magnitude au carrée est négative (Elle ne peut pas l'être)
|
||||
if (!NzNumberEquals(squaredMagnitude, F(1.0)))
|
||||
{
|
||||
T norm = std::sqrt(squaredMagnitude);
|
||||
T invNorm = F(1.0) / norm;
|
||||
|
||||
w *= invNorm;
|
||||
x *= invNorm;
|
||||
y *= invNorm;
|
||||
z *= invNorm;
|
||||
|
||||
return norm;
|
||||
}
|
||||
else
|
||||
return F(1.0); // Le quaternion est déjà normalisé
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(T W, T X, T Y, T Z)
|
||||
{
|
||||
w = W;
|
||||
x = X;
|
||||
y = Y;
|
||||
z = Z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(T quat[4])
|
||||
{
|
||||
w = quat[0];
|
||||
x = quat[1];
|
||||
y = quat[2];
|
||||
z = quat[3];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(T angle, const NzVector3<T>& axis)
|
||||
{
|
||||
angle /= F(2.0);
|
||||
|
||||
#if !NAZARA_MATH_ANGLE_RADIAN
|
||||
angle = NzDegreeToRadian(angle);
|
||||
#endif
|
||||
|
||||
NzVector3<T> normalizedAxis = axis.GetNormal();
|
||||
|
||||
T sinAngle = std::sin(angle);
|
||||
|
||||
w = std::cos(angle);
|
||||
x = normalizedAxis.x * sinAngle;
|
||||
y = normalizedAxis.y * sinAngle;
|
||||
z = normalizedAxis.z * sinAngle;
|
||||
|
||||
Normalize();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(const NzEulerAngles<T>& angles)
|
||||
{
|
||||
Set(angles.ToQuaternion());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
void NzQuaternion<T>::Set(const NzQuaternion<U>& quat)
|
||||
{
|
||||
w = static_cast<T>(quat.w);
|
||||
x = static_cast<T>(quat.x);
|
||||
y = static_cast<T>(quat.y);
|
||||
z = static_cast<T>(quat.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzQuaternion<T>::Set(const NzQuaternion& quat)
|
||||
{
|
||||
w = quat.w;
|
||||
x = quat.x;
|
||||
y = quat.y;
|
||||
z = quat.z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzQuaternion<T>::SquaredMagnitude() const
|
||||
{
|
||||
return w*w + x*x + y*y + z*z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzEulerAngles<T> NzQuaternion<T>::ToEulerAngles() const
|
||||
{
|
||||
T test = x*y + z*w;
|
||||
if (test > F(0.499))
|
||||
// singularity at north pole
|
||||
return NzEulerAngles<T>(NzDegrees(F(90.0)), NzRadians(F(2.0) * std::atan2(x, w)), F(0.0));
|
||||
|
||||
if (test < F(-0.499))
|
||||
return NzEulerAngles<T>(NzDegrees(F(-90.0)), NzRadians(F(-2.0) * std::atan2(x, w)), F(0.0));
|
||||
|
||||
return NzEulerAngles<T>(NzRadians(std::atan2(F(2.0)*x*w - F(2.0)*y*z, F(1.0) - F(2.0)*x* - F(2.0)*z*z)),
|
||||
NzRadians(std::atan2(F(2.0)*y*w - F(2.0)*x*z, F(1.0) - F(2.0)*y*y - F(2.0)*z*z)),
|
||||
NzRadians(std::asin(F(2.0)*test)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzString NzQuaternion<T>::ToString() const
|
||||
{
|
||||
NzStringStream ss;
|
||||
|
||||
return ss << "Quaternion(" << w << " | " << x << ", " << y << ", " << z << ')';
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>::operator NzString() const
|
||||
{
|
||||
return ToString();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>& NzQuaternion<T>::operator=(const NzQuaternion& quat)
|
||||
{
|
||||
Set(quat);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::operator+(const NzQuaternion& quat) const
|
||||
{
|
||||
return NzQuaternion(w + quat.w,
|
||||
x + quat.x,
|
||||
y + quat.y,
|
||||
z + quat.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::operator*(const NzQuaternion& quat) const
|
||||
{
|
||||
return NzQuaternion(w*quat.w - x*quat.x - y*quat.y - z*quat.z,
|
||||
w*quat.x + x*quat.w + y*quat.z - z*quat.y,
|
||||
w*quat.y + y*quat.w + z*quat.x - x*quat.z,
|
||||
w*quat.z + z*quat.w + x*quat.y - y*quat.x);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzQuaternion<T>::operator*(const NzVector3<T>& vec) const
|
||||
{
|
||||
NzVector3f quatVec(x, y, z);
|
||||
NzVector3f uv = quatVec.CrossProduct(vec);
|
||||
NzVector3f uuv = quatVec.CrossProduct(uv);
|
||||
uv *= F(2.0) * w;
|
||||
uuv *= F(2.0);
|
||||
|
||||
return vec + uv + uuv;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::operator*(T scale) const
|
||||
{
|
||||
return NzQuaternion(w * scale,
|
||||
x * scale,
|
||||
y * scale,
|
||||
z * scale);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::operator/(const NzQuaternion& quat) const
|
||||
{
|
||||
return GetConjugate(quat) * (*this);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>& NzQuaternion<T>::operator+=(const NzQuaternion& quat)
|
||||
{
|
||||
return operator=(operator+(quat));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>& NzQuaternion<T>::operator*=(const NzQuaternion& quat)
|
||||
{
|
||||
return operator=(operator*(quat));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>& NzQuaternion<T>::operator*=(T scale)
|
||||
{
|
||||
return operator=(operator*(scale));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T>& NzQuaternion<T>::operator/=(const NzQuaternion& quat)
|
||||
{
|
||||
return operator=(operator/(quat));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzQuaternion<T>::operator==(const NzQuaternion& quat) const
|
||||
{
|
||||
return NzNumberEquals(w, quat.w) &&
|
||||
NzNumberEquals(x, quat.x) &&
|
||||
NzNumberEquals(y, quat.y) &&
|
||||
NzNumberEquals(z, quat.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzQuaternion<T>::operator!=(const NzQuaternion& quat) const
|
||||
{
|
||||
return !operator==(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzQuaternion<T>::operator<(const NzQuaternion& quat) const
|
||||
{
|
||||
return w < quat.w && x < quat.x && y < quat.y && z < quat.z;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzQuaternion<T>::operator<=(const NzQuaternion& quat) const
|
||||
{
|
||||
return operator<(quat) || operator==(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzQuaternion<T>::operator>(const NzQuaternion& quat) const
|
||||
{
|
||||
return !operator<=(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzQuaternion<T>::operator>=(const NzQuaternion& quat) const
|
||||
{
|
||||
return !operator<(quat);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::Identity()
|
||||
{
|
||||
NzQuaternion quaternion;
|
||||
quaternion.MakeIdentity();
|
||||
|
||||
return quaternion;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::Slerp(const NzQuaternion& quatA, const NzQuaternion& quatB, T interp)
|
||||
{
|
||||
if (interp <= F(0.0))
|
||||
return quatA;
|
||||
|
||||
if (interp >= F(1.0))
|
||||
return quatB;
|
||||
|
||||
NzQuaternion q;
|
||||
|
||||
T cosOmega = quatA.DotProduct(quatB);
|
||||
if (cosOmega < F(0.0))
|
||||
{
|
||||
// On inverse tout
|
||||
q.Set(-quatB.w, -quatB.x, -quatB.y, -quatB.z);
|
||||
cosOmega = -cosOmega;
|
||||
}
|
||||
else
|
||||
q.Set(quatB);
|
||||
|
||||
T k0, k1;
|
||||
if (cosOmega > F(0.9999))
|
||||
{
|
||||
// Interpolation linéaire pour éviter une division par zéro
|
||||
k0 = F(1.0) - interp;
|
||||
k1 = interp;
|
||||
}
|
||||
else
|
||||
{
|
||||
T sinOmega = std::sqrt(F(1.0) - cosOmega*cosOmega);
|
||||
T omega = std::atan2(sinOmega, cosOmega);
|
||||
|
||||
// Pour éviter deux divisions
|
||||
sinOmega = F(1.0)/sinOmega;
|
||||
|
||||
k0 = std::sin((F(1.0) - interp) * omega) * sinOmega;
|
||||
k1 = std::sin(interp*omega) * sinOmega;
|
||||
}
|
||||
|
||||
NzQuaternion result(k0 * quatA.w, k0 * quatA.x, k0 * quatA.y, k0 * quatA.z);
|
||||
return result += q*k1;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::Zero()
|
||||
{
|
||||
NzQuaternion quaternion;
|
||||
quaternion.MakeZero();
|
||||
|
||||
return quaternion;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzQuaternion<T>& quat)
|
||||
{
|
||||
return out << quat.ToString();
|
||||
}
|
||||
|
||||
#undef F
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
||||
@@ -1,105 +1,105 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VECTOR2_HPP
|
||||
#define NAZARA_VECTOR2_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
template<typename T> class NzVector2
|
||||
{
|
||||
public:
|
||||
NzVector2();
|
||||
NzVector2(T X, T Y);
|
||||
explicit NzVector2(T scale);
|
||||
NzVector2(T vec[2]);
|
||||
template<typename U> explicit NzVector2(const NzVector2<U>& vec);
|
||||
NzVector2(const NzVector2& vec) = default;
|
||||
~NzVector2() = default;
|
||||
|
||||
T AbsDotProduct(const NzVector2& vec) const;
|
||||
|
||||
T Distance(const NzVector2& vec) const;
|
||||
float Distancef(const NzVector2& vec) const;
|
||||
|
||||
T DotProduct(const NzVector2& vec) const;
|
||||
|
||||
NzVector2 GetNormal() const;
|
||||
|
||||
T Length() const;
|
||||
float Lengthf() const;
|
||||
|
||||
void MakeUnitX();
|
||||
void MakeUnitY();
|
||||
void MakeZero();
|
||||
|
||||
void Maximize(const NzVector2& vec);
|
||||
void Minimize(const NzVector2& vec);
|
||||
|
||||
void Normalize();
|
||||
|
||||
void Set(T X, T Y);
|
||||
void Set(T scale);
|
||||
void Set(T vec[2]);
|
||||
template<typename U> void Set(const NzVector2<U>& vec);
|
||||
|
||||
T SquaredDistance(const NzVector2& vec) const;
|
||||
T SquaredLength() const;
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
operator NzString() const;
|
||||
|
||||
operator T*();
|
||||
operator const T*() const;
|
||||
|
||||
T& operator[](unsigned int i);
|
||||
T operator[](unsigned int i) const;
|
||||
|
||||
const NzVector2& operator+() const;
|
||||
NzVector2 operator-() const;
|
||||
|
||||
NzVector2 operator+(const NzVector2& vec) const;
|
||||
NzVector2 operator-(const NzVector2& vec) const;
|
||||
NzVector2 operator*(const NzVector2& vec) const;
|
||||
NzVector2 operator*(T scale) const;
|
||||
NzVector2 operator/(const NzVector2& vec) const;
|
||||
NzVector2 operator/(T scale) const;
|
||||
|
||||
NzVector2& operator+=(const NzVector2& vec);
|
||||
NzVector2& operator-=(const NzVector2& vec);
|
||||
NzVector2& operator*=(const NzVector2& vec);
|
||||
NzVector2& operator*=(T scale);
|
||||
NzVector2& operator/=(const NzVector2& vec);
|
||||
NzVector2& operator/=(T scale);
|
||||
|
||||
bool operator==(const NzVector2& vec) const;
|
||||
bool operator!=(const NzVector2& vec) const;
|
||||
bool operator<(const NzVector2& vec) const;
|
||||
bool operator<=(const NzVector2& vec) const;
|
||||
bool operator>(const NzVector2& vec) const;
|
||||
bool operator>=(const NzVector2& vec) const;
|
||||
|
||||
static NzVector2 UnitX();
|
||||
static NzVector2 UnitY();
|
||||
static NzVector2 Zero();
|
||||
|
||||
T x, y;
|
||||
};
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const NzVector2<T>& vec);
|
||||
|
||||
template<typename T> NzVector2<T> operator*(T scale, const NzVector2<T>& vec);
|
||||
template<typename T> NzVector2<T> operator/(T scale, const NzVector2<T>& vec);
|
||||
|
||||
typedef NzVector2<double> NzVector2d;
|
||||
typedef NzVector2<float> NzVector2f;
|
||||
typedef NzVector2<int> NzVector2i;
|
||||
typedef NzVector2<unsigned int> NzVector2ui;
|
||||
|
||||
#include <Nazara/Math/Vector2.inl>
|
||||
|
||||
#endif // NAZARA_VECTOR2_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VECTOR2_HPP
|
||||
#define NAZARA_VECTOR2_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
template<typename T> class NzVector2
|
||||
{
|
||||
public:
|
||||
NzVector2();
|
||||
NzVector2(T X, T Y);
|
||||
explicit NzVector2(T scale);
|
||||
NzVector2(T vec[2]);
|
||||
template<typename U> explicit NzVector2(const NzVector2<U>& vec);
|
||||
NzVector2(const NzVector2& vec) = default;
|
||||
~NzVector2() = default;
|
||||
|
||||
T AbsDotProduct(const NzVector2& vec) const;
|
||||
|
||||
T Distance(const NzVector2& vec) const;
|
||||
float Distancef(const NzVector2& vec) const;
|
||||
|
||||
T DotProduct(const NzVector2& vec) const;
|
||||
|
||||
NzVector2 GetNormal() const;
|
||||
|
||||
T Length() const;
|
||||
float Lengthf() const;
|
||||
|
||||
void MakeUnitX();
|
||||
void MakeUnitY();
|
||||
void MakeZero();
|
||||
|
||||
void Maximize(const NzVector2& vec);
|
||||
void Minimize(const NzVector2& vec);
|
||||
|
||||
void Normalize();
|
||||
|
||||
void Set(T X, T Y);
|
||||
void Set(T scale);
|
||||
void Set(T vec[2]);
|
||||
template<typename U> void Set(const NzVector2<U>& vec);
|
||||
|
||||
T SquaredDistance(const NzVector2& vec) const;
|
||||
T SquaredLength() const;
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
operator NzString() const;
|
||||
|
||||
operator T*();
|
||||
operator const T*() const;
|
||||
|
||||
T& operator[](unsigned int i);
|
||||
T operator[](unsigned int i) const;
|
||||
|
||||
const NzVector2& operator+() const;
|
||||
NzVector2 operator-() const;
|
||||
|
||||
NzVector2 operator+(const NzVector2& vec) const;
|
||||
NzVector2 operator-(const NzVector2& vec) const;
|
||||
NzVector2 operator*(const NzVector2& vec) const;
|
||||
NzVector2 operator*(T scale) const;
|
||||
NzVector2 operator/(const NzVector2& vec) const;
|
||||
NzVector2 operator/(T scale) const;
|
||||
|
||||
NzVector2& operator+=(const NzVector2& vec);
|
||||
NzVector2& operator-=(const NzVector2& vec);
|
||||
NzVector2& operator*=(const NzVector2& vec);
|
||||
NzVector2& operator*=(T scale);
|
||||
NzVector2& operator/=(const NzVector2& vec);
|
||||
NzVector2& operator/=(T scale);
|
||||
|
||||
bool operator==(const NzVector2& vec) const;
|
||||
bool operator!=(const NzVector2& vec) const;
|
||||
bool operator<(const NzVector2& vec) const;
|
||||
bool operator<=(const NzVector2& vec) const;
|
||||
bool operator>(const NzVector2& vec) const;
|
||||
bool operator>=(const NzVector2& vec) const;
|
||||
|
||||
static NzVector2 UnitX();
|
||||
static NzVector2 UnitY();
|
||||
static NzVector2 Zero();
|
||||
|
||||
T x, y;
|
||||
};
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const NzVector2<T>& vec);
|
||||
|
||||
template<typename T> NzVector2<T> operator*(T scale, const NzVector2<T>& vec);
|
||||
template<typename T> NzVector2<T> operator/(T scale, const NzVector2<T>& vec);
|
||||
|
||||
typedef NzVector2<double> NzVector2d;
|
||||
typedef NzVector2<float> NzVector2f;
|
||||
typedef NzVector2<int> NzVector2i;
|
||||
typedef NzVector2<unsigned int> NzVector2ui;
|
||||
|
||||
#include <Nazara/Math/Vector2.inl>
|
||||
|
||||
#endif // NAZARA_VECTOR2_HPP
|
||||
|
||||
@@ -1,488 +1,488 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Math/Basic.hpp>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
#define F(a) static_cast<T>(a)
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::NzVector2()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::NzVector2(T X, T Y)
|
||||
{
|
||||
Set(X, Y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::NzVector2(T scale)
|
||||
{
|
||||
Set(scale);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::NzVector2(T vec[2])
|
||||
{
|
||||
Set(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzVector2<T>::NzVector2(const NzVector2<U>& vec)
|
||||
{
|
||||
Set(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::AbsDotProduct(const NzVector2& vec) const
|
||||
{
|
||||
return std::fabs(x * vec.x) + std::fabs(y * vec.y);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline int NzVector2<int>::AbsDotProduct(const NzVector2<int>& vec) const
|
||||
{
|
||||
return std::labs(x * vec.x) + std::labs(y * vec.y);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline unsigned int NzVector2<unsigned int>::AbsDotProduct(const NzVector2<unsigned int>& vec) const
|
||||
{
|
||||
return std::labs(x * vec.x) + std::labs(y * vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::Distance(const NzVector2& vec) const
|
||||
{
|
||||
return std::sqrt(SquaredDistance(vec));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
float NzVector2<T>::Distancef(const NzVector2& vec) const
|
||||
{
|
||||
return std::sqrt(static_cast<float>(SquaredDistance(vec)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::DotProduct(const NzVector2& vec) const
|
||||
{
|
||||
return x*vec.x + y*vec.y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::GetNormal() const
|
||||
{
|
||||
NzVector2 vec(*this);
|
||||
vec.Normalize();
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::Length() const
|
||||
{
|
||||
return std::sqrt(SquaredLength());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
float NzVector2<T>::Lengthf() const
|
||||
{
|
||||
return std::sqrt(static_cast<float>(SquaredLength()));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::MakeUnitX()
|
||||
{
|
||||
Set(F(1.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::MakeUnitY()
|
||||
{
|
||||
Set(F(0.0), F(1.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::MakeZero()
|
||||
{
|
||||
Set(F(0.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::Maximize(const NzVector2& vec)
|
||||
{
|
||||
if (vec.x > x)
|
||||
x = vec.x;
|
||||
|
||||
if (vec.y > y)
|
||||
y = vec.y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::Minimize(const NzVector2& vec)
|
||||
{
|
||||
if (vec.x < x)
|
||||
x = vec.x;
|
||||
|
||||
if (vec.y < y)
|
||||
y = vec.y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::Normalize()
|
||||
{
|
||||
T squaredLength = SquaredLength();
|
||||
|
||||
if (squaredLength-F(1.0) > std::numeric_limits<T>::epsilon())
|
||||
{
|
||||
T length = std::sqrt(squaredLength);
|
||||
|
||||
x /= length;
|
||||
y /= length;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::Set(T X, T Y)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::Set(T scale)
|
||||
{
|
||||
x = scale;
|
||||
y = scale;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::Set(T vec[2])
|
||||
{
|
||||
std::memcpy(&x, vec, 2*sizeof(T));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
void NzVector2<T>::Set(const NzVector2<U>& vec)
|
||||
{
|
||||
x = F(vec.x);
|
||||
y = F(vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::SquaredDistance(const NzVector2& vec) const
|
||||
{
|
||||
return operator-(vec).SquaredLength();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::SquaredLength() const
|
||||
{
|
||||
return x*x + y*y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzString NzVector2<T>::ToString() const
|
||||
{
|
||||
NzStringStream ss;
|
||||
|
||||
return ss << "Vector2(" << x << ", " << y << ')';
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::operator NzString() const
|
||||
{
|
||||
return ToString();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::operator T*()
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::operator const T*() const
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T& NzVector2<T>::operator[](unsigned int i)
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (i >= 2)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 2)";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
return *(&x+i);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::operator[](unsigned int i) const
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (i >= 2)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 2)";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
return *(&x+i);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const NzVector2<T>& NzVector2<T>::operator+() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator-() const
|
||||
{
|
||||
return NzVector2(-x, -y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator+(const NzVector2& vec) const
|
||||
{
|
||||
return NzVector2(x + vec.x, y + vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator-(const NzVector2& vec) const
|
||||
{
|
||||
return NzVector2(x - vec.x, y - vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator*(const NzVector2& vec) const
|
||||
{
|
||||
return NzVector2(x * vec.x, y * vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator*(T scale) const
|
||||
{
|
||||
return NzVector2(x * scale, y * scale);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator/(const NzVector2& vec) const
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
return NzVector2(x / vec.x, y / vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator/(T scale) const
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(scale, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
return NzVector2(x / scale, y / scale);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator+=(const NzVector2& vec)
|
||||
{
|
||||
x += vec.x;
|
||||
y += vec.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator-=(const NzVector2& vec)
|
||||
{
|
||||
x -= vec.x;
|
||||
y -= vec.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator*=(const NzVector2& vec)
|
||||
{
|
||||
x *= vec.x;
|
||||
y *= vec.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator*=(T scale)
|
||||
{
|
||||
x *= scale;
|
||||
y *= scale;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator/=(const NzVector2& vec)
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
x /= vec.x;
|
||||
y /= vec.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator/=(T scale)
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(scale, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
x /= scale;
|
||||
y /= scale;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector2<T>::operator==(const NzVector2& vec) const
|
||||
{
|
||||
return NzNumberEquals(x, vec.x) &&
|
||||
NzNumberEquals(y, vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector2<T>::operator!=(const NzVector2& vec) const
|
||||
{
|
||||
return !operator==(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector2<T>::operator<(const NzVector2& vec) const
|
||||
{
|
||||
return x < vec.x && y < vec.y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector2<T>::operator<=(const NzVector2& vec) const
|
||||
{
|
||||
return operator<(vec) || operator==(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector2<T>::operator>(const NzVector2& vec) const
|
||||
{
|
||||
return !operator<=(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector2<T>::operator>=(const NzVector2& vec) const
|
||||
{
|
||||
return !operator<(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::UnitX()
|
||||
{
|
||||
NzVector2 vector;
|
||||
vector.MakeUnitX();
|
||||
|
||||
return vector;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::UnitY()
|
||||
{
|
||||
NzVector2 vector;
|
||||
vector.MakeUnitY();
|
||||
|
||||
return vector;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::Zero()
|
||||
{
|
||||
NzVector2 vector;
|
||||
vector.MakeZero();
|
||||
|
||||
return vector;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzVector2<T>& vec)
|
||||
{
|
||||
return out << vec.ToString();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> operator*(T scale, const NzVector2<T>& vec)
|
||||
{
|
||||
return NzVector2<T>(scale * vec.x, scale * vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> operator/(T scale, const NzVector2<T>& vec)
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
return NzVector2<T>(scale/vec.x, scale/vec.y);
|
||||
}
|
||||
|
||||
#undef F
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Math/Basic.hpp>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
#define F(a) static_cast<T>(a)
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::NzVector2()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::NzVector2(T X, T Y)
|
||||
{
|
||||
Set(X, Y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::NzVector2(T scale)
|
||||
{
|
||||
Set(scale);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::NzVector2(T vec[2])
|
||||
{
|
||||
Set(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzVector2<T>::NzVector2(const NzVector2<U>& vec)
|
||||
{
|
||||
Set(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::AbsDotProduct(const NzVector2& vec) const
|
||||
{
|
||||
return std::fabs(x * vec.x) + std::fabs(y * vec.y);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline int NzVector2<int>::AbsDotProduct(const NzVector2<int>& vec) const
|
||||
{
|
||||
return std::labs(x * vec.x) + std::labs(y * vec.y);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline unsigned int NzVector2<unsigned int>::AbsDotProduct(const NzVector2<unsigned int>& vec) const
|
||||
{
|
||||
return std::labs(x * vec.x) + std::labs(y * vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::Distance(const NzVector2& vec) const
|
||||
{
|
||||
return std::sqrt(SquaredDistance(vec));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
float NzVector2<T>::Distancef(const NzVector2& vec) const
|
||||
{
|
||||
return std::sqrt(static_cast<float>(SquaredDistance(vec)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::DotProduct(const NzVector2& vec) const
|
||||
{
|
||||
return x*vec.x + y*vec.y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::GetNormal() const
|
||||
{
|
||||
NzVector2 vec(*this);
|
||||
vec.Normalize();
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::Length() const
|
||||
{
|
||||
return std::sqrt(SquaredLength());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
float NzVector2<T>::Lengthf() const
|
||||
{
|
||||
return std::sqrt(static_cast<float>(SquaredLength()));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::MakeUnitX()
|
||||
{
|
||||
Set(F(1.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::MakeUnitY()
|
||||
{
|
||||
Set(F(0.0), F(1.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::MakeZero()
|
||||
{
|
||||
Set(F(0.0), F(0.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::Maximize(const NzVector2& vec)
|
||||
{
|
||||
if (vec.x > x)
|
||||
x = vec.x;
|
||||
|
||||
if (vec.y > y)
|
||||
y = vec.y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::Minimize(const NzVector2& vec)
|
||||
{
|
||||
if (vec.x < x)
|
||||
x = vec.x;
|
||||
|
||||
if (vec.y < y)
|
||||
y = vec.y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::Normalize()
|
||||
{
|
||||
T squaredLength = SquaredLength();
|
||||
|
||||
if (squaredLength-F(1.0) > std::numeric_limits<T>::epsilon())
|
||||
{
|
||||
T length = std::sqrt(squaredLength);
|
||||
|
||||
x /= length;
|
||||
y /= length;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::Set(T X, T Y)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::Set(T scale)
|
||||
{
|
||||
x = scale;
|
||||
y = scale;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzVector2<T>::Set(T vec[2])
|
||||
{
|
||||
std::memcpy(&x, vec, 2*sizeof(T));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
void NzVector2<T>::Set(const NzVector2<U>& vec)
|
||||
{
|
||||
x = F(vec.x);
|
||||
y = F(vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::SquaredDistance(const NzVector2& vec) const
|
||||
{
|
||||
return operator-(vec).SquaredLength();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::SquaredLength() const
|
||||
{
|
||||
return x*x + y*y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzString NzVector2<T>::ToString() const
|
||||
{
|
||||
NzStringStream ss;
|
||||
|
||||
return ss << "Vector2(" << x << ", " << y << ')';
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::operator NzString() const
|
||||
{
|
||||
return ToString();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::operator T*()
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>::operator const T*() const
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T& NzVector2<T>::operator[](unsigned int i)
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (i >= 2)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 2)";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
return *(&x+i);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::operator[](unsigned int i) const
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (i >= 2)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 2)";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
return *(&x+i);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const NzVector2<T>& NzVector2<T>::operator+() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator-() const
|
||||
{
|
||||
return NzVector2(-x, -y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator+(const NzVector2& vec) const
|
||||
{
|
||||
return NzVector2(x + vec.x, y + vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator-(const NzVector2& vec) const
|
||||
{
|
||||
return NzVector2(x - vec.x, y - vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator*(const NzVector2& vec) const
|
||||
{
|
||||
return NzVector2(x * vec.x, y * vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator*(T scale) const
|
||||
{
|
||||
return NzVector2(x * scale, y * scale);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator/(const NzVector2& vec) const
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
return NzVector2(x / vec.x, y / vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::operator/(T scale) const
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(scale, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
return NzVector2(x / scale, y / scale);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator+=(const NzVector2& vec)
|
||||
{
|
||||
x += vec.x;
|
||||
y += vec.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator-=(const NzVector2& vec)
|
||||
{
|
||||
x -= vec.x;
|
||||
y -= vec.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator*=(const NzVector2& vec)
|
||||
{
|
||||
x *= vec.x;
|
||||
y *= vec.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator*=(T scale)
|
||||
{
|
||||
x *= scale;
|
||||
y *= scale;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator/=(const NzVector2& vec)
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
x /= vec.x;
|
||||
y /= vec.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T>& NzVector2<T>::operator/=(T scale)
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(scale, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
x /= scale;
|
||||
y /= scale;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector2<T>::operator==(const NzVector2& vec) const
|
||||
{
|
||||
return NzNumberEquals(x, vec.x) &&
|
||||
NzNumberEquals(y, vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector2<T>::operator!=(const NzVector2& vec) const
|
||||
{
|
||||
return !operator==(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector2<T>::operator<(const NzVector2& vec) const
|
||||
{
|
||||
return x < vec.x && y < vec.y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector2<T>::operator<=(const NzVector2& vec) const
|
||||
{
|
||||
return operator<(vec) || operator==(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector2<T>::operator>(const NzVector2& vec) const
|
||||
{
|
||||
return !operator<=(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzVector2<T>::operator>=(const NzVector2& vec) const
|
||||
{
|
||||
return !operator<(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::UnitX()
|
||||
{
|
||||
NzVector2 vector;
|
||||
vector.MakeUnitX();
|
||||
|
||||
return vector;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::UnitY()
|
||||
{
|
||||
NzVector2 vector;
|
||||
vector.MakeUnitY();
|
||||
|
||||
return vector;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzVector2<T>::Zero()
|
||||
{
|
||||
NzVector2 vector;
|
||||
vector.MakeZero();
|
||||
|
||||
return vector;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzVector2<T>& vec)
|
||||
{
|
||||
return out << vec.ToString();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> operator*(T scale, const NzVector2<T>& vec)
|
||||
{
|
||||
return NzVector2<T>(scale * vec.x, scale * vec.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> operator/(T scale, const NzVector2<T>& vec)
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
return NzVector2<T>(scale/vec.x, scale/vec.y);
|
||||
}
|
||||
|
||||
#undef F
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
||||
@@ -1,121 +1,121 @@
|
||||
// Copyright (C) 2012 Rémi Bèges - Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VECTOR3_HPP
|
||||
#define NAZARA_VECTOR3_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
|
||||
template<typename T> class NzVector3
|
||||
{
|
||||
public:
|
||||
NzVector3();
|
||||
NzVector3(T X, T Y, T Z);
|
||||
explicit NzVector3(T scale);
|
||||
NzVector3(T vec[3]);
|
||||
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;
|
||||
|
||||
T AbsDotProduct(const NzVector3& vec) const;
|
||||
|
||||
NzVector3 CrossProduct(const NzVector3& vec) const;
|
||||
|
||||
T Distance(const NzVector3& vec) const;
|
||||
float Distancef(const NzVector3& vec) const;
|
||||
|
||||
T DotProduct(const NzVector3& vec) const;
|
||||
|
||||
NzVector3 GetNormal() const;
|
||||
|
||||
T Length() const;
|
||||
float Lengthf() const;
|
||||
|
||||
void MakeForward();
|
||||
void MakeLeft();
|
||||
void MakeUnitX();
|
||||
void MakeUnitY();
|
||||
void MakeUnitZ();
|
||||
void MakeUp();
|
||||
void MakeZero();
|
||||
|
||||
void Maximize(const NzVector3& vec);
|
||||
void Minimize(const NzVector3& vec);
|
||||
|
||||
void Normalize();
|
||||
|
||||
void Set(T X, T Y, T Z);
|
||||
void Set(T scale);
|
||||
void Set(T vec[3]);
|
||||
void Set(const NzVector2<T>& vec, T Z = 0.0);
|
||||
template<typename U> void Set(const NzVector3<U>& vec);
|
||||
|
||||
T SquaredDistance(const NzVector3& vec) const;
|
||||
T SquaredLength() const;
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
operator NzString() const;
|
||||
|
||||
operator T*();
|
||||
operator const T*() const;
|
||||
|
||||
T& operator[](unsigned int i);
|
||||
T operator[](unsigned int i) const;
|
||||
|
||||
const NzVector3& operator+() const;
|
||||
NzVector3 operator-() const;
|
||||
|
||||
NzVector3 operator+(const NzVector3& vec) const;
|
||||
NzVector3 operator-(const NzVector3& vec) const;
|
||||
NzVector3 operator*(const NzVector3& vec) const;
|
||||
NzVector3 operator*(T scale) const;
|
||||
NzVector3 operator/(const NzVector3& vec) const;
|
||||
NzVector3 operator/(T scale) const;
|
||||
|
||||
NzVector3& operator+=(const NzVector3& vec);
|
||||
NzVector3& operator-=(const NzVector3& vec);
|
||||
NzVector3& operator*=(const NzVector3& vec);
|
||||
NzVector3& operator*=(T scale);
|
||||
NzVector3& operator/=(const NzVector3& vec);
|
||||
NzVector3& operator/=(T scale);
|
||||
|
||||
bool operator==(const NzVector3& vec) const;
|
||||
bool operator!=(const NzVector3& vec) const;
|
||||
bool operator<(const NzVector3& vec) const;
|
||||
bool operator<=(const NzVector3& vec) const;
|
||||
bool operator>(const NzVector3& vec) const;
|
||||
bool operator>=(const NzVector3& vec) const;
|
||||
|
||||
static NzVector3 CrossProduct(const NzVector3& vec1, const NzVector3& vec2);
|
||||
static T DotProduct(const NzVector3& vec1, const NzVector3& vec2);
|
||||
static NzVector3 Forward();
|
||||
static NzVector3 Left();
|
||||
static NzVector3 Normalize(const NzVector3& vec);
|
||||
static NzVector3 UnitX();
|
||||
static NzVector3 UnitY();
|
||||
static NzVector3 UnitZ();
|
||||
static NzVector3 Up();
|
||||
static NzVector3 Zero();
|
||||
|
||||
T x, y, z;
|
||||
};
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const NzVector3<T>& vec);
|
||||
|
||||
template<typename T> NzVector3<T> operator*(T scale, const NzVector3<T>& vec);
|
||||
template<typename T> NzVector3<T> operator/(T scale, const NzVector3<T>& vec);
|
||||
|
||||
typedef NzVector3<double> NzVector3d;
|
||||
typedef NzVector3<float> NzVector3f;
|
||||
typedef NzVector3<int> NzVector3i;
|
||||
typedef NzVector3<unsigned int> NzVector3ui;
|
||||
|
||||
#include <Nazara/Math/Vector3.inl>
|
||||
|
||||
#endif // NAZARA_VECTOR3_HPP
|
||||
// Copyright (C) 2012 Rémi Bèges - Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VECTOR3_HPP
|
||||
#define NAZARA_VECTOR3_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
|
||||
template<typename T> class NzVector3
|
||||
{
|
||||
public:
|
||||
NzVector3();
|
||||
NzVector3(T X, T Y, T Z);
|
||||
explicit NzVector3(T scale);
|
||||
NzVector3(T vec[3]);
|
||||
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;
|
||||
|
||||
T AbsDotProduct(const NzVector3& vec) const;
|
||||
|
||||
NzVector3 CrossProduct(const NzVector3& vec) const;
|
||||
|
||||
T Distance(const NzVector3& vec) const;
|
||||
float Distancef(const NzVector3& vec) const;
|
||||
|
||||
T DotProduct(const NzVector3& vec) const;
|
||||
|
||||
NzVector3 GetNormal() const;
|
||||
|
||||
T Length() const;
|
||||
float Lengthf() const;
|
||||
|
||||
void MakeForward();
|
||||
void MakeLeft();
|
||||
void MakeUnitX();
|
||||
void MakeUnitY();
|
||||
void MakeUnitZ();
|
||||
void MakeUp();
|
||||
void MakeZero();
|
||||
|
||||
void Maximize(const NzVector3& vec);
|
||||
void Minimize(const NzVector3& vec);
|
||||
|
||||
void Normalize();
|
||||
|
||||
void Set(T X, T Y, T Z);
|
||||
void Set(T scale);
|
||||
void Set(T vec[3]);
|
||||
void Set(const NzVector2<T>& vec, T Z = 0.0);
|
||||
template<typename U> void Set(const NzVector3<U>& vec);
|
||||
|
||||
T SquaredDistance(const NzVector3& vec) const;
|
||||
T SquaredLength() const;
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
operator NzString() const;
|
||||
|
||||
operator T*();
|
||||
operator const T*() const;
|
||||
|
||||
T& operator[](unsigned int i);
|
||||
T operator[](unsigned int i) const;
|
||||
|
||||
const NzVector3& operator+() const;
|
||||
NzVector3 operator-() const;
|
||||
|
||||
NzVector3 operator+(const NzVector3& vec) const;
|
||||
NzVector3 operator-(const NzVector3& vec) const;
|
||||
NzVector3 operator*(const NzVector3& vec) const;
|
||||
NzVector3 operator*(T scale) const;
|
||||
NzVector3 operator/(const NzVector3& vec) const;
|
||||
NzVector3 operator/(T scale) const;
|
||||
|
||||
NzVector3& operator+=(const NzVector3& vec);
|
||||
NzVector3& operator-=(const NzVector3& vec);
|
||||
NzVector3& operator*=(const NzVector3& vec);
|
||||
NzVector3& operator*=(T scale);
|
||||
NzVector3& operator/=(const NzVector3& vec);
|
||||
NzVector3& operator/=(T scale);
|
||||
|
||||
bool operator==(const NzVector3& vec) const;
|
||||
bool operator!=(const NzVector3& vec) const;
|
||||
bool operator<(const NzVector3& vec) const;
|
||||
bool operator<=(const NzVector3& vec) const;
|
||||
bool operator>(const NzVector3& vec) const;
|
||||
bool operator>=(const NzVector3& vec) const;
|
||||
|
||||
static NzVector3 CrossProduct(const NzVector3& vec1, const NzVector3& vec2);
|
||||
static T DotProduct(const NzVector3& vec1, const NzVector3& vec2);
|
||||
static NzVector3 Forward();
|
||||
static NzVector3 Left();
|
||||
static NzVector3 Normalize(const NzVector3& vec);
|
||||
static NzVector3 UnitX();
|
||||
static NzVector3 UnitY();
|
||||
static NzVector3 UnitZ();
|
||||
static NzVector3 Up();
|
||||
static NzVector3 Zero();
|
||||
|
||||
T x, y, z;
|
||||
};
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const NzVector3<T>& vec);
|
||||
|
||||
template<typename T> NzVector3<T> operator*(T scale, const NzVector3<T>& vec);
|
||||
template<typename T> NzVector3<T> operator/(T scale, const NzVector3<T>& vec);
|
||||
|
||||
typedef NzVector3<double> NzVector3d;
|
||||
typedef NzVector3<float> NzVector3f;
|
||||
typedef NzVector3<int> NzVector3i;
|
||||
typedef NzVector3<unsigned int> NzVector3ui;
|
||||
|
||||
#include <Nazara/Math/Vector3.inl>
|
||||
|
||||
#endif // NAZARA_VECTOR3_HPP
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,98 +1,98 @@
|
||||
// Copyright (C) 2012 Rémi Bèges - Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VECTOR4_HPP
|
||||
#define NAZARA_VECTOR4_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
template<typename T> class NzVector4
|
||||
{
|
||||
public:
|
||||
NzVector4();
|
||||
NzVector4(T X, T Y, T Z, T W = 1.0);
|
||||
explicit NzVector4(T scale);
|
||||
NzVector4(T vec[4]);
|
||||
NzVector4(const NzVector3<T>& vec, T W = 1.0);
|
||||
template<typename U> explicit NzVector4(const NzVector4<U>& vec);
|
||||
NzVector4(const NzVector4& vec) = default;
|
||||
~NzVector4() = default;
|
||||
|
||||
T AbsDotProduct(const NzVector4& vec) const;
|
||||
|
||||
T DotProduct(const NzVector4& vec) const;
|
||||
|
||||
void MakeUnitX();
|
||||
void MakeUnitY();
|
||||
void MakeUnitZ();
|
||||
void MakeZero();
|
||||
|
||||
void Maximize(const NzVector4& vec);
|
||||
void Minimize(const NzVector4& vec);
|
||||
|
||||
void Normalize();
|
||||
|
||||
void Set(T X, T Y, T Z, T W = 1.0);
|
||||
void Set(T scale);
|
||||
void Set(T vec[4]);
|
||||
void Set(const NzVector3<T>& vec, T W = 1.0);
|
||||
template<typename U> void Set(const NzVector4<U>& vec);
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
operator NzString() const;
|
||||
|
||||
operator T*();
|
||||
operator const T*() const;
|
||||
|
||||
T& operator[](unsigned int i);
|
||||
T operator[](unsigned int i) const;
|
||||
|
||||
const NzVector4& operator+() const;
|
||||
NzVector4 operator-() const;
|
||||
|
||||
NzVector4 operator+(const NzVector4& vec) const;
|
||||
NzVector4 operator-(const NzVector4& vec) const;
|
||||
NzVector4 operator*(const NzVector4& vec) const;
|
||||
NzVector4 operator*(T scale) const;
|
||||
NzVector4 operator/(const NzVector4& vec) const;
|
||||
NzVector4 operator/(T scale) const;
|
||||
|
||||
NzVector4& operator+=(const NzVector4& vec);
|
||||
NzVector4& operator-=(const NzVector4& vec);
|
||||
NzVector4& operator*=(const NzVector4& vec);
|
||||
NzVector4& operator*=(T scale);
|
||||
NzVector4& operator/=(const NzVector4& vec);
|
||||
NzVector4& operator/=(T scale);
|
||||
|
||||
bool operator==(const NzVector4& vec) const;
|
||||
bool operator!=(const NzVector4& vec) const;
|
||||
bool operator<(const NzVector4& vec) const;
|
||||
bool operator<=(const NzVector4& vec) const;
|
||||
bool operator>(const NzVector4& vec) const;
|
||||
bool operator>=(const NzVector4& vec) const;
|
||||
|
||||
static NzVector4 UnitX();
|
||||
static NzVector4 UnitY();
|
||||
static NzVector4 UnitZ();
|
||||
static NzVector4 Zero();
|
||||
|
||||
T x, y, z, w;
|
||||
};
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const NzVector4<T>& vec);
|
||||
|
||||
template<typename T> NzVector4<T> operator*(T scale, const NzVector4<T>& vec);
|
||||
template<typename T> NzVector4<T> operator/(T scale, const NzVector4<T>& vec);
|
||||
|
||||
typedef NzVector4<double> NzVector4d;
|
||||
typedef NzVector4<float> NzVector4f;
|
||||
typedef NzVector4<int> NzVector4i;
|
||||
|
||||
#include <Nazara/Math/Vector4.inl>
|
||||
|
||||
#endif // NAZARA_VECTOR4_HPP
|
||||
// Copyright (C) 2012 Rémi Bèges - Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VECTOR4_HPP
|
||||
#define NAZARA_VECTOR4_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
template<typename T> class NzVector4
|
||||
{
|
||||
public:
|
||||
NzVector4();
|
||||
NzVector4(T X, T Y, T Z, T W = 1.0);
|
||||
explicit NzVector4(T scale);
|
||||
NzVector4(T vec[4]);
|
||||
NzVector4(const NzVector3<T>& vec, T W = 1.0);
|
||||
template<typename U> explicit NzVector4(const NzVector4<U>& vec);
|
||||
NzVector4(const NzVector4& vec) = default;
|
||||
~NzVector4() = default;
|
||||
|
||||
T AbsDotProduct(const NzVector4& vec) const;
|
||||
|
||||
T DotProduct(const NzVector4& vec) const;
|
||||
|
||||
void MakeUnitX();
|
||||
void MakeUnitY();
|
||||
void MakeUnitZ();
|
||||
void MakeZero();
|
||||
|
||||
void Maximize(const NzVector4& vec);
|
||||
void Minimize(const NzVector4& vec);
|
||||
|
||||
void Normalize();
|
||||
|
||||
void Set(T X, T Y, T Z, T W = 1.0);
|
||||
void Set(T scale);
|
||||
void Set(T vec[4]);
|
||||
void Set(const NzVector3<T>& vec, T W = 1.0);
|
||||
template<typename U> void Set(const NzVector4<U>& vec);
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
operator NzString() const;
|
||||
|
||||
operator T*();
|
||||
operator const T*() const;
|
||||
|
||||
T& operator[](unsigned int i);
|
||||
T operator[](unsigned int i) const;
|
||||
|
||||
const NzVector4& operator+() const;
|
||||
NzVector4 operator-() const;
|
||||
|
||||
NzVector4 operator+(const NzVector4& vec) const;
|
||||
NzVector4 operator-(const NzVector4& vec) const;
|
||||
NzVector4 operator*(const NzVector4& vec) const;
|
||||
NzVector4 operator*(T scale) const;
|
||||
NzVector4 operator/(const NzVector4& vec) const;
|
||||
NzVector4 operator/(T scale) const;
|
||||
|
||||
NzVector4& operator+=(const NzVector4& vec);
|
||||
NzVector4& operator-=(const NzVector4& vec);
|
||||
NzVector4& operator*=(const NzVector4& vec);
|
||||
NzVector4& operator*=(T scale);
|
||||
NzVector4& operator/=(const NzVector4& vec);
|
||||
NzVector4& operator/=(T scale);
|
||||
|
||||
bool operator==(const NzVector4& vec) const;
|
||||
bool operator!=(const NzVector4& vec) const;
|
||||
bool operator<(const NzVector4& vec) const;
|
||||
bool operator<=(const NzVector4& vec) const;
|
||||
bool operator>(const NzVector4& vec) const;
|
||||
bool operator>=(const NzVector4& vec) const;
|
||||
|
||||
static NzVector4 UnitX();
|
||||
static NzVector4 UnitY();
|
||||
static NzVector4 UnitZ();
|
||||
static NzVector4 Zero();
|
||||
|
||||
T x, y, z, w;
|
||||
};
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const NzVector4<T>& vec);
|
||||
|
||||
template<typename T> NzVector4<T> operator*(T scale, const NzVector4<T>& vec);
|
||||
template<typename T> NzVector4<T> operator/(T scale, const NzVector4<T>& vec);
|
||||
|
||||
typedef NzVector4<double> NzVector4d;
|
||||
typedef NzVector4<float> NzVector4f;
|
||||
typedef NzVector4<int> NzVector4i;
|
||||
|
||||
#include <Nazara/Math/Vector4.inl>
|
||||
|
||||
#endif // NAZARA_VECTOR4_HPP
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,41 +1,41 @@
|
||||
// This file was automatically generated by Nazara
|
||||
|
||||
/*
|
||||
Nazara Engine - Renderer module
|
||||
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Context.hpp>
|
||||
#include <Nazara/Renderer/ContextParameters.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/OcclusionQuery.hpp>
|
||||
#include <Nazara/Renderer/OpenGL.hpp>
|
||||
#include <Nazara/Renderer/Renderer.hpp>
|
||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||
#include <Nazara/Renderer/RenderTargetParameters.hpp>
|
||||
#include <Nazara/Renderer/RenderTexture.hpp>
|
||||
#include <Nazara/Renderer/RenderWindow.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
// This file was automatically generated by Nazara
|
||||
|
||||
/*
|
||||
Nazara Engine - Renderer module
|
||||
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Context.hpp>
|
||||
#include <Nazara/Renderer/ContextParameters.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/OcclusionQuery.hpp>
|
||||
#include <Nazara/Renderer/OpenGL.hpp>
|
||||
#include <Nazara/Renderer/Renderer.hpp>
|
||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||
#include <Nazara/Renderer/RenderTargetParameters.hpp>
|
||||
#include <Nazara/Renderer/RenderTexture.hpp>
|
||||
#include <Nazara/Renderer/RenderWindow.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
/*
|
||||
Nazara Engine - Renderer module
|
||||
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONFIG_RENDERER_HPP
|
||||
#define NAZARA_CONFIG_RENDERER_HPP
|
||||
|
||||
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
|
||||
|
||||
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
|
||||
#define NAZARA_RENDERER_MEMORYLEAKTRACKER 0
|
||||
|
||||
// Active le paramère debug des paramètres des contextes par défaut (Perte de performances mais capable de recevoir des messages d'OpenGL)
|
||||
#define NAZARA_RENDERER_OPENGL_DEBUG 0
|
||||
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_RENDERER_SAFE 1
|
||||
|
||||
#endif // NAZARA_CONFIG_MODULENAME_HPP
|
||||
/*
|
||||
Nazara Engine - Renderer module
|
||||
|
||||
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONFIG_RENDERER_HPP
|
||||
#define NAZARA_CONFIG_RENDERER_HPP
|
||||
|
||||
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
|
||||
|
||||
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
|
||||
#define NAZARA_RENDERER_MEMORYLEAKTRACKER 0
|
||||
|
||||
// Active le paramère debug des paramètres des contextes par défaut (Perte de performances mais capable de recevoir des messages d'OpenGL)
|
||||
#define NAZARA_RENDERER_OPENGL_DEBUG 0
|
||||
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_RENDERER_SAFE 1
|
||||
|
||||
#endif // NAZARA_CONFIG_MODULENAME_HPP
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONTEXT_HPP
|
||||
#define NAZARA_CONTEXT_HPP
|
||||
|
||||
#ifdef NAZARA_RENDERER_OPENGL
|
||||
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Renderer/ContextParameters.hpp>
|
||||
|
||||
class NzContextImpl;
|
||||
|
||||
class NAZARA_API NzContext : public NzResource
|
||||
{
|
||||
friend NzContextImpl;
|
||||
|
||||
public:
|
||||
NzContext();
|
||||
~NzContext();
|
||||
|
||||
bool Create(const NzContextParameters& parameters = NzContextParameters());
|
||||
void Destroy();
|
||||
|
||||
const NzContextParameters& GetParameters() const;
|
||||
bool IsActive() const;
|
||||
bool SetActive(bool active);
|
||||
void SwapBuffers();
|
||||
|
||||
static bool EnsureContext();
|
||||
static NzContext* GetCurrent();
|
||||
static const NzContext* GetReference();
|
||||
static NzContext* GetThreadContext();
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
private:
|
||||
NzContextParameters m_parameters;
|
||||
NzContextImpl* m_impl;
|
||||
|
||||
static NzContext* s_reference;
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERER_OPENGL
|
||||
|
||||
#endif // NAZARA_CONTEXT_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONTEXT_HPP
|
||||
#define NAZARA_CONTEXT_HPP
|
||||
|
||||
#ifdef NAZARA_RENDERER_OPENGL
|
||||
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Renderer/ContextParameters.hpp>
|
||||
|
||||
class NzContextImpl;
|
||||
|
||||
class NAZARA_API NzContext : public NzResource
|
||||
{
|
||||
friend NzContextImpl;
|
||||
|
||||
public:
|
||||
NzContext();
|
||||
~NzContext();
|
||||
|
||||
bool Create(const NzContextParameters& parameters = NzContextParameters());
|
||||
void Destroy();
|
||||
|
||||
const NzContextParameters& GetParameters() const;
|
||||
bool IsActive() const;
|
||||
bool SetActive(bool active);
|
||||
void SwapBuffers();
|
||||
|
||||
static bool EnsureContext();
|
||||
static NzContext* GetCurrent();
|
||||
static const NzContext* GetReference();
|
||||
static NzContext* GetThreadContext();
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
private:
|
||||
NzContextParameters m_parameters;
|
||||
NzContextImpl* m_impl;
|
||||
|
||||
static NzContext* s_reference;
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERER_OPENGL
|
||||
|
||||
#endif // NAZARA_CONTEXT_HPP
|
||||
|
||||
@@ -1,174 +1,174 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// 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 nzAttachmentPoint
|
||||
{
|
||||
nzAttachmentPoint_Color,
|
||||
nzAttachmentPoint_Depth,
|
||||
nzAttachmentPoint_DepthStencil,
|
||||
nzAttachmentPoint_Stencil,
|
||||
|
||||
nzAttachmentPoint_Max = nzAttachmentPoint_Stencil
|
||||
};
|
||||
|
||||
enum nzBlendFunc
|
||||
{
|
||||
nzBlendFunc_DestAlpha,
|
||||
nzBlendFunc_DestColor,
|
||||
nzBlendFunc_SrcAlpha,
|
||||
nzBlendFunc_SrcColor,
|
||||
nzBlendFunc_InvDestAlpha,
|
||||
nzBlendFunc_InvDestColor,
|
||||
nzBlendFunc_InvSrcAlpha,
|
||||
nzBlendFunc_InvSrcColor,
|
||||
nzBlendFunc_One,
|
||||
nzBlendFunc_Zero,
|
||||
|
||||
nzBlendFunc_Max = nzBlendFunc_Zero
|
||||
};
|
||||
|
||||
enum nzFaceCulling
|
||||
{
|
||||
nzFaceCulling_Back,
|
||||
nzFaceCulling_Front,
|
||||
nzFaceCulling_FrontAndBack,
|
||||
|
||||
nzFaceCulling_Max = nzFaceCulling_FrontAndBack
|
||||
};
|
||||
|
||||
enum nzFaceFilling
|
||||
{
|
||||
nzFaceFilling_Point,
|
||||
nzFaceFilling_Line,
|
||||
nzFaceFilling_Fill,
|
||||
|
||||
nzFaceFilling_Max = nzFaceFilling_Fill
|
||||
};
|
||||
|
||||
enum nzMatrixType
|
||||
{
|
||||
nzMatrixType_Projection,
|
||||
nzMatrixType_View,
|
||||
nzMatrixType_World,
|
||||
|
||||
nzMatrixType_Max = nzMatrixType_World
|
||||
};
|
||||
|
||||
enum nzPixelBufferType
|
||||
{
|
||||
nzPixelBufferType_Pack,
|
||||
nzPixelBufferType_Unpack,
|
||||
|
||||
nzPixelBufferType_Max = nzPixelBufferType_Unpack
|
||||
};
|
||||
|
||||
enum nzRendererCap
|
||||
{
|
||||
nzRendererCap_AnisotropicFilter,
|
||||
nzRendererCap_FP64,
|
||||
nzRendererCap_HardwareBuffer,
|
||||
nzRendererCap_MultipleRenderTargets,
|
||||
nzRendererCap_OcclusionQuery,
|
||||
nzRendererCap_PixelBufferObject,
|
||||
nzRendererCap_RenderTexture,
|
||||
nzRendererCap_Texture3D,
|
||||
nzRendererCap_TextureCubemap,
|
||||
nzRendererCap_TextureMulti,
|
||||
nzRendererCap_TextureNPOT,
|
||||
|
||||
nzRendererCap_Max = nzRendererCap_TextureNPOT
|
||||
};
|
||||
|
||||
enum nzRendererClearFlags
|
||||
{
|
||||
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,
|
||||
|
||||
nzRendererComparison_Max = nzRendererComparison_Never
|
||||
};
|
||||
|
||||
enum nzRendererParameter
|
||||
{
|
||||
nzRendererParameter_Blend,
|
||||
nzRendererParameter_ColorWrite,
|
||||
nzRendererParameter_DepthTest,
|
||||
nzRendererParameter_DepthWrite,
|
||||
nzRendererParameter_FaceCulling,
|
||||
nzRendererParameter_Stencil,
|
||||
|
||||
nzRendererParameter_Max = nzRendererParameter_Stencil
|
||||
};
|
||||
|
||||
enum nzShaderLanguage
|
||||
{
|
||||
nzShaderLanguage_Unknown = -1,
|
||||
|
||||
nzShaderLanguage_Cg,
|
||||
nzShaderLanguage_GLSL,
|
||||
|
||||
nzShaderLanguage_Max = 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,
|
||||
|
||||
nzStencilOperation_Max = nzStencilOperation_Zero
|
||||
};
|
||||
|
||||
enum nzTextureFilter
|
||||
{
|
||||
nzTextureFilter_Unknown = -1,
|
||||
|
||||
nzTextureFilter_Bilinear,
|
||||
nzTextureFilter_Nearest,
|
||||
nzTextureFilter_Trilinear,
|
||||
|
||||
nzTextureFilter_Max = nzTextureFilter_Trilinear
|
||||
};
|
||||
|
||||
enum nzTextureWrap
|
||||
{
|
||||
nzTextureWrap_Unknown = -1,
|
||||
|
||||
nzTextureWrap_Clamp,
|
||||
nzTextureWrap_Repeat,
|
||||
|
||||
nzTextureWrap_Max = nzTextureWrap_Repeat
|
||||
};
|
||||
|
||||
#endif // NAZARA_ENUMS_RENDERER_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// 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 nzAttachmentPoint
|
||||
{
|
||||
nzAttachmentPoint_Color,
|
||||
nzAttachmentPoint_Depth,
|
||||
nzAttachmentPoint_DepthStencil,
|
||||
nzAttachmentPoint_Stencil,
|
||||
|
||||
nzAttachmentPoint_Max = nzAttachmentPoint_Stencil
|
||||
};
|
||||
|
||||
enum nzBlendFunc
|
||||
{
|
||||
nzBlendFunc_DestAlpha,
|
||||
nzBlendFunc_DestColor,
|
||||
nzBlendFunc_SrcAlpha,
|
||||
nzBlendFunc_SrcColor,
|
||||
nzBlendFunc_InvDestAlpha,
|
||||
nzBlendFunc_InvDestColor,
|
||||
nzBlendFunc_InvSrcAlpha,
|
||||
nzBlendFunc_InvSrcColor,
|
||||
nzBlendFunc_One,
|
||||
nzBlendFunc_Zero,
|
||||
|
||||
nzBlendFunc_Max = nzBlendFunc_Zero
|
||||
};
|
||||
|
||||
enum nzFaceCulling
|
||||
{
|
||||
nzFaceCulling_Back,
|
||||
nzFaceCulling_Front,
|
||||
nzFaceCulling_FrontAndBack,
|
||||
|
||||
nzFaceCulling_Max = nzFaceCulling_FrontAndBack
|
||||
};
|
||||
|
||||
enum nzFaceFilling
|
||||
{
|
||||
nzFaceFilling_Point,
|
||||
nzFaceFilling_Line,
|
||||
nzFaceFilling_Fill,
|
||||
|
||||
nzFaceFilling_Max = nzFaceFilling_Fill
|
||||
};
|
||||
|
||||
enum nzMatrixType
|
||||
{
|
||||
nzMatrixType_Projection,
|
||||
nzMatrixType_View,
|
||||
nzMatrixType_World,
|
||||
|
||||
nzMatrixType_Max = nzMatrixType_World
|
||||
};
|
||||
|
||||
enum nzPixelBufferType
|
||||
{
|
||||
nzPixelBufferType_Pack,
|
||||
nzPixelBufferType_Unpack,
|
||||
|
||||
nzPixelBufferType_Max = nzPixelBufferType_Unpack
|
||||
};
|
||||
|
||||
enum nzRendererCap
|
||||
{
|
||||
nzRendererCap_AnisotropicFilter,
|
||||
nzRendererCap_FP64,
|
||||
nzRendererCap_HardwareBuffer,
|
||||
nzRendererCap_MultipleRenderTargets,
|
||||
nzRendererCap_OcclusionQuery,
|
||||
nzRendererCap_PixelBufferObject,
|
||||
nzRendererCap_RenderTexture,
|
||||
nzRendererCap_Texture3D,
|
||||
nzRendererCap_TextureCubemap,
|
||||
nzRendererCap_TextureMulti,
|
||||
nzRendererCap_TextureNPOT,
|
||||
|
||||
nzRendererCap_Max = nzRendererCap_TextureNPOT
|
||||
};
|
||||
|
||||
enum nzRendererClearFlags
|
||||
{
|
||||
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,
|
||||
|
||||
nzRendererComparison_Max = nzRendererComparison_Never
|
||||
};
|
||||
|
||||
enum nzRendererParameter
|
||||
{
|
||||
nzRendererParameter_Blend,
|
||||
nzRendererParameter_ColorWrite,
|
||||
nzRendererParameter_DepthTest,
|
||||
nzRendererParameter_DepthWrite,
|
||||
nzRendererParameter_FaceCulling,
|
||||
nzRendererParameter_Stencil,
|
||||
|
||||
nzRendererParameter_Max = nzRendererParameter_Stencil
|
||||
};
|
||||
|
||||
enum nzShaderLanguage
|
||||
{
|
||||
nzShaderLanguage_Unknown = -1,
|
||||
|
||||
nzShaderLanguage_Cg,
|
||||
nzShaderLanguage_GLSL,
|
||||
|
||||
nzShaderLanguage_Max = 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,
|
||||
|
||||
nzStencilOperation_Max = nzStencilOperation_Zero
|
||||
};
|
||||
|
||||
enum nzTextureFilter
|
||||
{
|
||||
nzTextureFilter_Unknown = -1,
|
||||
|
||||
nzTextureFilter_Bilinear,
|
||||
nzTextureFilter_Nearest,
|
||||
nzTextureFilter_Trilinear,
|
||||
|
||||
nzTextureFilter_Max = nzTextureFilter_Trilinear
|
||||
};
|
||||
|
||||
enum nzTextureWrap
|
||||
{
|
||||
nzTextureWrap_Unknown = -1,
|
||||
|
||||
nzTextureWrap_Clamp,
|
||||
nzTextureWrap_Repeat,
|
||||
|
||||
nzTextureWrap_Max = nzTextureWrap_Repeat
|
||||
};
|
||||
|
||||
#endif // NAZARA_ENUMS_RENDERER_HPP
|
||||
|
||||
@@ -1,233 +1,233 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_OPENGL_HPP
|
||||
#define NAZARA_OPENGL_HPP
|
||||
|
||||
#ifdef NAZARA_RENDERER_OPENGL
|
||||
|
||||
// gl3.h définit WIN32_LEAN_AND_MEAN qui entre en conflit avec la définition de Nazara et doit donc être inclut en premier
|
||||
#include <GL3/glcorearb.h>
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
|
||||
// Inclusion des extensions
|
||||
#include <GL3/glext.h>
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
#include <GL3/wglext.h>
|
||||
#elif defined(NAZARA_PLATFORM_LINUX)
|
||||
#include <GL3/glxext.h>
|
||||
#endif
|
||||
|
||||
enum nzOpenGLExtension
|
||||
{
|
||||
nzOpenGLExtension_AnisotropicFilter,
|
||||
nzOpenGLExtension_DebugOutput,
|
||||
nzOpenGLExtension_FP64,
|
||||
nzOpenGLExtension_FrameBufferObject,
|
||||
nzOpenGLExtension_PixelBufferObject,
|
||||
nzOpenGLExtension_SeparateShaderObjects,
|
||||
nzOpenGLExtension_TextureArray,
|
||||
nzOpenGLExtension_TextureCompression_s3tc,
|
||||
nzOpenGLExtension_TextureStorage,
|
||||
nzOpenGLExtension_VertexArrayObject,
|
||||
|
||||
nzOpenGLExtension_Max = nzOpenGLExtension_VertexArrayObject
|
||||
};
|
||||
|
||||
using NzOpenGLFunc = void (*)();
|
||||
|
||||
namespace NzOpenGL
|
||||
{
|
||||
enum FormatType
|
||||
{
|
||||
FormatType_RenderBuffer,
|
||||
// FormatType_MultisampleTexture,
|
||||
FormatType_Texture
|
||||
};
|
||||
|
||||
struct Format
|
||||
{
|
||||
GLenum dataFormat;
|
||||
GLenum dataType;
|
||||
GLint internalFormat;
|
||||
};
|
||||
|
||||
NzOpenGLFunc GetEntry(const NzString& entryPoint);
|
||||
unsigned int GetVersion();
|
||||
bool Initialize();
|
||||
bool IsSupported(nzOpenGLExtension extension);
|
||||
bool IsSupported(const NzString& string);
|
||||
bool TranslateFormat(nzPixelFormat pixelFormat, Format* format, FormatType target);
|
||||
void Uninitialize();
|
||||
|
||||
extern GLenum Attachment[nzAttachmentPoint_Max+1];
|
||||
extern nzUInt8 AttributeIndex[nzElementUsage_Max+1];
|
||||
extern GLenum BlendFunc[nzBlendFunc_Max+1];
|
||||
extern GLenum BufferLock[nzBufferAccess_Max+1];
|
||||
extern GLenum BufferLockRange[nzBufferAccess_Max+1];
|
||||
extern GLenum BufferTarget[nzBufferType_Max+1];
|
||||
extern GLenum BufferTargetBinding[nzBufferType_Max+1];
|
||||
extern GLenum BufferUsage[nzBufferUsage_Max+1];
|
||||
extern GLenum CubemapFace[6]; // Un cube possède six faces et ça n'est pas prêt de changer
|
||||
extern GLenum ElementType[nzElementType_Max+1];
|
||||
extern GLenum FaceCulling[nzFaceCulling_Max+1];
|
||||
extern GLenum FaceFilling[nzFaceFilling_Max+1];
|
||||
extern GLenum PrimitiveType[nzPrimitiveType_Max+1];
|
||||
extern GLenum RendererComparison[nzRendererComparison_Max+1];
|
||||
extern GLenum RendererParameter[nzRendererParameter_Max+1];
|
||||
extern GLenum ShaderType[nzShaderType_Max+1];
|
||||
extern GLenum StencilOperation[nzStencilOperation_Max+1];
|
||||
extern GLenum TextureTarget[nzImageType_Max+1];
|
||||
extern GLenum TextureTargetBinding[nzImageType_Max+1];
|
||||
extern GLenum TextureTargetProxy[nzImageType_Max+1];
|
||||
}
|
||||
|
||||
NAZARA_API extern PFNGLACTIVETEXTUREPROC glActiveTexture;
|
||||
NAZARA_API extern PFNGLATTACHSHADERPROC glAttachShader;
|
||||
NAZARA_API extern PFNGLBEGINQUERYPROC glBeginQuery;
|
||||
NAZARA_API extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
|
||||
NAZARA_API extern PFNGLBINDBUFFERPROC glBindBuffer;
|
||||
NAZARA_API extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
|
||||
NAZARA_API extern PFNGLBINDFRAGDATALOCATIONPROC glBindFragDataLocation;
|
||||
NAZARA_API extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer;
|
||||
NAZARA_API extern PFNGLBINDTEXTUREPROC glBindTexture;
|
||||
NAZARA_API extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
|
||||
NAZARA_API extern PFNGLBLENDFUNCPROC glBlendFunc;
|
||||
NAZARA_API extern PFNGLBUFFERDATAPROC glBufferData;
|
||||
NAZARA_API extern PFNGLBUFFERSUBDATAPROC glBufferSubData;
|
||||
NAZARA_API extern PFNGLCLEARPROC glClear;
|
||||
NAZARA_API extern PFNGLCLEARCOLORPROC glClearColor;
|
||||
NAZARA_API extern PFNGLCLEARDEPTHPROC glClearDepth;
|
||||
NAZARA_API extern PFNGLCLEARSTENCILPROC glClearStencil;
|
||||
NAZARA_API extern PFNGLCREATEPROGRAMPROC glCreateProgram;
|
||||
NAZARA_API extern PFNGLCREATESHADERPROC glCreateShader;
|
||||
NAZARA_API extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
|
||||
NAZARA_API extern PFNGLCOLORMASKPROC glColorMask;
|
||||
NAZARA_API extern PFNGLCULLFACEPROC glCullFace;
|
||||
NAZARA_API extern PFNGLCOMPILESHADERPROC glCompileShader;
|
||||
NAZARA_API extern PFNGLCOPYTEXSUBIMAGE2DPROC glCopyTexSubImage2D;
|
||||
NAZARA_API extern PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback;
|
||||
NAZARA_API extern PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl;
|
||||
NAZARA_API extern PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert;
|
||||
NAZARA_API extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
|
||||
NAZARA_API extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
|
||||
NAZARA_API extern PFNGLDELETEPROGRAMPROC glDeleteProgram;
|
||||
NAZARA_API extern PFNGLDELETEQUERIESPROC glDeleteQueries;
|
||||
NAZARA_API extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers;
|
||||
NAZARA_API extern PFNGLDELETESHADERPROC glDeleteShader;
|
||||
NAZARA_API extern PFNGLDELETETEXTURESPROC glDeleteTextures;
|
||||
NAZARA_API extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
|
||||
NAZARA_API extern PFNGLDEPTHFUNCPROC glDepthFunc;
|
||||
NAZARA_API extern PFNGLDEPTHMASKPROC glDepthMask;
|
||||
NAZARA_API extern PFNGLDISABLEPROC glDisable;
|
||||
NAZARA_API extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
|
||||
NAZARA_API extern PFNGLDRAWARRAYSPROC glDrawArrays;
|
||||
NAZARA_API extern PFNGLDRAWBUFFERPROC glDrawBuffer;
|
||||
NAZARA_API extern PFNGLDRAWBUFFERSPROC glDrawBuffers;
|
||||
NAZARA_API extern PFNGLDRAWELEMENTSPROC glDrawElements;
|
||||
NAZARA_API extern PFNGLENDQUERYPROC glEndQuery;
|
||||
NAZARA_API extern PFNGLFLUSHPROC glFlush;
|
||||
NAZARA_API extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer;
|
||||
NAZARA_API extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture;
|
||||
NAZARA_API extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D;
|
||||
NAZARA_API extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
|
||||
NAZARA_API extern PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D;
|
||||
NAZARA_API extern PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer;
|
||||
NAZARA_API extern PFNGLENABLEPROC glEnable;
|
||||
NAZARA_API extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
|
||||
NAZARA_API extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap;
|
||||
NAZARA_API extern PFNGLGENBUFFERSPROC glGenBuffers;
|
||||
NAZARA_API extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
||||
NAZARA_API extern PFNGLGENQUERIESPROC glGenQueries;
|
||||
NAZARA_API extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
|
||||
NAZARA_API extern PFNGLGENTEXTURESPROC glGenTextures;
|
||||
NAZARA_API extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
|
||||
NAZARA_API extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv;
|
||||
NAZARA_API extern PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog;
|
||||
NAZARA_API extern PFNGLGETERRORPROC glGetError;
|
||||
NAZARA_API extern PFNGLGETINTEGERVPROC glGetIntegerv;
|
||||
NAZARA_API extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
|
||||
NAZARA_API extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
|
||||
NAZARA_API extern PFNGLGETQUERYIVPROC glGetQueryiv;
|
||||
NAZARA_API extern PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv;
|
||||
NAZARA_API extern PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv;
|
||||
NAZARA_API extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
|
||||
NAZARA_API extern PFNGLGETSHADERIVPROC glGetShaderiv;
|
||||
NAZARA_API extern PFNGLGETSHADERSOURCEPROC glGetShaderSource;
|
||||
NAZARA_API extern PFNGLGETSTRINGPROC glGetString;
|
||||
NAZARA_API extern PFNGLGETSTRINGIPROC glGetStringi;
|
||||
NAZARA_API extern PFNGLGETTEXIMAGEPROC glGetTexImage;
|
||||
NAZARA_API extern PFNGLGETTEXLEVELPARAMETERFVPROC glGetTexLevelParameterfv;
|
||||
NAZARA_API extern PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv;
|
||||
NAZARA_API extern PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv;
|
||||
NAZARA_API extern PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv;
|
||||
NAZARA_API extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
|
||||
NAZARA_API extern PFNGLLINKPROGRAMPROC glLinkProgram;
|
||||
NAZARA_API extern PFNGLMAPBUFFERPROC glMapBuffer;
|
||||
NAZARA_API extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
|
||||
NAZARA_API extern PFNGLPIXELSTOREIPROC glPixelStorei;
|
||||
NAZARA_API extern PFNGLPOLYGONMODEPROC glPolygonMode;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM2DVPROC glProgramUniform2dv;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM2FVPROC glProgramUniform2fv;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM3DVPROC glProgramUniform3dv;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM3FVPROC glProgramUniform3fv;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM4DVPROC glProgramUniform4dv;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM4FVPROC glProgramUniform4fv;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORMMATRIX4DVPROC glProgramUniformMatrix4dv;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORMMATRIX4FVPROC glProgramUniformMatrix4fv;
|
||||
NAZARA_API extern PFNGLREADPIXELSPROC glReadPixels;
|
||||
NAZARA_API extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage;
|
||||
NAZARA_API extern PFNGLSCISSORPROC glScissor;
|
||||
NAZARA_API extern PFNGLSHADERSOURCEPROC glShaderSource;
|
||||
NAZARA_API extern PFNGLSTENCILFUNCPROC glStencilFunc;
|
||||
NAZARA_API extern PFNGLSTENCILOPPROC glStencilOp;
|
||||
NAZARA_API extern PFNGLTEXIMAGE1DPROC glTexImage1D;
|
||||
NAZARA_API extern PFNGLTEXIMAGE2DPROC glTexImage2D;
|
||||
NAZARA_API extern PFNGLTEXIMAGE3DPROC glTexImage3D;
|
||||
NAZARA_API extern PFNGLTEXPARAMETERFPROC glTexParameterf;
|
||||
NAZARA_API extern PFNGLTEXPARAMETERIPROC glTexParameteri;
|
||||
NAZARA_API extern PFNGLTEXSTORAGE1DPROC glTexStorage1D;
|
||||
NAZARA_API extern PFNGLTEXSTORAGE2DPROC glTexStorage2D;
|
||||
NAZARA_API extern PFNGLTEXSTORAGE3DPROC glTexStorage3D;
|
||||
NAZARA_API extern PFNGLTEXSUBIMAGE1DPROC glTexSubImage1D;
|
||||
NAZARA_API extern PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D;
|
||||
NAZARA_API extern PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D;
|
||||
NAZARA_API extern PFNGLUNIFORM1DPROC glUniform1d;
|
||||
NAZARA_API extern PFNGLUNIFORM1FPROC glUniform1f;
|
||||
NAZARA_API extern PFNGLUNIFORM1IPROC glUniform1i;
|
||||
NAZARA_API extern PFNGLUNIFORM2DVPROC glUniform2dv;
|
||||
NAZARA_API extern PFNGLUNIFORM2FVPROC glUniform2fv;
|
||||
NAZARA_API extern PFNGLUNIFORM3DVPROC glUniform3dv;
|
||||
NAZARA_API extern PFNGLUNIFORM3FVPROC glUniform3fv;
|
||||
NAZARA_API extern PFNGLUNIFORM4DVPROC glUniform4dv;
|
||||
NAZARA_API extern PFNGLUNIFORM4FVPROC glUniform4fv;
|
||||
NAZARA_API extern PFNGLUNIFORMMATRIX4DVPROC glUniformMatrix4dv;
|
||||
NAZARA_API extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv;
|
||||
NAZARA_API extern PFNGLUNMAPBUFFERPROC glUnmapBuffer;
|
||||
NAZARA_API extern PFNGLUSEPROGRAMPROC glUseProgram;
|
||||
NAZARA_API extern PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f;
|
||||
NAZARA_API extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
|
||||
NAZARA_API extern PFNGLVIEWPORTPROC glViewport;
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
NAZARA_API extern PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat;
|
||||
NAZARA_API extern PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs;
|
||||
NAZARA_API extern PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB;
|
||||
NAZARA_API extern PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT;
|
||||
NAZARA_API extern PFNWGLSWAPINTERVALEXTPROC wglSwapInterval;
|
||||
#elif defined(NAZARA_PLATFORM_LINUX)
|
||||
NAZARA_API extern PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs;
|
||||
NAZARA_API extern PFNGLXSWAPINTERVALSGIPROC glXSwapInterval;
|
||||
#endif
|
||||
|
||||
#endif // NAZARA_RENDERER_OPENGL
|
||||
|
||||
#endif // NAZARA_OPENGL_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_OPENGL_HPP
|
||||
#define NAZARA_OPENGL_HPP
|
||||
|
||||
#ifdef NAZARA_RENDERER_OPENGL
|
||||
|
||||
// gl3.h définit WIN32_LEAN_AND_MEAN qui entre en conflit avec la définition de Nazara et doit donc être inclut en premier
|
||||
#include <GL3/glcorearb.h>
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
|
||||
// Inclusion des extensions
|
||||
#include <GL3/glext.h>
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
#include <GL3/wglext.h>
|
||||
#elif defined(NAZARA_PLATFORM_LINUX)
|
||||
#include <GL3/glxext.h>
|
||||
#endif
|
||||
|
||||
enum nzOpenGLExtension
|
||||
{
|
||||
nzOpenGLExtension_AnisotropicFilter,
|
||||
nzOpenGLExtension_DebugOutput,
|
||||
nzOpenGLExtension_FP64,
|
||||
nzOpenGLExtension_FrameBufferObject,
|
||||
nzOpenGLExtension_PixelBufferObject,
|
||||
nzOpenGLExtension_SeparateShaderObjects,
|
||||
nzOpenGLExtension_TextureArray,
|
||||
nzOpenGLExtension_TextureCompression_s3tc,
|
||||
nzOpenGLExtension_TextureStorage,
|
||||
nzOpenGLExtension_VertexArrayObject,
|
||||
|
||||
nzOpenGLExtension_Max = nzOpenGLExtension_VertexArrayObject
|
||||
};
|
||||
|
||||
using NzOpenGLFunc = void (*)();
|
||||
|
||||
namespace NzOpenGL
|
||||
{
|
||||
enum FormatType
|
||||
{
|
||||
FormatType_RenderBuffer,
|
||||
// FormatType_MultisampleTexture,
|
||||
FormatType_Texture
|
||||
};
|
||||
|
||||
struct Format
|
||||
{
|
||||
GLenum dataFormat;
|
||||
GLenum dataType;
|
||||
GLint internalFormat;
|
||||
};
|
||||
|
||||
NzOpenGLFunc GetEntry(const NzString& entryPoint);
|
||||
unsigned int GetVersion();
|
||||
bool Initialize();
|
||||
bool IsSupported(nzOpenGLExtension extension);
|
||||
bool IsSupported(const NzString& string);
|
||||
bool TranslateFormat(nzPixelFormat pixelFormat, Format* format, FormatType target);
|
||||
void Uninitialize();
|
||||
|
||||
extern GLenum Attachment[nzAttachmentPoint_Max+1];
|
||||
extern nzUInt8 AttributeIndex[nzElementUsage_Max+1];
|
||||
extern GLenum BlendFunc[nzBlendFunc_Max+1];
|
||||
extern GLenum BufferLock[nzBufferAccess_Max+1];
|
||||
extern GLenum BufferLockRange[nzBufferAccess_Max+1];
|
||||
extern GLenum BufferTarget[nzBufferType_Max+1];
|
||||
extern GLenum BufferTargetBinding[nzBufferType_Max+1];
|
||||
extern GLenum BufferUsage[nzBufferUsage_Max+1];
|
||||
extern GLenum CubemapFace[6]; // Un cube possède six faces et ça n'est pas prêt de changer
|
||||
extern GLenum ElementType[nzElementType_Max+1];
|
||||
extern GLenum FaceCulling[nzFaceCulling_Max+1];
|
||||
extern GLenum FaceFilling[nzFaceFilling_Max+1];
|
||||
extern GLenum PrimitiveType[nzPrimitiveType_Max+1];
|
||||
extern GLenum RendererComparison[nzRendererComparison_Max+1];
|
||||
extern GLenum RendererParameter[nzRendererParameter_Max+1];
|
||||
extern GLenum ShaderType[nzShaderType_Max+1];
|
||||
extern GLenum StencilOperation[nzStencilOperation_Max+1];
|
||||
extern GLenum TextureTarget[nzImageType_Max+1];
|
||||
extern GLenum TextureTargetBinding[nzImageType_Max+1];
|
||||
extern GLenum TextureTargetProxy[nzImageType_Max+1];
|
||||
}
|
||||
|
||||
NAZARA_API extern PFNGLACTIVETEXTUREPROC glActiveTexture;
|
||||
NAZARA_API extern PFNGLATTACHSHADERPROC glAttachShader;
|
||||
NAZARA_API extern PFNGLBEGINQUERYPROC glBeginQuery;
|
||||
NAZARA_API extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
|
||||
NAZARA_API extern PFNGLBINDBUFFERPROC glBindBuffer;
|
||||
NAZARA_API extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
|
||||
NAZARA_API extern PFNGLBINDFRAGDATALOCATIONPROC glBindFragDataLocation;
|
||||
NAZARA_API extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer;
|
||||
NAZARA_API extern PFNGLBINDTEXTUREPROC glBindTexture;
|
||||
NAZARA_API extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
|
||||
NAZARA_API extern PFNGLBLENDFUNCPROC glBlendFunc;
|
||||
NAZARA_API extern PFNGLBUFFERDATAPROC glBufferData;
|
||||
NAZARA_API extern PFNGLBUFFERSUBDATAPROC glBufferSubData;
|
||||
NAZARA_API extern PFNGLCLEARPROC glClear;
|
||||
NAZARA_API extern PFNGLCLEARCOLORPROC glClearColor;
|
||||
NAZARA_API extern PFNGLCLEARDEPTHPROC glClearDepth;
|
||||
NAZARA_API extern PFNGLCLEARSTENCILPROC glClearStencil;
|
||||
NAZARA_API extern PFNGLCREATEPROGRAMPROC glCreateProgram;
|
||||
NAZARA_API extern PFNGLCREATESHADERPROC glCreateShader;
|
||||
NAZARA_API extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
|
||||
NAZARA_API extern PFNGLCOLORMASKPROC glColorMask;
|
||||
NAZARA_API extern PFNGLCULLFACEPROC glCullFace;
|
||||
NAZARA_API extern PFNGLCOMPILESHADERPROC glCompileShader;
|
||||
NAZARA_API extern PFNGLCOPYTEXSUBIMAGE2DPROC glCopyTexSubImage2D;
|
||||
NAZARA_API extern PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback;
|
||||
NAZARA_API extern PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl;
|
||||
NAZARA_API extern PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert;
|
||||
NAZARA_API extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
|
||||
NAZARA_API extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
|
||||
NAZARA_API extern PFNGLDELETEPROGRAMPROC glDeleteProgram;
|
||||
NAZARA_API extern PFNGLDELETEQUERIESPROC glDeleteQueries;
|
||||
NAZARA_API extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers;
|
||||
NAZARA_API extern PFNGLDELETESHADERPROC glDeleteShader;
|
||||
NAZARA_API extern PFNGLDELETETEXTURESPROC glDeleteTextures;
|
||||
NAZARA_API extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
|
||||
NAZARA_API extern PFNGLDEPTHFUNCPROC glDepthFunc;
|
||||
NAZARA_API extern PFNGLDEPTHMASKPROC glDepthMask;
|
||||
NAZARA_API extern PFNGLDISABLEPROC glDisable;
|
||||
NAZARA_API extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
|
||||
NAZARA_API extern PFNGLDRAWARRAYSPROC glDrawArrays;
|
||||
NAZARA_API extern PFNGLDRAWBUFFERPROC glDrawBuffer;
|
||||
NAZARA_API extern PFNGLDRAWBUFFERSPROC glDrawBuffers;
|
||||
NAZARA_API extern PFNGLDRAWELEMENTSPROC glDrawElements;
|
||||
NAZARA_API extern PFNGLENDQUERYPROC glEndQuery;
|
||||
NAZARA_API extern PFNGLFLUSHPROC glFlush;
|
||||
NAZARA_API extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer;
|
||||
NAZARA_API extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture;
|
||||
NAZARA_API extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D;
|
||||
NAZARA_API extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
|
||||
NAZARA_API extern PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D;
|
||||
NAZARA_API extern PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer;
|
||||
NAZARA_API extern PFNGLENABLEPROC glEnable;
|
||||
NAZARA_API extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
|
||||
NAZARA_API extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap;
|
||||
NAZARA_API extern PFNGLGENBUFFERSPROC glGenBuffers;
|
||||
NAZARA_API extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
||||
NAZARA_API extern PFNGLGENQUERIESPROC glGenQueries;
|
||||
NAZARA_API extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
|
||||
NAZARA_API extern PFNGLGENTEXTURESPROC glGenTextures;
|
||||
NAZARA_API extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
|
||||
NAZARA_API extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv;
|
||||
NAZARA_API extern PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog;
|
||||
NAZARA_API extern PFNGLGETERRORPROC glGetError;
|
||||
NAZARA_API extern PFNGLGETINTEGERVPROC glGetIntegerv;
|
||||
NAZARA_API extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
|
||||
NAZARA_API extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
|
||||
NAZARA_API extern PFNGLGETQUERYIVPROC glGetQueryiv;
|
||||
NAZARA_API extern PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv;
|
||||
NAZARA_API extern PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv;
|
||||
NAZARA_API extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
|
||||
NAZARA_API extern PFNGLGETSHADERIVPROC glGetShaderiv;
|
||||
NAZARA_API extern PFNGLGETSHADERSOURCEPROC glGetShaderSource;
|
||||
NAZARA_API extern PFNGLGETSTRINGPROC glGetString;
|
||||
NAZARA_API extern PFNGLGETSTRINGIPROC glGetStringi;
|
||||
NAZARA_API extern PFNGLGETTEXIMAGEPROC glGetTexImage;
|
||||
NAZARA_API extern PFNGLGETTEXLEVELPARAMETERFVPROC glGetTexLevelParameterfv;
|
||||
NAZARA_API extern PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv;
|
||||
NAZARA_API extern PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv;
|
||||
NAZARA_API extern PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv;
|
||||
NAZARA_API extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
|
||||
NAZARA_API extern PFNGLLINKPROGRAMPROC glLinkProgram;
|
||||
NAZARA_API extern PFNGLMAPBUFFERPROC glMapBuffer;
|
||||
NAZARA_API extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
|
||||
NAZARA_API extern PFNGLPIXELSTOREIPROC glPixelStorei;
|
||||
NAZARA_API extern PFNGLPOLYGONMODEPROC glPolygonMode;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM2DVPROC glProgramUniform2dv;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM2FVPROC glProgramUniform2fv;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM3DVPROC glProgramUniform3dv;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM3FVPROC glProgramUniform3fv;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM4DVPROC glProgramUniform4dv;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORM4FVPROC glProgramUniform4fv;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORMMATRIX4DVPROC glProgramUniformMatrix4dv;
|
||||
NAZARA_API extern PFNGLPROGRAMUNIFORMMATRIX4FVPROC glProgramUniformMatrix4fv;
|
||||
NAZARA_API extern PFNGLREADPIXELSPROC glReadPixels;
|
||||
NAZARA_API extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage;
|
||||
NAZARA_API extern PFNGLSCISSORPROC glScissor;
|
||||
NAZARA_API extern PFNGLSHADERSOURCEPROC glShaderSource;
|
||||
NAZARA_API extern PFNGLSTENCILFUNCPROC glStencilFunc;
|
||||
NAZARA_API extern PFNGLSTENCILOPPROC glStencilOp;
|
||||
NAZARA_API extern PFNGLTEXIMAGE1DPROC glTexImage1D;
|
||||
NAZARA_API extern PFNGLTEXIMAGE2DPROC glTexImage2D;
|
||||
NAZARA_API extern PFNGLTEXIMAGE3DPROC glTexImage3D;
|
||||
NAZARA_API extern PFNGLTEXPARAMETERFPROC glTexParameterf;
|
||||
NAZARA_API extern PFNGLTEXPARAMETERIPROC glTexParameteri;
|
||||
NAZARA_API extern PFNGLTEXSTORAGE1DPROC glTexStorage1D;
|
||||
NAZARA_API extern PFNGLTEXSTORAGE2DPROC glTexStorage2D;
|
||||
NAZARA_API extern PFNGLTEXSTORAGE3DPROC glTexStorage3D;
|
||||
NAZARA_API extern PFNGLTEXSUBIMAGE1DPROC glTexSubImage1D;
|
||||
NAZARA_API extern PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D;
|
||||
NAZARA_API extern PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D;
|
||||
NAZARA_API extern PFNGLUNIFORM1DPROC glUniform1d;
|
||||
NAZARA_API extern PFNGLUNIFORM1FPROC glUniform1f;
|
||||
NAZARA_API extern PFNGLUNIFORM1IPROC glUniform1i;
|
||||
NAZARA_API extern PFNGLUNIFORM2DVPROC glUniform2dv;
|
||||
NAZARA_API extern PFNGLUNIFORM2FVPROC glUniform2fv;
|
||||
NAZARA_API extern PFNGLUNIFORM3DVPROC glUniform3dv;
|
||||
NAZARA_API extern PFNGLUNIFORM3FVPROC glUniform3fv;
|
||||
NAZARA_API extern PFNGLUNIFORM4DVPROC glUniform4dv;
|
||||
NAZARA_API extern PFNGLUNIFORM4FVPROC glUniform4fv;
|
||||
NAZARA_API extern PFNGLUNIFORMMATRIX4DVPROC glUniformMatrix4dv;
|
||||
NAZARA_API extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv;
|
||||
NAZARA_API extern PFNGLUNMAPBUFFERPROC glUnmapBuffer;
|
||||
NAZARA_API extern PFNGLUSEPROGRAMPROC glUseProgram;
|
||||
NAZARA_API extern PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f;
|
||||
NAZARA_API extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
|
||||
NAZARA_API extern PFNGLVIEWPORTPROC glViewport;
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
NAZARA_API extern PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat;
|
||||
NAZARA_API extern PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs;
|
||||
NAZARA_API extern PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB;
|
||||
NAZARA_API extern PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT;
|
||||
NAZARA_API extern PFNWGLSWAPINTERVALEXTPROC wglSwapInterval;
|
||||
#elif defined(NAZARA_PLATFORM_LINUX)
|
||||
NAZARA_API extern PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs;
|
||||
NAZARA_API extern PFNGLXSWAPINTERVALSGIPROC glXSwapInterval;
|
||||
#endif
|
||||
|
||||
#endif // NAZARA_RENDERER_OPENGL
|
||||
|
||||
#endif // NAZARA_OPENGL_HPP
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RENDERTARGET_HPP
|
||||
#define NAZARA_RENDERTARGET_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/RenderTargetParameters.hpp>
|
||||
|
||||
class NzRenderer;
|
||||
|
||||
class NAZARA_API NzRenderTarget
|
||||
{
|
||||
friend class NzRenderer;
|
||||
|
||||
public:
|
||||
NzRenderTarget() = default;
|
||||
virtual ~NzRenderTarget();
|
||||
|
||||
virtual unsigned int GetHeight() const = 0;
|
||||
virtual NzRenderTargetParameters GetParameters() const = 0;
|
||||
virtual unsigned int GetWidth() const = 0;
|
||||
|
||||
bool IsActive() const;
|
||||
virtual bool IsRenderable() const = 0;
|
||||
|
||||
bool SetActive(bool active);
|
||||
|
||||
// Fonctions OpenGL
|
||||
virtual bool HasContext() const = 0;
|
||||
|
||||
protected:
|
||||
virtual bool Activate() = 0;
|
||||
virtual void Desactivate();
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERTARGET_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RENDERTARGET_HPP
|
||||
#define NAZARA_RENDERTARGET_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/RenderTargetParameters.hpp>
|
||||
|
||||
class NzRenderer;
|
||||
|
||||
class NAZARA_API NzRenderTarget
|
||||
{
|
||||
friend class NzRenderer;
|
||||
|
||||
public:
|
||||
NzRenderTarget() = default;
|
||||
virtual ~NzRenderTarget();
|
||||
|
||||
virtual unsigned int GetHeight() const = 0;
|
||||
virtual NzRenderTargetParameters GetParameters() const = 0;
|
||||
virtual unsigned int GetWidth() const = 0;
|
||||
|
||||
bool IsActive() const;
|
||||
virtual bool IsRenderable() const = 0;
|
||||
|
||||
bool SetActive(bool active);
|
||||
|
||||
// Fonctions OpenGL
|
||||
virtual bool HasContext() const = 0;
|
||||
|
||||
protected:
|
||||
virtual bool Activate() = 0;
|
||||
virtual void Desactivate();
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERTARGET_HPP
|
||||
|
||||
@@ -1,60 +1,60 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RENDERTEXTURE_HPP
|
||||
#define NAZARA_RENDERTEXTURE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/ResourceListener.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
|
||||
struct NzRenderTextureImpl;
|
||||
|
||||
class NAZARA_API NzRenderTexture : public NzRenderTarget, NzResourceListener, NzNonCopyable
|
||||
{
|
||||
public:
|
||||
NzRenderTexture() = default;
|
||||
~NzRenderTexture();
|
||||
|
||||
bool AttachBuffer(nzAttachmentPoint attachmentPoint, nzUInt8 index, nzPixelFormat format);
|
||||
bool AttachTexture(nzAttachmentPoint attachmentPoint, nzUInt8 index, NzTexture* texture);
|
||||
bool AttachTexture(nzAttachmentPoint attachmentPoint, nzUInt8 index, NzTexture* texture, unsigned int z);
|
||||
|
||||
bool Create(unsigned int width, unsigned int height, bool lock = false);
|
||||
void Destroy();
|
||||
|
||||
void Detach(nzAttachmentPoint attachmentPoint, nzUInt8 index);
|
||||
|
||||
unsigned int GetHeight() const;
|
||||
NzRenderTargetParameters GetParameters() const;
|
||||
unsigned int GetWidth() const;
|
||||
|
||||
bool IsComplete() const;
|
||||
bool IsRenderable() const;
|
||||
bool IsValid() const;
|
||||
|
||||
bool Lock() const;
|
||||
void Unlock() const;
|
||||
|
||||
// Fonctions OpenGL
|
||||
bool HasContext() const;
|
||||
|
||||
static bool IsSupported();
|
||||
|
||||
protected:
|
||||
bool Activate() override;
|
||||
void Desactivate() override;
|
||||
|
||||
private:
|
||||
void OnResourceDestroy(const NzResource* resource, int index) override;
|
||||
|
||||
NzRenderTextureImpl* m_impl = nullptr;
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERTEXTURE_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RENDERTEXTURE_HPP
|
||||
#define NAZARA_RENDERTEXTURE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/ResourceListener.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
|
||||
struct NzRenderTextureImpl;
|
||||
|
||||
class NAZARA_API NzRenderTexture : public NzRenderTarget, NzResourceListener, NzNonCopyable
|
||||
{
|
||||
public:
|
||||
NzRenderTexture() = default;
|
||||
~NzRenderTexture();
|
||||
|
||||
bool AttachBuffer(nzAttachmentPoint attachmentPoint, nzUInt8 index, nzPixelFormat format);
|
||||
bool AttachTexture(nzAttachmentPoint attachmentPoint, nzUInt8 index, NzTexture* texture);
|
||||
bool AttachTexture(nzAttachmentPoint attachmentPoint, nzUInt8 index, NzTexture* texture, unsigned int z);
|
||||
|
||||
bool Create(unsigned int width, unsigned int height, bool lock = false);
|
||||
void Destroy();
|
||||
|
||||
void Detach(nzAttachmentPoint attachmentPoint, nzUInt8 index);
|
||||
|
||||
unsigned int GetHeight() const;
|
||||
NzRenderTargetParameters GetParameters() const;
|
||||
unsigned int GetWidth() const;
|
||||
|
||||
bool IsComplete() const;
|
||||
bool IsRenderable() const;
|
||||
bool IsValid() const;
|
||||
|
||||
bool Lock() const;
|
||||
void Unlock() const;
|
||||
|
||||
// Fonctions OpenGL
|
||||
bool HasContext() const;
|
||||
|
||||
static bool IsSupported();
|
||||
|
||||
protected:
|
||||
bool Activate() override;
|
||||
void Desactivate() override;
|
||||
|
||||
private:
|
||||
void OnResourceDestroy(const NzResource* resource, int index) override;
|
||||
|
||||
NzRenderTextureImpl* m_impl = nullptr;
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERTEXTURE_HPP
|
||||
|
||||
@@ -1,68 +1,68 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// Interface inspirée de la SFML par Laurent Gomila
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RENDERWINDOW_HPP
|
||||
#define NAZARA_RENDERWINDOW_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/ContextParameters.hpp>
|
||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||
#include <Nazara/Utility/Window.hpp>
|
||||
|
||||
class NzContext;
|
||||
class NzImage;
|
||||
class NzTexture;
|
||||
struct NzContextParameters;
|
||||
|
||||
class NAZARA_API NzRenderWindow : public NzRenderTarget, public NzWindow
|
||||
{
|
||||
public:
|
||||
NzRenderWindow() = default;
|
||||
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 = nzWindowStyle_Default, const NzContextParameters& parameters = NzContextParameters());
|
||||
bool Create(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters());
|
||||
|
||||
void Display();
|
||||
|
||||
void EnableVerticalSync(bool enabled);
|
||||
|
||||
unsigned int GetHeight() const;
|
||||
NzRenderTargetParameters GetParameters() const;
|
||||
unsigned int GetWidth() const;
|
||||
|
||||
bool IsRenderable() const;
|
||||
bool IsValid() const;
|
||||
|
||||
void SetFramerateLimit(unsigned int limit);
|
||||
|
||||
// Fonctions OpenGL
|
||||
NzContextParameters GetContextParameters() const;
|
||||
bool HasContext() const;
|
||||
|
||||
protected:
|
||||
bool Activate() override;
|
||||
|
||||
private:
|
||||
bool OnWindowCreated() override;
|
||||
void OnWindowDestroy() override;
|
||||
|
||||
NzClock m_clock;
|
||||
NzContextParameters m_parameters;
|
||||
NzContext* m_context = nullptr;
|
||||
unsigned int m_framerateLimit = 0;
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERWINDOW_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// Interface inspirée de la SFML par Laurent Gomila
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RENDERWINDOW_HPP
|
||||
#define NAZARA_RENDERWINDOW_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/ContextParameters.hpp>
|
||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||
#include <Nazara/Utility/Window.hpp>
|
||||
|
||||
class NzContext;
|
||||
class NzImage;
|
||||
class NzTexture;
|
||||
struct NzContextParameters;
|
||||
|
||||
class NAZARA_API NzRenderWindow : public NzRenderTarget, public NzWindow
|
||||
{
|
||||
public:
|
||||
NzRenderWindow() = default;
|
||||
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 = nzWindowStyle_Default, const NzContextParameters& parameters = NzContextParameters());
|
||||
bool Create(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters());
|
||||
|
||||
void Display();
|
||||
|
||||
void EnableVerticalSync(bool enabled);
|
||||
|
||||
unsigned int GetHeight() const;
|
||||
NzRenderTargetParameters GetParameters() const;
|
||||
unsigned int GetWidth() const;
|
||||
|
||||
bool IsRenderable() const;
|
||||
bool IsValid() const;
|
||||
|
||||
void SetFramerateLimit(unsigned int limit);
|
||||
|
||||
// Fonctions OpenGL
|
||||
NzContextParameters GetContextParameters() const;
|
||||
bool HasContext() const;
|
||||
|
||||
protected:
|
||||
bool Activate() override;
|
||||
|
||||
private:
|
||||
bool OnWindowCreated() override;
|
||||
void OnWindowDestroy() override;
|
||||
|
||||
NzClock m_clock;
|
||||
NzContextParameters m_parameters;
|
||||
NzContext* m_context = nullptr;
|
||||
unsigned int m_framerateLimit = 0;
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERWINDOW_HPP
|
||||
|
||||
@@ -1,92 +1,92 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_TEXTURE_HPP
|
||||
#define NAZARA_TEXTURE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Utility/Image.hpp>
|
||||
#include <Nazara/Utility/PixelFormat.hpp>
|
||||
|
||||
class NzRenderTexture;
|
||||
struct NzTextureImpl;
|
||||
|
||||
class NAZARA_API NzTexture : public NzResource, NzNonCopyable
|
||||
{
|
||||
friend NzRenderTexture;
|
||||
friend class NzShader;
|
||||
|
||||
public:
|
||||
NzTexture();
|
||||
explicit NzTexture(const NzImage& image);
|
||||
~NzTexture();
|
||||
|
||||
bool Create(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, nzUInt8 levelCount = 1, bool lock = false);
|
||||
void Destroy();
|
||||
|
||||
bool Download(NzImage* image) const;
|
||||
|
||||
bool EnableMipmapping(bool enable);
|
||||
|
||||
unsigned int GetAnisotropyLevel() const;
|
||||
nzUInt8 GetBPP() const;
|
||||
unsigned int GetDepth() const;
|
||||
nzTextureFilter GetFilterMode() const;
|
||||
nzPixelFormat GetFormat() const;
|
||||
unsigned int GetHeight() const;
|
||||
nzImageType GetType() const;
|
||||
unsigned int GetWidth() const;
|
||||
nzTextureWrap GetWrapMode() const;
|
||||
|
||||
bool IsCompressed() const;
|
||||
bool IsCubemap() const;
|
||||
bool IsTarget() const;
|
||||
bool IsValid() const;
|
||||
|
||||
bool LoadFromFile(const NzString& filePath, const NzImageParams& params = NzImageParams());
|
||||
bool LoadFromImage(const NzImage& image);
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const NzImageParams& params = NzImageParams());
|
||||
bool LoadFromStream(NzInputStream& stream, const NzImageParams& params = NzImageParams());
|
||||
|
||||
bool Lock();
|
||||
|
||||
bool SetAnisotropyLevel(unsigned int anistropyLevel);
|
||||
bool SetFilterMode(nzTextureFilter filter);
|
||||
bool SetMipmapRange(nzUInt8 minLevel, nzUInt8 maxLevel);
|
||||
bool SetWrapMode(nzTextureWrap wrap);
|
||||
|
||||
bool Update(const NzImage& image, nzUInt8 level = 0);
|
||||
bool Update(const NzImage& image, const NzRectui& rect, unsigned int z = 0, nzUInt8 level = 0);
|
||||
bool Update(const NzImage& image, const NzCubeui& cube, nzUInt8 level = 0);
|
||||
bool Update(const nzUInt8* pixels, nzUInt8 level = 0);
|
||||
bool Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z = 0, nzUInt8 level = 0);
|
||||
bool Update(const nzUInt8* pixels, const NzCubeui& cube, nzUInt8 level = 0);
|
||||
bool UpdateFace(nzCubemapFace face, const NzImage& image, nzUInt8 level = 0);
|
||||
bool UpdateFace(nzCubemapFace face, const NzImage& image, const NzRectui& rect, nzUInt8 level = 0);
|
||||
bool UpdateFace(nzCubemapFace face, const nzUInt8* pixels, nzUInt8 level = 0);
|
||||
bool UpdateFace(nzCubemapFace face, const nzUInt8* pixels, const NzRectui& rect, nzUInt8 level = 0);
|
||||
|
||||
void Unlock();
|
||||
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
bool Prepare() const;
|
||||
|
||||
static unsigned int GetValidSize(unsigned int size);
|
||||
static bool IsFormatSupported(nzPixelFormat format);
|
||||
static bool IsMipmappingSupported();
|
||||
static bool IsTypeSupported(nzImageType type);
|
||||
|
||||
private:
|
||||
NzRenderTexture* GetRenderTexture() const;
|
||||
void SetRenderTexture(NzRenderTexture* renderTexture);
|
||||
|
||||
NzTextureImpl* m_impl;
|
||||
};
|
||||
|
||||
#endif // NAZARA_TEXTURE_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_TEXTURE_HPP
|
||||
#define NAZARA_TEXTURE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Utility/Image.hpp>
|
||||
#include <Nazara/Utility/PixelFormat.hpp>
|
||||
|
||||
class NzRenderTexture;
|
||||
struct NzTextureImpl;
|
||||
|
||||
class NAZARA_API NzTexture : public NzResource, NzNonCopyable
|
||||
{
|
||||
friend NzRenderTexture;
|
||||
friend class NzShader;
|
||||
|
||||
public:
|
||||
NzTexture();
|
||||
explicit NzTexture(const NzImage& image);
|
||||
~NzTexture();
|
||||
|
||||
bool Create(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, nzUInt8 levelCount = 1, bool lock = false);
|
||||
void Destroy();
|
||||
|
||||
bool Download(NzImage* image) const;
|
||||
|
||||
bool EnableMipmapping(bool enable);
|
||||
|
||||
unsigned int GetAnisotropyLevel() const;
|
||||
nzUInt8 GetBPP() const;
|
||||
unsigned int GetDepth() const;
|
||||
nzTextureFilter GetFilterMode() const;
|
||||
nzPixelFormat GetFormat() const;
|
||||
unsigned int GetHeight() const;
|
||||
nzImageType GetType() const;
|
||||
unsigned int GetWidth() const;
|
||||
nzTextureWrap GetWrapMode() const;
|
||||
|
||||
bool IsCompressed() const;
|
||||
bool IsCubemap() const;
|
||||
bool IsTarget() const;
|
||||
bool IsValid() const;
|
||||
|
||||
bool LoadFromFile(const NzString& filePath, const NzImageParams& params = NzImageParams());
|
||||
bool LoadFromImage(const NzImage& image);
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const NzImageParams& params = NzImageParams());
|
||||
bool LoadFromStream(NzInputStream& stream, const NzImageParams& params = NzImageParams());
|
||||
|
||||
bool Lock();
|
||||
|
||||
bool SetAnisotropyLevel(unsigned int anistropyLevel);
|
||||
bool SetFilterMode(nzTextureFilter filter);
|
||||
bool SetMipmapRange(nzUInt8 minLevel, nzUInt8 maxLevel);
|
||||
bool SetWrapMode(nzTextureWrap wrap);
|
||||
|
||||
bool Update(const NzImage& image, nzUInt8 level = 0);
|
||||
bool Update(const NzImage& image, const NzRectui& rect, unsigned int z = 0, nzUInt8 level = 0);
|
||||
bool Update(const NzImage& image, const NzCubeui& cube, nzUInt8 level = 0);
|
||||
bool Update(const nzUInt8* pixels, nzUInt8 level = 0);
|
||||
bool Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z = 0, nzUInt8 level = 0);
|
||||
bool Update(const nzUInt8* pixels, const NzCubeui& cube, nzUInt8 level = 0);
|
||||
bool UpdateFace(nzCubemapFace face, const NzImage& image, nzUInt8 level = 0);
|
||||
bool UpdateFace(nzCubemapFace face, const NzImage& image, const NzRectui& rect, nzUInt8 level = 0);
|
||||
bool UpdateFace(nzCubemapFace face, const nzUInt8* pixels, nzUInt8 level = 0);
|
||||
bool UpdateFace(nzCubemapFace face, const nzUInt8* pixels, const NzRectui& rect, nzUInt8 level = 0);
|
||||
|
||||
void Unlock();
|
||||
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
bool Prepare() const;
|
||||
|
||||
static unsigned int GetValidSize(unsigned int size);
|
||||
static bool IsFormatSupported(nzPixelFormat format);
|
||||
static bool IsMipmappingSupported();
|
||||
static bool IsTypeSupported(nzImageType type);
|
||||
|
||||
private:
|
||||
NzRenderTexture* GetRenderTexture() const;
|
||||
void SetRenderTexture(NzRenderTexture* renderTexture);
|
||||
|
||||
NzTextureImpl* m_impl;
|
||||
};
|
||||
|
||||
#endif // NAZARA_TEXTURE_HPP
|
||||
|
||||
@@ -1,78 +1,78 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// 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/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
|
||||
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;
|
||||
|
||||
using NzAnimationLoader = NzResourceLoader<NzAnimation, NzAnimationParams>;
|
||||
|
||||
struct NzAnimationImpl;
|
||||
|
||||
class NAZARA_API NzAnimation : public NzResource
|
||||
{
|
||||
friend NzAnimationLoader;
|
||||
|
||||
public:
|
||||
NzAnimation() = default;
|
||||
~NzAnimation();
|
||||
|
||||
bool 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;
|
||||
int GetSequenceIndex(const NzString& sequenceName) 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 NzAnimationLoader::LoaderList s_loaders;
|
||||
};
|
||||
|
||||
#endif // NAZARA_ANIMATION_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// 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/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
|
||||
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;
|
||||
|
||||
using NzAnimationLoader = NzResourceLoader<NzAnimation, NzAnimationParams>;
|
||||
|
||||
struct NzAnimationImpl;
|
||||
|
||||
class NAZARA_API NzAnimation : public NzResource
|
||||
{
|
||||
friend NzAnimationLoader;
|
||||
|
||||
public:
|
||||
NzAnimation() = default;
|
||||
~NzAnimation();
|
||||
|
||||
bool 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;
|
||||
int GetSequenceIndex(const NzString& sequenceName) 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 NzAnimationLoader::LoaderList s_loaders;
|
||||
};
|
||||
|
||||
#endif // NAZARA_ANIMATION_HPP
|
||||
|
||||
@@ -1,250 +1,250 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// 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,
|
||||
|
||||
nzAnimationType_Max = nzAnimationType_Static
|
||||
};
|
||||
|
||||
enum nzBufferAccess
|
||||
{
|
||||
nzBufferAccess_DiscardAndWrite,
|
||||
nzBufferAccess_ReadOnly,
|
||||
nzBufferAccess_ReadWrite,
|
||||
nzBufferAccess_WriteOnly,
|
||||
|
||||
nzBufferAccess_Max = nzBufferAccess_WriteOnly
|
||||
};
|
||||
|
||||
enum nzBufferStorage
|
||||
{
|
||||
//nzBufferStorage_Both,
|
||||
nzBufferStorage_Hardware,
|
||||
nzBufferStorage_Software,
|
||||
|
||||
nzBufferStorage_Max = nzBufferStorage_Software
|
||||
};
|
||||
|
||||
enum nzBufferType
|
||||
{
|
||||
nzBufferType_Index,
|
||||
nzBufferType_Vertex,
|
||||
|
||||
nzBufferType_Max = nzBufferType_Vertex
|
||||
};
|
||||
|
||||
enum nzBufferUsage
|
||||
{
|
||||
nzBufferUsage_Dynamic,
|
||||
nzBufferUsage_Static,
|
||||
|
||||
nzBufferUsage_Max = nzBufferUsage_Static
|
||||
};
|
||||
|
||||
enum nzCubemapFace
|
||||
{
|
||||
// Cette énumération est prévue pour remplacer l'argument "z" des méthodes de NzImage contenant un cubemap
|
||||
// L'ordre est X, -X, Y, -Y, Z, -Z
|
||||
nzCubemapFace_PositiveX = 0,
|
||||
nzCubemapFace_PositiveY = 2,
|
||||
nzCubemapFace_PositiveZ = 4,
|
||||
nzCubemapFace_NegativeX = 1,
|
||||
nzCubemapFace_NegativeY = 3,
|
||||
nzCubemapFace_NegativeZ = 5,
|
||||
|
||||
nzCubemapFace_Max = nzCubemapFace_NegativeZ
|
||||
};
|
||||
|
||||
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,
|
||||
|
||||
nzElementType_Max = nzElementType_Float4
|
||||
};
|
||||
|
||||
enum nzElementUsage
|
||||
{
|
||||
nzElementUsage_Diffuse,
|
||||
nzElementUsage_Normal,
|
||||
nzElementUsage_Position,
|
||||
nzElementUsage_Tangent,
|
||||
nzElementUsage_TexCoord,
|
||||
|
||||
nzElementUsage_Max = nzElementUsage_TexCoord
|
||||
};
|
||||
|
||||
enum nzEventType
|
||||
{
|
||||
nzEventType_GainedFocus,
|
||||
nzEventType_LostFocus,
|
||||
nzEventType_KeyPressed,
|
||||
nzEventType_KeyReleased,
|
||||
nzEventType_MouseButtonDoubleClicked,
|
||||
nzEventType_MouseButtonPressed,
|
||||
nzEventType_MouseButtonReleased,
|
||||
nzEventType_MouseEntered,
|
||||
nzEventType_MouseLeft,
|
||||
nzEventType_MouseMoved,
|
||||
nzEventType_MouseWheelMoved,
|
||||
nzEventType_Moved,
|
||||
nzEventType_Quit,
|
||||
nzEventType_Resized,
|
||||
nzEventType_TextEntered,
|
||||
|
||||
nzEventType_Max = nzEventType_TextEntered
|
||||
};
|
||||
|
||||
enum nzExtend
|
||||
{
|
||||
nzExtend_Finite,
|
||||
nzExtend_Infinite,
|
||||
nzExtend_Null,
|
||||
|
||||
nzExtend_Max = nzExtend_Null
|
||||
};
|
||||
|
||||
enum nzImageType
|
||||
{
|
||||
nzImageType_1D,
|
||||
nzImageType_1D_Array,
|
||||
nzImageType_2D,
|
||||
nzImageType_2D_Array,
|
||||
nzImageType_3D,
|
||||
nzImageType_Cubemap,
|
||||
|
||||
nzImageType_Max = nzImageType_Cubemap
|
||||
};
|
||||
|
||||
enum nzPixelFormat
|
||||
{
|
||||
nzPixelFormat_Undefined = -1,
|
||||
|
||||
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_Stencil16
|
||||
};
|
||||
|
||||
enum nzPixelFormatType
|
||||
{
|
||||
nzPixelFormatType_Undefined = -1,
|
||||
|
||||
nzPixelFormatType_Color,
|
||||
nzPixelFormatType_Depth,
|
||||
nzPixelFormatType_DepthStencil,
|
||||
nzPixelFormatType_Stencil,
|
||||
|
||||
nzPixelFormatType_Max = nzPixelFormatType_Stencil
|
||||
};
|
||||
|
||||
enum nzPixelFlipping
|
||||
{
|
||||
nzPixelFlipping_Horizontally,
|
||||
nzPixelFlipping_Vertically,
|
||||
|
||||
nzPixelFlipping_Max = nzPixelFlipping_Vertically
|
||||
};
|
||||
|
||||
enum nzPrimitiveType
|
||||
{
|
||||
nzPrimitiveType_LineList,
|
||||
nzPrimitiveType_LineStrip,
|
||||
nzPrimitiveType_PointList,
|
||||
nzPrimitiveType_TriangleList,
|
||||
nzPrimitiveType_TriangleStrip,
|
||||
nzPrimitiveType_TriangleFan,
|
||||
|
||||
nzPrimitiveType_Max = 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,
|
||||
|
||||
nzWindowCursor_Max = nzWindowCursor_Wait
|
||||
};
|
||||
|
||||
enum nzWindowStyleFlags
|
||||
{
|
||||
nzWindowStyle_None = 0x0,
|
||||
nzWindowStyle_Fullscreen = 0x1,
|
||||
|
||||
nzWindowStyle_Closable = 0x2,
|
||||
nzWindowStyle_Resizable = 0x4,
|
||||
nzWindowStyle_Titlebar = 0x8,
|
||||
|
||||
nzWindowStyle_Default = nzWindowStyle_Closable | nzWindowStyle_Resizable | nzWindowStyle_Titlebar
|
||||
};
|
||||
|
||||
#endif // NAZARA_ENUMS_UTILITY_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// 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,
|
||||
|
||||
nzAnimationType_Max = nzAnimationType_Static
|
||||
};
|
||||
|
||||
enum nzBufferAccess
|
||||
{
|
||||
nzBufferAccess_DiscardAndWrite,
|
||||
nzBufferAccess_ReadOnly,
|
||||
nzBufferAccess_ReadWrite,
|
||||
nzBufferAccess_WriteOnly,
|
||||
|
||||
nzBufferAccess_Max = nzBufferAccess_WriteOnly
|
||||
};
|
||||
|
||||
enum nzBufferStorage
|
||||
{
|
||||
//nzBufferStorage_Both,
|
||||
nzBufferStorage_Hardware,
|
||||
nzBufferStorage_Software,
|
||||
|
||||
nzBufferStorage_Max = nzBufferStorage_Software
|
||||
};
|
||||
|
||||
enum nzBufferType
|
||||
{
|
||||
nzBufferType_Index,
|
||||
nzBufferType_Vertex,
|
||||
|
||||
nzBufferType_Max = nzBufferType_Vertex
|
||||
};
|
||||
|
||||
enum nzBufferUsage
|
||||
{
|
||||
nzBufferUsage_Dynamic,
|
||||
nzBufferUsage_Static,
|
||||
|
||||
nzBufferUsage_Max = nzBufferUsage_Static
|
||||
};
|
||||
|
||||
enum nzCubemapFace
|
||||
{
|
||||
// Cette énumération est prévue pour remplacer l'argument "z" des méthodes de NzImage contenant un cubemap
|
||||
// L'ordre est X, -X, Y, -Y, Z, -Z
|
||||
nzCubemapFace_PositiveX = 0,
|
||||
nzCubemapFace_PositiveY = 2,
|
||||
nzCubemapFace_PositiveZ = 4,
|
||||
nzCubemapFace_NegativeX = 1,
|
||||
nzCubemapFace_NegativeY = 3,
|
||||
nzCubemapFace_NegativeZ = 5,
|
||||
|
||||
nzCubemapFace_Max = nzCubemapFace_NegativeZ
|
||||
};
|
||||
|
||||
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,
|
||||
|
||||
nzElementType_Max = nzElementType_Float4
|
||||
};
|
||||
|
||||
enum nzElementUsage
|
||||
{
|
||||
nzElementUsage_Diffuse,
|
||||
nzElementUsage_Normal,
|
||||
nzElementUsage_Position,
|
||||
nzElementUsage_Tangent,
|
||||
nzElementUsage_TexCoord,
|
||||
|
||||
nzElementUsage_Max = nzElementUsage_TexCoord
|
||||
};
|
||||
|
||||
enum nzEventType
|
||||
{
|
||||
nzEventType_GainedFocus,
|
||||
nzEventType_LostFocus,
|
||||
nzEventType_KeyPressed,
|
||||
nzEventType_KeyReleased,
|
||||
nzEventType_MouseButtonDoubleClicked,
|
||||
nzEventType_MouseButtonPressed,
|
||||
nzEventType_MouseButtonReleased,
|
||||
nzEventType_MouseEntered,
|
||||
nzEventType_MouseLeft,
|
||||
nzEventType_MouseMoved,
|
||||
nzEventType_MouseWheelMoved,
|
||||
nzEventType_Moved,
|
||||
nzEventType_Quit,
|
||||
nzEventType_Resized,
|
||||
nzEventType_TextEntered,
|
||||
|
||||
nzEventType_Max = nzEventType_TextEntered
|
||||
};
|
||||
|
||||
enum nzExtend
|
||||
{
|
||||
nzExtend_Finite,
|
||||
nzExtend_Infinite,
|
||||
nzExtend_Null,
|
||||
|
||||
nzExtend_Max = nzExtend_Null
|
||||
};
|
||||
|
||||
enum nzImageType
|
||||
{
|
||||
nzImageType_1D,
|
||||
nzImageType_1D_Array,
|
||||
nzImageType_2D,
|
||||
nzImageType_2D_Array,
|
||||
nzImageType_3D,
|
||||
nzImageType_Cubemap,
|
||||
|
||||
nzImageType_Max = nzImageType_Cubemap
|
||||
};
|
||||
|
||||
enum nzPixelFormat
|
||||
{
|
||||
nzPixelFormat_Undefined = -1,
|
||||
|
||||
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_Stencil16
|
||||
};
|
||||
|
||||
enum nzPixelFormatType
|
||||
{
|
||||
nzPixelFormatType_Undefined = -1,
|
||||
|
||||
nzPixelFormatType_Color,
|
||||
nzPixelFormatType_Depth,
|
||||
nzPixelFormatType_DepthStencil,
|
||||
nzPixelFormatType_Stencil,
|
||||
|
||||
nzPixelFormatType_Max = nzPixelFormatType_Stencil
|
||||
};
|
||||
|
||||
enum nzPixelFlipping
|
||||
{
|
||||
nzPixelFlipping_Horizontally,
|
||||
nzPixelFlipping_Vertically,
|
||||
|
||||
nzPixelFlipping_Max = nzPixelFlipping_Vertically
|
||||
};
|
||||
|
||||
enum nzPrimitiveType
|
||||
{
|
||||
nzPrimitiveType_LineList,
|
||||
nzPrimitiveType_LineStrip,
|
||||
nzPrimitiveType_PointList,
|
||||
nzPrimitiveType_TriangleList,
|
||||
nzPrimitiveType_TriangleStrip,
|
||||
nzPrimitiveType_TriangleFan,
|
||||
|
||||
nzPrimitiveType_Max = 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,
|
||||
|
||||
nzWindowCursor_Max = nzWindowCursor_Wait
|
||||
};
|
||||
|
||||
enum nzWindowStyleFlags
|
||||
{
|
||||
nzWindowStyle_None = 0x0,
|
||||
nzWindowStyle_Fullscreen = 0x1,
|
||||
|
||||
nzWindowStyle_Closable = 0x2,
|
||||
nzWindowStyle_Resizable = 0x4,
|
||||
nzWindowStyle_Titlebar = 0x8,
|
||||
|
||||
nzWindowStyle_Default = nzWindowStyle_Closable | nzWindowStyle_Resizable | nzWindowStyle_Titlebar
|
||||
};
|
||||
|
||||
#endif // NAZARA_ENUMS_UTILITY_HPP
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
|
||||
class NzMesh;
|
||||
struct NzAnimation;
|
||||
|
||||
class NAZARA_API NzKeyframeMesh : public NzSubMesh
|
||||
{
|
||||
|
||||
@@ -1,98 +1,98 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// 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/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceListener.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Animation.hpp>
|
||||
#include <Nazara/Utility/AxisAlignedBox.hpp>
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
|
||||
class NzVertexDeclaration;
|
||||
|
||||
struct NzMeshParams
|
||||
{
|
||||
NzAnimationParams animation;
|
||||
//const NzVertexDeclaration* declaration = nullptr;
|
||||
nzBufferStorage storage = nzBufferStorage_Hardware;
|
||||
bool loadAnimations = true;
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
|
||||
class NzMesh;
|
||||
|
||||
using NzMeshLoader = NzResourceLoader<NzMesh, NzMeshParams>;
|
||||
|
||||
struct NzMeshImpl;
|
||||
|
||||
class NAZARA_API NzMesh : public NzResource, NzResourceListener
|
||||
{
|
||||
friend NzMeshLoader;
|
||||
|
||||
public:
|
||||
NzMesh() = default;
|
||||
~NzMesh();
|
||||
|
||||
bool AddSkin(const NzString& skin, bool setDefault = false);
|
||||
bool AddSubMesh(NzSubMesh* subMesh);
|
||||
bool AddSubMesh(const NzString& identifier, NzSubMesh* subMesh);
|
||||
|
||||
void Animate(unsigned int frameA, unsigned int frameB, float interpolation);
|
||||
|
||||
bool Create(nzAnimationType type);
|
||||
void Destroy();
|
||||
|
||||
const NzAxisAlignedBox& GetAABB() const;
|
||||
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(unsigned int index);
|
||||
const NzSubMesh* GetSubMesh(const NzString& identifier) const;
|
||||
const NzSubMesh* GetSubMesh(unsigned int index) const;
|
||||
unsigned int GetSubMeshCount() const;
|
||||
int GetSubMeshIndex(const NzString& identifier) const;
|
||||
unsigned int GetVertexCount() const;
|
||||
|
||||
bool HasAnimation() const;
|
||||
bool HasSkin(unsigned int index = 0) const;
|
||||
bool HasSubMesh(const NzString& identifier) const;
|
||||
bool HasSubMesh(unsigned int index = 0) const;
|
||||
|
||||
void InvalidateAABB() 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(unsigned int index = 0);
|
||||
|
||||
bool SetAnimation(const NzAnimation* animation);
|
||||
|
||||
private:
|
||||
void OnResourceCreated(const NzResource* resource, int index) override;
|
||||
void OnResourceReleased(const NzResource* resource, int index) override;
|
||||
|
||||
NzMeshImpl* m_impl = nullptr;
|
||||
|
||||
static NzMeshLoader::LoaderList s_loaders;
|
||||
};
|
||||
|
||||
#endif // NAZARA_MESH_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// 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/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceListener.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Animation.hpp>
|
||||
#include <Nazara/Utility/AxisAlignedBox.hpp>
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
|
||||
class NzVertexDeclaration;
|
||||
|
||||
struct NzMeshParams
|
||||
{
|
||||
NzAnimationParams animation;
|
||||
//const NzVertexDeclaration* declaration = nullptr;
|
||||
nzBufferStorage storage = nzBufferStorage_Hardware;
|
||||
bool loadAnimations = true;
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
|
||||
class NzMesh;
|
||||
|
||||
using NzMeshLoader = NzResourceLoader<NzMesh, NzMeshParams>;
|
||||
|
||||
struct NzMeshImpl;
|
||||
|
||||
class NAZARA_API NzMesh : public NzResource, NzResourceListener
|
||||
{
|
||||
friend NzMeshLoader;
|
||||
|
||||
public:
|
||||
NzMesh() = default;
|
||||
~NzMesh();
|
||||
|
||||
bool AddSkin(const NzString& skin, bool setDefault = false);
|
||||
bool AddSubMesh(NzSubMesh* subMesh);
|
||||
bool AddSubMesh(const NzString& identifier, NzSubMesh* subMesh);
|
||||
|
||||
void Animate(unsigned int frameA, unsigned int frameB, float interpolation);
|
||||
|
||||
bool Create(nzAnimationType type);
|
||||
void Destroy();
|
||||
|
||||
const NzAxisAlignedBox& GetAABB() const;
|
||||
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(unsigned int index);
|
||||
const NzSubMesh* GetSubMesh(const NzString& identifier) const;
|
||||
const NzSubMesh* GetSubMesh(unsigned int index) const;
|
||||
unsigned int GetSubMeshCount() const;
|
||||
int GetSubMeshIndex(const NzString& identifier) const;
|
||||
unsigned int GetVertexCount() const;
|
||||
|
||||
bool HasAnimation() const;
|
||||
bool HasSkin(unsigned int index = 0) const;
|
||||
bool HasSubMesh(const NzString& identifier) const;
|
||||
bool HasSubMesh(unsigned int index = 0) const;
|
||||
|
||||
void InvalidateAABB() 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(unsigned int index = 0);
|
||||
|
||||
bool SetAnimation(const NzAnimation* animation);
|
||||
|
||||
private:
|
||||
void OnResourceCreated(const NzResource* resource, int index) override;
|
||||
void OnResourceReleased(const NzResource* resource, int index) override;
|
||||
|
||||
NzMeshImpl* m_impl = nullptr;
|
||||
|
||||
static NzMeshLoader::LoaderList s_loaders;
|
||||
};
|
||||
|
||||
#endif // NAZARA_MESH_HPP
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_PIXELFORMAT_HPP
|
||||
#define NAZARA_PIXELFORMAT_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <map>
|
||||
|
||||
class NzUtility;
|
||||
|
||||
class NzPixelFormat
|
||||
{
|
||||
friend class NzUtility;
|
||||
|
||||
public:
|
||||
using ConvertFunction = nzUInt8* (*)(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst);
|
||||
using FlipFunction = void (*)(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 nzPixelFormatType GetType(nzPixelFormat format);
|
||||
|
||||
static bool HasAlpha(nzPixelFormat format);
|
||||
|
||||
static bool IsCompressed(nzPixelFormat format);
|
||||
static bool IsConversionSupported(nzPixelFormat srcFormat, nzPixelFormat dstFormat);
|
||||
static bool IsValid(nzPixelFormat format);
|
||||
|
||||
static void SetConvertFunction(nzPixelFormat srcFormat, nzPixelFormat dstFormat, ConvertFunction func);
|
||||
static void SetFlipFunction(nzPixelFlipping flipping, nzPixelFormat format, FlipFunction func);
|
||||
|
||||
static NzString ToString(nzPixelFormat format);
|
||||
|
||||
private:
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
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>
|
||||
|
||||
#endif // NAZARA_PIXELFORMAT_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_PIXELFORMAT_HPP
|
||||
#define NAZARA_PIXELFORMAT_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <map>
|
||||
|
||||
class NzUtility;
|
||||
|
||||
class NzPixelFormat
|
||||
{
|
||||
friend class NzUtility;
|
||||
|
||||
public:
|
||||
using ConvertFunction = nzUInt8* (*)(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst);
|
||||
using FlipFunction = void (*)(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 nzPixelFormatType GetType(nzPixelFormat format);
|
||||
|
||||
static bool HasAlpha(nzPixelFormat format);
|
||||
|
||||
static bool IsCompressed(nzPixelFormat format);
|
||||
static bool IsConversionSupported(nzPixelFormat srcFormat, nzPixelFormat dstFormat);
|
||||
static bool IsValid(nzPixelFormat format);
|
||||
|
||||
static void SetConvertFunction(nzPixelFormat srcFormat, nzPixelFormat dstFormat, ConvertFunction func);
|
||||
static void SetFlipFunction(nzPixelFlipping flipping, nzPixelFormat format, FlipFunction func);
|
||||
|
||||
static NzString ToString(nzPixelFormat format);
|
||||
|
||||
private:
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
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>
|
||||
|
||||
#endif // NAZARA_PIXELFORMAT_HPP
|
||||
|
||||
@@ -1,487 +1,487 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <cstring>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
inline bool NzPixelFormat::Convert(nzPixelFormat srcFormat, nzPixelFormat dstFormat, const void* src, void* dst)
|
||||
{
|
||||
if (srcFormat == dstFormat)
|
||||
{
|
||||
std::memcpy(dst, src, GetBPP(srcFormat));
|
||||
return true;
|
||||
}
|
||||
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (IsCompressed(srcFormat))
|
||||
{
|
||||
NazaraError("Cannot convert single pixel from compressed format");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsCompressed(dstFormat))
|
||||
{
|
||||
NazaraError("Cannot convert single pixel to compressed format");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
ConvertFunction func = s_convertFunctions[srcFormat][dstFormat];
|
||||
if (!func)
|
||||
{
|
||||
NazaraError("Pixel format conversion from " + ToString(srcFormat) + " to " + ToString(dstFormat) + " is not supported");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!func(reinterpret_cast<const nzUInt8*>(src), reinterpret_cast<const nzUInt8*>(src) + GetBPP(srcFormat), reinterpret_cast<nzUInt8*>(dst)))
|
||||
{
|
||||
NazaraError("Pixel format conversion from " + ToString(srcFormat) + " to " + ToString(dstFormat) + " failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool NzPixelFormat::Convert(nzPixelFormat srcFormat, nzPixelFormat dstFormat, const void* start, const void* end, void* dst)
|
||||
{
|
||||
if (srcFormat == dstFormat)
|
||||
{
|
||||
std::memcpy(dst, start, reinterpret_cast<const nzUInt8*>(end)-reinterpret_cast<const nzUInt8*>(start));
|
||||
return true;
|
||||
}
|
||||
|
||||
ConvertFunction func = s_convertFunctions[srcFormat][dstFormat];
|
||||
if (!func)
|
||||
{
|
||||
NazaraError("Pixel format conversion from " + ToString(srcFormat) + " to " + ToString(dstFormat) + " is not supported");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!func(reinterpret_cast<const nzUInt8*>(start), reinterpret_cast<const nzUInt8*>(end), reinterpret_cast<nzUInt8*>(dst)))
|
||||
{
|
||||
NazaraError("Pixel format conversion from " + ToString(srcFormat) + " to " + ToString(dstFormat) + " failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
case nzPixelFormat_BGR8:
|
||||
return 3;
|
||||
|
||||
case nzPixelFormat_BGRA8:
|
||||
return 4;
|
||||
|
||||
case nzPixelFormat_DXT1:
|
||||
return 1;
|
||||
|
||||
case nzPixelFormat_DXT3:
|
||||
return 2;
|
||||
|
||||
case nzPixelFormat_DXT5:
|
||||
return 2;
|
||||
|
||||
case nzPixelFormat_L8:
|
||||
return 1;
|
||||
|
||||
case nzPixelFormat_LA8:
|
||||
return 2;
|
||||
/*
|
||||
case nzPixelFormat_RGB16F:
|
||||
return 6;
|
||||
|
||||
case nzPixelFormat_RGB16I:
|
||||
return 6;
|
||||
|
||||
case nzPixelFormat_RGB32F:
|
||||
return 12;
|
||||
|
||||
case nzPixelFormat_RGB32I:
|
||||
return 12;
|
||||
|
||||
case nzPixelFormat_RGBA16F:
|
||||
return 8;
|
||||
|
||||
case nzPixelFormat_RGBA16I:
|
||||
return 8;
|
||||
|
||||
case nzPixelFormat_RGBA32F:
|
||||
return 16;
|
||||
|
||||
case nzPixelFormat_RGBA32I:
|
||||
return 16;
|
||||
*/
|
||||
case nzPixelFormat_RGBA4:
|
||||
return 2;
|
||||
|
||||
case nzPixelFormat_RGB5A1:
|
||||
return 2;
|
||||
|
||||
case nzPixelFormat_RGB8:
|
||||
return 3;
|
||||
|
||||
case nzPixelFormat_RGBA8:
|
||||
return 4;
|
||||
|
||||
case nzPixelFormat_Depth16:
|
||||
return 2;
|
||||
|
||||
case nzPixelFormat_Depth24:
|
||||
return 3;
|
||||
|
||||
case nzPixelFormat_Depth24Stencil8:
|
||||
return 4;
|
||||
|
||||
case nzPixelFormat_Depth32:
|
||||
return 4;
|
||||
|
||||
case nzPixelFormat_Stencil1:
|
||||
NazaraWarning("This format uses less than one byte per pixel");
|
||||
return 0;
|
||||
|
||||
case nzPixelFormat_Stencil4:
|
||||
NazaraWarning("This format uses less than one byte per pixel");
|
||||
return 0;
|
||||
|
||||
case nzPixelFormat_Stencil8:
|
||||
return 1;
|
||||
|
||||
case nzPixelFormat_Stencil16:
|
||||
return 2;
|
||||
|
||||
case nzPixelFormat_Undefined:
|
||||
break;
|
||||
}
|
||||
|
||||
NazaraError("Invalid pixel format");
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline nzPixelFormatType NzPixelFormat::GetType(nzPixelFormat format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case nzPixelFormat_BGR8:
|
||||
case nzPixelFormat_BGRA8:
|
||||
case nzPixelFormat_DXT1:
|
||||
case nzPixelFormat_DXT3:
|
||||
case nzPixelFormat_DXT5:
|
||||
case nzPixelFormat_L8:
|
||||
case nzPixelFormat_LA8:
|
||||
case nzPixelFormat_RGB5A1:
|
||||
case nzPixelFormat_RGB8:
|
||||
case nzPixelFormat_RGBA4:
|
||||
case nzPixelFormat_RGBA8:
|
||||
return nzPixelFormatType_Color;
|
||||
|
||||
case nzPixelFormat_Depth16:
|
||||
case nzPixelFormat_Depth24:
|
||||
case nzPixelFormat_Depth32:
|
||||
return nzPixelFormatType_Depth;
|
||||
|
||||
case nzPixelFormat_Depth24Stencil8:
|
||||
return nzPixelFormatType_DepthStencil;
|
||||
|
||||
case nzPixelFormat_Stencil1:
|
||||
case nzPixelFormat_Stencil4:
|
||||
case nzPixelFormat_Stencil8:
|
||||
case nzPixelFormat_Stencil16:
|
||||
return nzPixelFormatType_Stencil;
|
||||
|
||||
case nzPixelFormat_Undefined:
|
||||
break;
|
||||
}
|
||||
|
||||
NazaraError("Invalid pixel format");
|
||||
return nzPixelFormatType_Undefined;
|
||||
}
|
||||
|
||||
inline bool NzPixelFormat::HasAlpha(nzPixelFormat format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case nzPixelFormat_BGRA8:
|
||||
case nzPixelFormat_DXT3:
|
||||
case nzPixelFormat_DXT5:
|
||||
case nzPixelFormat_LA8:
|
||||
case nzPixelFormat_RGB5A1:
|
||||
case nzPixelFormat_RGBA4:
|
||||
case nzPixelFormat_RGBA8:
|
||||
return true;
|
||||
|
||||
case nzPixelFormat_BGR8:
|
||||
case nzPixelFormat_DXT1:
|
||||
case nzPixelFormat_L8:
|
||||
case nzPixelFormat_RGB8:
|
||||
case nzPixelFormat_Depth16:
|
||||
case nzPixelFormat_Depth24:
|
||||
case nzPixelFormat_Depth24Stencil8:
|
||||
case nzPixelFormat_Depth32:
|
||||
case nzPixelFormat_Stencil1:
|
||||
case nzPixelFormat_Stencil4:
|
||||
case nzPixelFormat_Stencil8:
|
||||
case nzPixelFormat_Stencil16:
|
||||
return false;
|
||||
|
||||
case nzPixelFormat_Undefined:
|
||||
break;
|
||||
}
|
||||
|
||||
NazaraError("Invalid pixel format");
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool NzPixelFormat::IsCompressed(nzPixelFormat format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case nzPixelFormat_DXT1:
|
||||
case nzPixelFormat_DXT3:
|
||||
case nzPixelFormat_DXT5:
|
||||
return true;
|
||||
|
||||
case nzPixelFormat_BGRA8:
|
||||
case nzPixelFormat_LA8:
|
||||
case nzPixelFormat_RGB5A1:
|
||||
case nzPixelFormat_RGBA4:
|
||||
case nzPixelFormat_RGBA8:
|
||||
case nzPixelFormat_BGR8:
|
||||
case nzPixelFormat_L8:
|
||||
case nzPixelFormat_RGB8:
|
||||
case nzPixelFormat_Depth16:
|
||||
case nzPixelFormat_Depth24:
|
||||
case nzPixelFormat_Depth24Stencil8:
|
||||
case nzPixelFormat_Depth32:
|
||||
case nzPixelFormat_Stencil1:
|
||||
case nzPixelFormat_Stencil4:
|
||||
case nzPixelFormat_Stencil8:
|
||||
case nzPixelFormat_Stencil16:
|
||||
return false;
|
||||
|
||||
case nzPixelFormat_Undefined:
|
||||
break;
|
||||
}
|
||||
|
||||
NazaraError("Invalid pixel format");
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool NzPixelFormat::IsConversionSupported(nzPixelFormat srcFormat, nzPixelFormat dstFormat)
|
||||
{
|
||||
if (srcFormat == dstFormat)
|
||||
return true;
|
||||
|
||||
return s_convertFunctions[srcFormat][dstFormat] != nullptr;
|
||||
}
|
||||
|
||||
inline bool NzPixelFormat::IsValid(nzPixelFormat format)
|
||||
{
|
||||
return format != nzPixelFormat_Undefined;
|
||||
}
|
||||
|
||||
inline void NzPixelFormat::SetConvertFunction(nzPixelFormat srcFormat, nzPixelFormat dstFormat, ConvertFunction func)
|
||||
{
|
||||
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)
|
||||
{
|
||||
case nzPixelFormat_BGR8:
|
||||
return "BGR8";
|
||||
|
||||
case nzPixelFormat_BGRA8:
|
||||
return "BGRA8";
|
||||
|
||||
case nzPixelFormat_DXT1:
|
||||
return "DXT1";
|
||||
|
||||
case nzPixelFormat_DXT3:
|
||||
return "DXT3";
|
||||
|
||||
case nzPixelFormat_DXT5:
|
||||
return "DXT5";
|
||||
|
||||
case nzPixelFormat_L8:
|
||||
return "L8";
|
||||
|
||||
case nzPixelFormat_LA8:
|
||||
return "LA8";
|
||||
/*
|
||||
case nzPixelFormat_RGB16F:
|
||||
return "RGB16F";
|
||||
|
||||
case nzPixelFormat_RGB16I:
|
||||
return "RGB16I";
|
||||
|
||||
case nzPixelFormat_RGB32F:
|
||||
return "RGB32F";
|
||||
|
||||
case nzPixelFormat_RGB32I:
|
||||
return "RGB32I";
|
||||
|
||||
case nzPixelFormat_RGBA16F:
|
||||
return "RGBA16F";
|
||||
|
||||
case nzPixelFormat_RGBA16I:
|
||||
return "RGBA16I";
|
||||
|
||||
case nzPixelFormat_RGBA32F:
|
||||
return "RGBA32F";
|
||||
|
||||
case nzPixelFormat_RGBA32I:
|
||||
return "RGBA32I";
|
||||
*/
|
||||
case nzPixelFormat_RGBA4:
|
||||
return "RGBA4";
|
||||
|
||||
case nzPixelFormat_RGB5A1:
|
||||
return "RGB5A1";
|
||||
|
||||
case nzPixelFormat_RGB8:
|
||||
return "RGB8";
|
||||
|
||||
case nzPixelFormat_RGBA8:
|
||||
return "RGBA8";
|
||||
|
||||
case nzPixelFormat_Depth16:
|
||||
return "Depth16";
|
||||
|
||||
case nzPixelFormat_Depth24:
|
||||
return "Depth24";
|
||||
|
||||
case nzPixelFormat_Depth24Stencil8:
|
||||
return "Depth24Stencil8";
|
||||
|
||||
case nzPixelFormat_Depth32:
|
||||
return "Depth32";
|
||||
|
||||
case nzPixelFormat_Stencil1:
|
||||
return "Stencil1";
|
||||
|
||||
case nzPixelFormat_Stencil4:
|
||||
return "Stencil4";
|
||||
|
||||
case nzPixelFormat_Stencil8:
|
||||
return "Stencil8";
|
||||
|
||||
case nzPixelFormat_Stencil16:
|
||||
return "Stencil16";
|
||||
|
||||
case nzPixelFormat_Undefined:
|
||||
return "Undefined";
|
||||
}
|
||||
|
||||
NazaraError("Invalid pixel format");
|
||||
return "Invalid format";
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <cstring>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
inline bool NzPixelFormat::Convert(nzPixelFormat srcFormat, nzPixelFormat dstFormat, const void* src, void* dst)
|
||||
{
|
||||
if (srcFormat == dstFormat)
|
||||
{
|
||||
std::memcpy(dst, src, GetBPP(srcFormat));
|
||||
return true;
|
||||
}
|
||||
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (IsCompressed(srcFormat))
|
||||
{
|
||||
NazaraError("Cannot convert single pixel from compressed format");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsCompressed(dstFormat))
|
||||
{
|
||||
NazaraError("Cannot convert single pixel to compressed format");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
ConvertFunction func = s_convertFunctions[srcFormat][dstFormat];
|
||||
if (!func)
|
||||
{
|
||||
NazaraError("Pixel format conversion from " + ToString(srcFormat) + " to " + ToString(dstFormat) + " is not supported");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!func(reinterpret_cast<const nzUInt8*>(src), reinterpret_cast<const nzUInt8*>(src) + GetBPP(srcFormat), reinterpret_cast<nzUInt8*>(dst)))
|
||||
{
|
||||
NazaraError("Pixel format conversion from " + ToString(srcFormat) + " to " + ToString(dstFormat) + " failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool NzPixelFormat::Convert(nzPixelFormat srcFormat, nzPixelFormat dstFormat, const void* start, const void* end, void* dst)
|
||||
{
|
||||
if (srcFormat == dstFormat)
|
||||
{
|
||||
std::memcpy(dst, start, reinterpret_cast<const nzUInt8*>(end)-reinterpret_cast<const nzUInt8*>(start));
|
||||
return true;
|
||||
}
|
||||
|
||||
ConvertFunction func = s_convertFunctions[srcFormat][dstFormat];
|
||||
if (!func)
|
||||
{
|
||||
NazaraError("Pixel format conversion from " + ToString(srcFormat) + " to " + ToString(dstFormat) + " is not supported");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!func(reinterpret_cast<const nzUInt8*>(start), reinterpret_cast<const nzUInt8*>(end), reinterpret_cast<nzUInt8*>(dst)))
|
||||
{
|
||||
NazaraError("Pixel format conversion from " + ToString(srcFormat) + " to " + ToString(dstFormat) + " failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
case nzPixelFormat_BGR8:
|
||||
return 3;
|
||||
|
||||
case nzPixelFormat_BGRA8:
|
||||
return 4;
|
||||
|
||||
case nzPixelFormat_DXT1:
|
||||
return 1;
|
||||
|
||||
case nzPixelFormat_DXT3:
|
||||
return 2;
|
||||
|
||||
case nzPixelFormat_DXT5:
|
||||
return 2;
|
||||
|
||||
case nzPixelFormat_L8:
|
||||
return 1;
|
||||
|
||||
case nzPixelFormat_LA8:
|
||||
return 2;
|
||||
/*
|
||||
case nzPixelFormat_RGB16F:
|
||||
return 6;
|
||||
|
||||
case nzPixelFormat_RGB16I:
|
||||
return 6;
|
||||
|
||||
case nzPixelFormat_RGB32F:
|
||||
return 12;
|
||||
|
||||
case nzPixelFormat_RGB32I:
|
||||
return 12;
|
||||
|
||||
case nzPixelFormat_RGBA16F:
|
||||
return 8;
|
||||
|
||||
case nzPixelFormat_RGBA16I:
|
||||
return 8;
|
||||
|
||||
case nzPixelFormat_RGBA32F:
|
||||
return 16;
|
||||
|
||||
case nzPixelFormat_RGBA32I:
|
||||
return 16;
|
||||
*/
|
||||
case nzPixelFormat_RGBA4:
|
||||
return 2;
|
||||
|
||||
case nzPixelFormat_RGB5A1:
|
||||
return 2;
|
||||
|
||||
case nzPixelFormat_RGB8:
|
||||
return 3;
|
||||
|
||||
case nzPixelFormat_RGBA8:
|
||||
return 4;
|
||||
|
||||
case nzPixelFormat_Depth16:
|
||||
return 2;
|
||||
|
||||
case nzPixelFormat_Depth24:
|
||||
return 3;
|
||||
|
||||
case nzPixelFormat_Depth24Stencil8:
|
||||
return 4;
|
||||
|
||||
case nzPixelFormat_Depth32:
|
||||
return 4;
|
||||
|
||||
case nzPixelFormat_Stencil1:
|
||||
NazaraWarning("This format uses less than one byte per pixel");
|
||||
return 0;
|
||||
|
||||
case nzPixelFormat_Stencil4:
|
||||
NazaraWarning("This format uses less than one byte per pixel");
|
||||
return 0;
|
||||
|
||||
case nzPixelFormat_Stencil8:
|
||||
return 1;
|
||||
|
||||
case nzPixelFormat_Stencil16:
|
||||
return 2;
|
||||
|
||||
case nzPixelFormat_Undefined:
|
||||
break;
|
||||
}
|
||||
|
||||
NazaraError("Invalid pixel format");
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline nzPixelFormatType NzPixelFormat::GetType(nzPixelFormat format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case nzPixelFormat_BGR8:
|
||||
case nzPixelFormat_BGRA8:
|
||||
case nzPixelFormat_DXT1:
|
||||
case nzPixelFormat_DXT3:
|
||||
case nzPixelFormat_DXT5:
|
||||
case nzPixelFormat_L8:
|
||||
case nzPixelFormat_LA8:
|
||||
case nzPixelFormat_RGB5A1:
|
||||
case nzPixelFormat_RGB8:
|
||||
case nzPixelFormat_RGBA4:
|
||||
case nzPixelFormat_RGBA8:
|
||||
return nzPixelFormatType_Color;
|
||||
|
||||
case nzPixelFormat_Depth16:
|
||||
case nzPixelFormat_Depth24:
|
||||
case nzPixelFormat_Depth32:
|
||||
return nzPixelFormatType_Depth;
|
||||
|
||||
case nzPixelFormat_Depth24Stencil8:
|
||||
return nzPixelFormatType_DepthStencil;
|
||||
|
||||
case nzPixelFormat_Stencil1:
|
||||
case nzPixelFormat_Stencil4:
|
||||
case nzPixelFormat_Stencil8:
|
||||
case nzPixelFormat_Stencil16:
|
||||
return nzPixelFormatType_Stencil;
|
||||
|
||||
case nzPixelFormat_Undefined:
|
||||
break;
|
||||
}
|
||||
|
||||
NazaraError("Invalid pixel format");
|
||||
return nzPixelFormatType_Undefined;
|
||||
}
|
||||
|
||||
inline bool NzPixelFormat::HasAlpha(nzPixelFormat format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case nzPixelFormat_BGRA8:
|
||||
case nzPixelFormat_DXT3:
|
||||
case nzPixelFormat_DXT5:
|
||||
case nzPixelFormat_LA8:
|
||||
case nzPixelFormat_RGB5A1:
|
||||
case nzPixelFormat_RGBA4:
|
||||
case nzPixelFormat_RGBA8:
|
||||
return true;
|
||||
|
||||
case nzPixelFormat_BGR8:
|
||||
case nzPixelFormat_DXT1:
|
||||
case nzPixelFormat_L8:
|
||||
case nzPixelFormat_RGB8:
|
||||
case nzPixelFormat_Depth16:
|
||||
case nzPixelFormat_Depth24:
|
||||
case nzPixelFormat_Depth24Stencil8:
|
||||
case nzPixelFormat_Depth32:
|
||||
case nzPixelFormat_Stencil1:
|
||||
case nzPixelFormat_Stencil4:
|
||||
case nzPixelFormat_Stencil8:
|
||||
case nzPixelFormat_Stencil16:
|
||||
return false;
|
||||
|
||||
case nzPixelFormat_Undefined:
|
||||
break;
|
||||
}
|
||||
|
||||
NazaraError("Invalid pixel format");
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool NzPixelFormat::IsCompressed(nzPixelFormat format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case nzPixelFormat_DXT1:
|
||||
case nzPixelFormat_DXT3:
|
||||
case nzPixelFormat_DXT5:
|
||||
return true;
|
||||
|
||||
case nzPixelFormat_BGRA8:
|
||||
case nzPixelFormat_LA8:
|
||||
case nzPixelFormat_RGB5A1:
|
||||
case nzPixelFormat_RGBA4:
|
||||
case nzPixelFormat_RGBA8:
|
||||
case nzPixelFormat_BGR8:
|
||||
case nzPixelFormat_L8:
|
||||
case nzPixelFormat_RGB8:
|
||||
case nzPixelFormat_Depth16:
|
||||
case nzPixelFormat_Depth24:
|
||||
case nzPixelFormat_Depth24Stencil8:
|
||||
case nzPixelFormat_Depth32:
|
||||
case nzPixelFormat_Stencil1:
|
||||
case nzPixelFormat_Stencil4:
|
||||
case nzPixelFormat_Stencil8:
|
||||
case nzPixelFormat_Stencil16:
|
||||
return false;
|
||||
|
||||
case nzPixelFormat_Undefined:
|
||||
break;
|
||||
}
|
||||
|
||||
NazaraError("Invalid pixel format");
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool NzPixelFormat::IsConversionSupported(nzPixelFormat srcFormat, nzPixelFormat dstFormat)
|
||||
{
|
||||
if (srcFormat == dstFormat)
|
||||
return true;
|
||||
|
||||
return s_convertFunctions[srcFormat][dstFormat] != nullptr;
|
||||
}
|
||||
|
||||
inline bool NzPixelFormat::IsValid(nzPixelFormat format)
|
||||
{
|
||||
return format != nzPixelFormat_Undefined;
|
||||
}
|
||||
|
||||
inline void NzPixelFormat::SetConvertFunction(nzPixelFormat srcFormat, nzPixelFormat dstFormat, ConvertFunction func)
|
||||
{
|
||||
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)
|
||||
{
|
||||
case nzPixelFormat_BGR8:
|
||||
return "BGR8";
|
||||
|
||||
case nzPixelFormat_BGRA8:
|
||||
return "BGRA8";
|
||||
|
||||
case nzPixelFormat_DXT1:
|
||||
return "DXT1";
|
||||
|
||||
case nzPixelFormat_DXT3:
|
||||
return "DXT3";
|
||||
|
||||
case nzPixelFormat_DXT5:
|
||||
return "DXT5";
|
||||
|
||||
case nzPixelFormat_L8:
|
||||
return "L8";
|
||||
|
||||
case nzPixelFormat_LA8:
|
||||
return "LA8";
|
||||
/*
|
||||
case nzPixelFormat_RGB16F:
|
||||
return "RGB16F";
|
||||
|
||||
case nzPixelFormat_RGB16I:
|
||||
return "RGB16I";
|
||||
|
||||
case nzPixelFormat_RGB32F:
|
||||
return "RGB32F";
|
||||
|
||||
case nzPixelFormat_RGB32I:
|
||||
return "RGB32I";
|
||||
|
||||
case nzPixelFormat_RGBA16F:
|
||||
return "RGBA16F";
|
||||
|
||||
case nzPixelFormat_RGBA16I:
|
||||
return "RGBA16I";
|
||||
|
||||
case nzPixelFormat_RGBA32F:
|
||||
return "RGBA32F";
|
||||
|
||||
case nzPixelFormat_RGBA32I:
|
||||
return "RGBA32I";
|
||||
*/
|
||||
case nzPixelFormat_RGBA4:
|
||||
return "RGBA4";
|
||||
|
||||
case nzPixelFormat_RGB5A1:
|
||||
return "RGB5A1";
|
||||
|
||||
case nzPixelFormat_RGB8:
|
||||
return "RGB8";
|
||||
|
||||
case nzPixelFormat_RGBA8:
|
||||
return "RGBA8";
|
||||
|
||||
case nzPixelFormat_Depth16:
|
||||
return "Depth16";
|
||||
|
||||
case nzPixelFormat_Depth24:
|
||||
return "Depth24";
|
||||
|
||||
case nzPixelFormat_Depth24Stencil8:
|
||||
return "Depth24Stencil8";
|
||||
|
||||
case nzPixelFormat_Depth32:
|
||||
return "Depth32";
|
||||
|
||||
case nzPixelFormat_Stencil1:
|
||||
return "Stencil1";
|
||||
|
||||
case nzPixelFormat_Stencil4:
|
||||
return "Stencil4";
|
||||
|
||||
case nzPixelFormat_Stencil8:
|
||||
return "Stencil8";
|
||||
|
||||
case nzPixelFormat_Stencil16:
|
||||
return "Stencil16";
|
||||
|
||||
case nzPixelFormat_Undefined:
|
||||
return "Undefined";
|
||||
}
|
||||
|
||||
NazaraError("Invalid pixel format");
|
||||
return "Invalid format";
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
|
||||
@@ -1,51 +1,51 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// 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/Core/ResourceListener.hpp>
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
|
||||
class NAZARA_API NzStaticMesh final : public NzSubMesh, NzResourceListener
|
||||
{
|
||||
public:
|
||||
NzStaticMesh(const NzMesh* parent);
|
||||
NzStaticMesh(const NzMesh* parent, const NzVertexDeclaration* vertexDeclaration, NzVertexBuffer* vertexBuffer, NzIndexBuffer* indexBuffer = nullptr);
|
||||
virtual ~NzStaticMesh();
|
||||
|
||||
bool Create(const NzVertexDeclaration* vertexDeclaration, NzVertexBuffer* vertexBuffer, NzIndexBuffer* indexBuffer = nullptr);
|
||||
void Destroy();
|
||||
|
||||
bool GenerateAABB();
|
||||
|
||||
const NzAxisAlignedBox& GetAABB() const;
|
||||
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 SetAABB(const NzAxisAlignedBox& aabb);
|
||||
void SetPrimitiveType(nzPrimitiveType primitiveType);
|
||||
|
||||
private:
|
||||
void AnimateImpl(unsigned int frameA, unsigned int frameB, float interpolation);
|
||||
void OnResourceReleased(const NzResource* resource, int index) override;
|
||||
|
||||
nzPrimitiveType m_primitiveType = nzPrimitiveType_TriangleList;
|
||||
NzAxisAlignedBox m_aabb;
|
||||
NzIndexBuffer* m_indexBuffer = nullptr;
|
||||
NzVertexBuffer* m_vertexBuffer = nullptr;
|
||||
const NzVertexDeclaration* m_vertexDeclaration = nullptr;
|
||||
};
|
||||
|
||||
#endif // NAZARA_STATICMESH_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// 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/Core/ResourceListener.hpp>
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
|
||||
class NAZARA_API NzStaticMesh final : public NzSubMesh, NzResourceListener
|
||||
{
|
||||
public:
|
||||
NzStaticMesh(const NzMesh* parent);
|
||||
NzStaticMesh(const NzMesh* parent, const NzVertexDeclaration* vertexDeclaration, NzVertexBuffer* vertexBuffer, NzIndexBuffer* indexBuffer = nullptr);
|
||||
virtual ~NzStaticMesh();
|
||||
|
||||
bool Create(const NzVertexDeclaration* vertexDeclaration, NzVertexBuffer* vertexBuffer, NzIndexBuffer* indexBuffer = nullptr);
|
||||
void Destroy();
|
||||
|
||||
bool GenerateAABB();
|
||||
|
||||
const NzAxisAlignedBox& GetAABB() const;
|
||||
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 SetAABB(const NzAxisAlignedBox& aabb);
|
||||
void SetPrimitiveType(nzPrimitiveType primitiveType);
|
||||
|
||||
private:
|
||||
void AnimateImpl(unsigned int frameA, unsigned int frameB, float interpolation);
|
||||
void OnResourceReleased(const NzResource* resource, int index) override;
|
||||
|
||||
nzPrimitiveType m_primitiveType = nzPrimitiveType_TriangleList;
|
||||
NzAxisAlignedBox m_aabb;
|
||||
NzIndexBuffer* m_indexBuffer = nullptr;
|
||||
NzVertexBuffer* m_vertexBuffer = nullptr;
|
||||
const NzVertexDeclaration* m_vertexDeclaration = nullptr;
|
||||
};
|
||||
|
||||
#endif // NAZARA_STATICMESH_HPP
|
||||
|
||||
@@ -1,56 +1,56 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// 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/Core/Resource.hpp>
|
||||
#include <Nazara/Utility/Enums.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) noexcept;
|
||||
~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) noexcept;
|
||||
|
||||
static unsigned int GetElementCount(nzElementType type);
|
||||
static unsigned int GetElementSize(nzElementType type);
|
||||
|
||||
private:
|
||||
NzVertexDeclarationImpl* m_sharedImpl = nullptr;
|
||||
};
|
||||
|
||||
#endif // NAZARA_VERTEXDECLARATION_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// 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/Core/Resource.hpp>
|
||||
#include <Nazara/Utility/Enums.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) noexcept;
|
||||
~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) noexcept;
|
||||
|
||||
static unsigned int GetElementCount(nzElementType type);
|
||||
static unsigned int GetElementSize(nzElementType type);
|
||||
|
||||
private:
|
||||
NzVertexDeclarationImpl* m_sharedImpl = nullptr;
|
||||
};
|
||||
|
||||
#endif // NAZARA_VERTEXDECLARATION_HPP
|
||||
|
||||
@@ -1,112 +1,112 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// Interface inspirée de la SFML par Laurent Gomila
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_WINDOW_HPP
|
||||
#define NAZARA_WINDOW_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#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>
|
||||
#include <queue>
|
||||
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
#include <Nazara/Core/ConditionVariable.hpp>
|
||||
#include <Nazara/Core/Mutex.hpp>
|
||||
#endif
|
||||
|
||||
class NzCursor;
|
||||
class NzImage;
|
||||
class NzIcon;
|
||||
class NzWindowImpl;
|
||||
|
||||
class NAZARA_API NzWindow : NzNonCopyable
|
||||
{
|
||||
friend NzWindowImpl;
|
||||
friend class NzMouse;
|
||||
friend class NzUtility;
|
||||
|
||||
public:
|
||||
NzWindow();
|
||||
NzWindow(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default);
|
||||
NzWindow(NzWindowHandle handle);
|
||||
virtual ~NzWindow();
|
||||
|
||||
bool Create(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default);
|
||||
bool Create(NzWindowHandle handle);
|
||||
|
||||
void Destroy();
|
||||
|
||||
void EnableKeyRepeat(bool enable);
|
||||
void EnableSmoothScrolling(bool enable);
|
||||
|
||||
NzWindowHandle GetHandle() const;
|
||||
unsigned int GetHeight() const;
|
||||
NzVector2i GetPosition() const;
|
||||
NzVector2ui GetSize() const;
|
||||
NzString GetTitle() const;
|
||||
unsigned int GetWidth() const;
|
||||
|
||||
bool HasFocus() const;
|
||||
|
||||
bool IsMinimized() const;
|
||||
bool IsOpen() const;
|
||||
bool IsValid() const;
|
||||
bool IsVisible() const;
|
||||
|
||||
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);
|
||||
void SetMinimumSize(int width, int height);
|
||||
void SetPosition(const NzVector2i& position);
|
||||
void SetPosition(int x, int y);
|
||||
void SetSize(const NzVector2i& size);
|
||||
void SetSize(unsigned int width, unsigned int height);
|
||||
void SetStayOnTop(bool stayOnTop);
|
||||
void SetTitle(const NzString& title);
|
||||
void SetVisible(bool visible);
|
||||
|
||||
bool WaitEvent(NzEvent* event);
|
||||
|
||||
protected:
|
||||
virtual bool OnWindowCreated();
|
||||
virtual void OnWindowDestroy();
|
||||
|
||||
NzWindowImpl* m_impl;
|
||||
|
||||
private:
|
||||
void IgnoreNextMouseEvent(int mouseX, int mouseY) const;
|
||||
void PushEvent(const NzEvent& event);
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
std::queue<NzEvent> m_events;
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
NzConditionVariable m_eventCondition;
|
||||
NzMutex m_eventMutex;
|
||||
NzMutex m_eventConditionMutex;
|
||||
bool m_eventListener;
|
||||
bool m_waitForEvent;
|
||||
#endif
|
||||
bool m_ownsWindow;
|
||||
};
|
||||
|
||||
#endif // NAZARA_WINDOW_HPP
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// Interface inspirée de la SFML par Laurent Gomila
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_WINDOW_HPP
|
||||
#define NAZARA_WINDOW_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#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>
|
||||
#include <queue>
|
||||
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
#include <Nazara/Core/ConditionVariable.hpp>
|
||||
#include <Nazara/Core/Mutex.hpp>
|
||||
#endif
|
||||
|
||||
class NzCursor;
|
||||
class NzImage;
|
||||
class NzIcon;
|
||||
class NzWindowImpl;
|
||||
|
||||
class NAZARA_API NzWindow : NzNonCopyable
|
||||
{
|
||||
friend NzWindowImpl;
|
||||
friend class NzMouse;
|
||||
friend class NzUtility;
|
||||
|
||||
public:
|
||||
NzWindow();
|
||||
NzWindow(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default);
|
||||
NzWindow(NzWindowHandle handle);
|
||||
virtual ~NzWindow();
|
||||
|
||||
bool Create(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default);
|
||||
bool Create(NzWindowHandle handle);
|
||||
|
||||
void Destroy();
|
||||
|
||||
void EnableKeyRepeat(bool enable);
|
||||
void EnableSmoothScrolling(bool enable);
|
||||
|
||||
NzWindowHandle GetHandle() const;
|
||||
unsigned int GetHeight() const;
|
||||
NzVector2i GetPosition() const;
|
||||
NzVector2ui GetSize() const;
|
||||
NzString GetTitle() const;
|
||||
unsigned int GetWidth() const;
|
||||
|
||||
bool HasFocus() const;
|
||||
|
||||
bool IsMinimized() const;
|
||||
bool IsOpen() const;
|
||||
bool IsValid() const;
|
||||
bool IsVisible() const;
|
||||
|
||||
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);
|
||||
void SetMinimumSize(int width, int height);
|
||||
void SetPosition(const NzVector2i& position);
|
||||
void SetPosition(int x, int y);
|
||||
void SetSize(const NzVector2i& size);
|
||||
void SetSize(unsigned int width, unsigned int height);
|
||||
void SetStayOnTop(bool stayOnTop);
|
||||
void SetTitle(const NzString& title);
|
||||
void SetVisible(bool visible);
|
||||
|
||||
bool WaitEvent(NzEvent* event);
|
||||
|
||||
protected:
|
||||
virtual bool OnWindowCreated();
|
||||
virtual void OnWindowDestroy();
|
||||
|
||||
NzWindowImpl* m_impl;
|
||||
|
||||
private:
|
||||
void IgnoreNextMouseEvent(int mouseX, int mouseY) const;
|
||||
void PushEvent(const NzEvent& event);
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
std::queue<NzEvent> m_events;
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
NzConditionVariable m_eventCondition;
|
||||
NzMutex m_eventMutex;
|
||||
NzMutex m_eventConditionMutex;
|
||||
bool m_eventListener;
|
||||
bool m_waitForEvent;
|
||||
#endif
|
||||
bool m_ownsWindow;
|
||||
};
|
||||
|
||||
#endif // NAZARA_WINDOW_HPP
|
||||
|
||||
Reference in New Issue
Block a user