Merge branch 'master' into vulkan
This commit is contained in:
@@ -73,6 +73,7 @@ namespace Nz
|
||||
|
||||
bool FillAndQueueBuffer(unsigned int buffer);
|
||||
void MusicThread();
|
||||
void StopThread();
|
||||
|
||||
static MusicLoader::LoaderList s_loaders;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Nz
|
||||
{
|
||||
public:
|
||||
inline ByteStream(Stream* stream = nullptr);
|
||||
ByteStream(ByteArray* byteArray, UInt32 openMode = OpenMode_ReadWrite);
|
||||
ByteStream(ByteArray* byteArray, OpenModeFlags openMode = OpenMode_ReadWrite);
|
||||
ByteStream(void* ptr, Nz::UInt64 size);
|
||||
ByteStream(const void* ptr, Nz::UInt64 size);
|
||||
ByteStream(const ByteStream&) = delete;
|
||||
@@ -36,7 +36,7 @@ namespace Nz
|
||||
|
||||
inline void SetDataEndianness(Endianness endiannes);
|
||||
inline void SetStream(Stream* stream);
|
||||
void SetStream(ByteArray* byteArray, UInt32 openMode = OpenMode_ReadWrite);
|
||||
void SetStream(ByteArray* byteArray, OpenModeFlags openMode = OpenMode_ReadWrite);
|
||||
void SetStream(void* ptr, Nz::UInt64 size);
|
||||
void SetStream(const void* ptr, Nz::UInt64 size);
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#ifndef NAZARA_ENUMS_CORE_HPP
|
||||
#define NAZARA_ENUMS_CORE_HPP
|
||||
|
||||
#include <Nazara/Core/Flags.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
enum CoordSys
|
||||
@@ -73,23 +75,31 @@ namespace Nz
|
||||
HashType_Max = HashType_Whirlpool
|
||||
};
|
||||
|
||||
enum OpenModeFlags
|
||||
enum OpenMode
|
||||
{
|
||||
OpenMode_NotOpen = 0x00, // Use the current mod of opening
|
||||
OpenMode_NotOpen, // Use the current mod of opening
|
||||
|
||||
OpenMode_Append = 0x01, // Disable writing on existing parts and put the cursor at the end
|
||||
OpenMode_Lock = 0x02, // Disable modifying the file before it is open
|
||||
OpenMode_MustExit = 0x04, // Fail if the file doesn't exists, even if opened in write mode
|
||||
OpenMode_ReadOnly = 0x08, // Open in read only
|
||||
OpenMode_Text = 0x10, // Open in text mod
|
||||
OpenMode_Truncate = 0x20, // Create the file if it doesn't exist and empty it if it exists
|
||||
OpenMode_WriteOnly = 0x40, // Open in write only, create the file if it doesn't exist
|
||||
OpenMode_Append, // Disable writing on existing parts and put the cursor at the end
|
||||
OpenMode_Lock, // Disable modifying the file before it is open
|
||||
OpenMode_MustExist, // Fail if the file doesn't exists, even if opened in write mode
|
||||
OpenMode_ReadOnly, // Open in read only
|
||||
OpenMode_Text, // Open in text mod
|
||||
OpenMode_Truncate, // Create the file if it doesn't exist and empty it if it exists
|
||||
OpenMode_WriteOnly, // Open in write only, create the file if it doesn't exist
|
||||
|
||||
OpenMode_ReadWrite = OpenMode_ReadOnly | OpenMode_WriteOnly, // Open in read and write
|
||||
|
||||
OpenMode_Max = OpenMode_WriteOnly * 2 - 1
|
||||
OpenMode_Max = OpenMode_WriteOnly
|
||||
};
|
||||
|
||||
template<>
|
||||
struct EnableFlagsOperators<OpenMode>
|
||||
{
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
using OpenModeFlags = Flags<OpenMode>;
|
||||
|
||||
constexpr OpenModeFlags OpenMode_ReadWrite = OpenMode_ReadOnly | OpenMode_WriteOnly;
|
||||
|
||||
enum ParameterType
|
||||
{
|
||||
ParameterType_Boolean,
|
||||
@@ -173,16 +183,24 @@ namespace Nz
|
||||
SphereType_Max = SphereType_UV
|
||||
};
|
||||
|
||||
enum StreamOptionFlags
|
||||
enum StreamOption
|
||||
{
|
||||
StreamOption_None = 0,
|
||||
StreamOption_None,
|
||||
|
||||
StreamOption_Sequential = 0x1,
|
||||
StreamOption_Text = 0x2,
|
||||
StreamOption_Sequential,
|
||||
StreamOption_Text,
|
||||
|
||||
StreamOption_Max = StreamOption_Text * 2 - 1
|
||||
StreamOption_Max = StreamOption_Text
|
||||
};
|
||||
|
||||
template<>
|
||||
struct EnableFlagsOperators<StreamOption>
|
||||
{
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
using StreamOptionFlags = Flags<StreamOption>;
|
||||
|
||||
enum Ternary
|
||||
{
|
||||
Ternary_False,
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Nz
|
||||
public:
|
||||
File();
|
||||
File(const String& filePath);
|
||||
File(const String& filePath, UInt32 openMode);
|
||||
File(const String& filePath, OpenModeFlags openMode);
|
||||
File(const File&) = delete;
|
||||
File(File&& file) noexcept;
|
||||
~File();
|
||||
@@ -57,8 +57,8 @@ namespace Nz
|
||||
|
||||
bool IsOpen() const;
|
||||
|
||||
bool Open(unsigned int openMode = OpenMode_NotOpen);
|
||||
bool Open(const String& filePath, unsigned int openMode = OpenMode_NotOpen);
|
||||
bool Open(OpenModeFlags openMode = OpenMode_NotOpen);
|
||||
bool Open(const String& filePath, OpenModeFlags openMode = OpenMode_NotOpen);
|
||||
|
||||
bool Rename(const String& newFilePath);
|
||||
|
||||
|
||||
60
include/Nazara/Core/Flags.hpp
Normal file
60
include/Nazara/Core/Flags.hpp
Normal file
@@ -0,0 +1,60 @@
|
||||
// Copyright (C) 2016 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_FLAGS_HPP
|
||||
#define NAZARA_FLAGS_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
template<typename E>
|
||||
class Flags
|
||||
{
|
||||
static_assert(std::is_enum<E>::value, "Type must be an enumeration");
|
||||
|
||||
public:
|
||||
constexpr Flags(UInt32 value);
|
||||
constexpr Flags(E enumVal);
|
||||
|
||||
explicit constexpr operator bool() const;
|
||||
explicit constexpr operator UInt32() const;
|
||||
|
||||
constexpr Flags operator~() const;
|
||||
constexpr Flags operator&(Flags rhs) const;
|
||||
constexpr Flags operator|(Flags rhs) const;
|
||||
constexpr Flags operator^(Flags rhs) const;
|
||||
|
||||
constexpr bool operator==(Flags rhs) const;
|
||||
constexpr bool operator!=(Flags rhs) const;
|
||||
|
||||
/*constexpr*/ Flags& operator|=(Flags rhs);
|
||||
/*constexpr*/ Flags& operator&=(Flags rhs);
|
||||
/*constexpr*/ Flags& operator^=(Flags rhs);
|
||||
|
||||
static constexpr UInt32 GetFlagValue(E enumValue);
|
||||
|
||||
private:
|
||||
UInt32 m_value;
|
||||
};
|
||||
|
||||
// From: https://www.justsoftwaresolutions.co.uk/cplusplus/using-enum-classes-as-bitfields.html
|
||||
template<typename E>
|
||||
struct EnableFlagsOperators
|
||||
{
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
template<typename E> constexpr std::enable_if_t<EnableFlagsOperators<E>::value, Flags<E>> operator~(E lhs);
|
||||
template<typename E> constexpr std::enable_if_t<EnableFlagsOperators<E>::value, Flags<E>> operator|(E lhs, E rhs);
|
||||
template<typename E> constexpr std::enable_if_t<EnableFlagsOperators<E>::value, Flags<E>> operator&(E lhs, E rhs);
|
||||
template<typename E> constexpr std::enable_if_t<EnableFlagsOperators<E>::value, Flags<E>> operator^(E lhs, E rhs);
|
||||
}
|
||||
|
||||
#include <Nazara/Core/Flags.inl>
|
||||
|
||||
#endif // NAZARA_FLAGS_HPP
|
||||
134
include/Nazara/Core/Flags.inl
Normal file
134
include/Nazara/Core/Flags.inl
Normal file
@@ -0,0 +1,134 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Flags.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
* \ingroup core
|
||||
* \class Nz::Flags
|
||||
* \brief Core class that represents a set of bits
|
||||
*
|
||||
* This class meets the requirements of Container, AllocatorAwareContainer, SequenceContainer
|
||||
*/
|
||||
|
||||
template<typename E>
|
||||
constexpr Flags<E>::Flags(UInt32 value) :
|
||||
m_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
constexpr Flags<E>::Flags(E enumVal) :
|
||||
Flags(GetFlagValue(enumVal))
|
||||
{
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
constexpr Flags<E>::operator bool() const
|
||||
{
|
||||
return m_value != 0;
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
constexpr Flags<E>::operator UInt32() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
constexpr Flags<E> Flags<E>::operator~() const
|
||||
{
|
||||
return Flags(~m_value);
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
constexpr Flags<E> Flags<E>::operator&(Flags rhs) const
|
||||
{
|
||||
return Flags(m_value & rhs.m_value);
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
constexpr Flags<E> Flags<E>::operator|(Flags rhs) const
|
||||
{
|
||||
return Flags(m_value | rhs.m_value);
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
constexpr Flags<E> Flags<E>::operator^(Flags rhs) const
|
||||
{
|
||||
return Flags(m_value ^ rhs.m_value);
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
constexpr bool Flags<E>::operator==(Flags rhs) const
|
||||
{
|
||||
return m_value == rhs.m_value;
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
constexpr bool Flags<E>::operator!=(Flags rhs) const
|
||||
{
|
||||
return !operator==(rhs);
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
/*constexpr*/ Flags<E>& Flags<E>::operator|=(Flags rhs)
|
||||
{
|
||||
m_value |= rhs.m_value;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
/*constexpr*/ Flags<E>& Flags<E>::operator&=(Flags rhs)
|
||||
{
|
||||
m_value &= rhs.m_value;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
/*constexpr*/ Flags<E>& Flags<E>::operator^=(Flags rhs)
|
||||
{
|
||||
m_value ^= rhs.m_value;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
constexpr UInt32 Flags<E>::GetFlagValue(E enumValue)
|
||||
{
|
||||
return 1U << static_cast<UInt32>(enumValue);
|
||||
}
|
||||
|
||||
|
||||
template<typename E>
|
||||
constexpr std::enable_if_t<EnableFlagsOperators<E>::value, Flags<E>> operator~(E lhs)
|
||||
{
|
||||
return ~Flags<E>(lhs);
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
constexpr std::enable_if_t<EnableFlagsOperators<E>::value, Flags<E>> operator|(E lhs, E rhs)
|
||||
{
|
||||
return Flags<E>(lhs) | rhs;
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
constexpr std::enable_if_t<EnableFlagsOperators<E>::value, Flags<E>> operator&(E lhs, E rhs)
|
||||
{
|
||||
return Flags<E>(lhs) & rhs;
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
constexpr std::enable_if_t<EnableFlagsOperators<E>::value, Flags<E>> operator^(E lhs, E rhs)
|
||||
{
|
||||
return Flags<E>(lhs) ^ rhs;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Nz
|
||||
{
|
||||
public:
|
||||
inline MemoryStream();
|
||||
inline MemoryStream(ByteArray* byteArray, UInt32 openMode = OpenMode_ReadWrite);
|
||||
inline MemoryStream(ByteArray* byteArray, OpenModeFlags openMode = OpenMode_ReadWrite);
|
||||
MemoryStream(const MemoryStream&) = default;
|
||||
MemoryStream(MemoryStream&&) = default;
|
||||
~MemoryStream() = default;
|
||||
@@ -32,7 +32,7 @@ namespace Nz
|
||||
UInt64 GetCursorPos() const override;
|
||||
UInt64 GetSize() const override;
|
||||
|
||||
void SetBuffer(ByteArray* byteArray, UInt32 openMode = OpenMode_ReadWrite);
|
||||
void SetBuffer(ByteArray* byteArray, OpenModeFlags openMode = OpenMode_ReadWrite);
|
||||
bool SetCursorPos(UInt64 offset) override;
|
||||
|
||||
MemoryStream& operator=(const MemoryStream&) = default;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Nz
|
||||
* \param byteArray Bytes to stream
|
||||
* \param openMode Reading/writing mode for the stream
|
||||
*/
|
||||
inline MemoryStream::MemoryStream(ByteArray* byteArray, UInt32 openMode) :
|
||||
inline MemoryStream::MemoryStream(ByteArray* byteArray, OpenModeFlags openMode) :
|
||||
MemoryStream()
|
||||
{
|
||||
SetBuffer(byteArray, openMode);
|
||||
|
||||
@@ -32,8 +32,8 @@ namespace Nz
|
||||
virtual UInt64 GetCursorPos() const = 0;
|
||||
virtual String GetDirectory() const;
|
||||
virtual String GetPath() const;
|
||||
inline UInt32 GetOpenMode() const;
|
||||
inline UInt32 GetStreamOptions() const;
|
||||
inline OpenModeFlags GetOpenMode() const;
|
||||
inline StreamOptionFlags GetStreamOptions() const;
|
||||
|
||||
virtual UInt64 GetSize() const = 0;
|
||||
|
||||
@@ -55,14 +55,14 @@ namespace Nz
|
||||
Stream& operator=(Stream&&) = default;
|
||||
|
||||
protected:
|
||||
inline Stream(UInt32 streamOptions = StreamOption_None, UInt32 openMode = OpenMode_NotOpen);
|
||||
inline Stream(StreamOptionFlags streamOptions = StreamOption_None, OpenModeFlags openMode = OpenMode_NotOpen);
|
||||
|
||||
virtual void FlushStream() = 0;
|
||||
virtual std::size_t ReadBlock(void* buffer, std::size_t size) = 0;
|
||||
virtual std::size_t WriteBlock(const void* buffer, std::size_t size) = 0;
|
||||
|
||||
UInt32 m_openMode;
|
||||
UInt32 m_streamOptions;
|
||||
OpenModeFlags m_openMode;
|
||||
StreamOptionFlags m_streamOptions;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Nz
|
||||
* \param openMode Reading/writing mode for the stream
|
||||
*/
|
||||
|
||||
inline Stream::Stream(UInt32 streamOptions, UInt32 openMode) :
|
||||
inline Stream::Stream(StreamOptionFlags streamOptions, OpenModeFlags openMode) :
|
||||
m_openMode(openMode),
|
||||
m_streamOptions(streamOptions)
|
||||
{
|
||||
@@ -53,7 +53,7 @@ namespace Nz
|
||||
* \return Reading/writing mode for the stream
|
||||
*/
|
||||
|
||||
inline UInt32 Stream::GetOpenMode() const
|
||||
inline OpenModeFlags Stream::GetOpenMode() const
|
||||
{
|
||||
return m_openMode;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ namespace Nz
|
||||
* \return Options of the stream
|
||||
*/
|
||||
|
||||
inline UInt32 Stream::GetStreamOptions() const
|
||||
inline StreamOptionFlags Stream::GetStreamOptions() const
|
||||
{
|
||||
return m_streamOptions;
|
||||
}
|
||||
@@ -116,7 +116,7 @@ namespace Nz
|
||||
* \param size Size meant to be read
|
||||
*
|
||||
* \remark Produces a NazaraAssert if stream is not readable
|
||||
* \remark If preallocated space of buffer is less than the size, the behaviour is undefined
|
||||
* \remark If preallocated space of buffer is less than the size, the behavior is undefined
|
||||
*/
|
||||
|
||||
inline std::size_t Stream::Read(void* buffer, std::size_t size)
|
||||
@@ -134,7 +134,7 @@ namespace Nz
|
||||
* \param size Size meant to be written
|
||||
*
|
||||
* \remark Produces a NazaraAssert if stream is not writable
|
||||
* \remark If preallocated space of buffer is less than the size, the behaviour is undefined
|
||||
* \remark If preallocated space of buffer is less than the size, the behavior is undefined
|
||||
*/
|
||||
|
||||
inline std::size_t Stream::Write(const void* buffer, std::size_t size)
|
||||
|
||||
@@ -82,6 +82,7 @@ namespace Nz
|
||||
|
||||
char* GetBuffer();
|
||||
std::size_t GetCapacity() const;
|
||||
std::size_t GetCharacterPosition(std::size_t characterIndex) const;
|
||||
const char* GetConstBuffer() const;
|
||||
std::size_t GetLength() const;
|
||||
std::size_t GetSize() const;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <Nazara/Graphics/Billboard.hpp>
|
||||
#include <Nazara/Graphics/ColorBackground.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Graphics/CullingList.hpp>
|
||||
#include <Nazara/Graphics/DeferredBloomPass.hpp>
|
||||
#include <Nazara/Graphics/DeferredDOFPass.hpp>
|
||||
#include <Nazara/Graphics/DeferredFinalPass.hpp>
|
||||
|
||||
180
include/Nazara/Graphics/CullingList.hpp
Normal file
180
include/Nazara/Graphics/CullingList.hpp
Normal file
@@ -0,0 +1,180 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CULLINGLIST_HPP
|
||||
#define NAZARA_CULLINGLIST_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Graphics/Enums.hpp>
|
||||
#include <Nazara/Math/BoundingVolume.hpp>
|
||||
#include <Nazara/Math/Frustum.hpp>
|
||||
#include <Nazara/Math/Sphere.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
template<typename T>
|
||||
class CullingList
|
||||
{
|
||||
public:
|
||||
template<CullTest> class Entry;
|
||||
class NoTestEntry;
|
||||
class SphereEntry;
|
||||
class VolumeEntry;
|
||||
|
||||
template<CullTest> friend class Entry;
|
||||
friend NoTestEntry;
|
||||
friend SphereEntry;
|
||||
friend VolumeEntry;
|
||||
|
||||
using ResultContainer = std::vector<const T*>;
|
||||
|
||||
CullingList() = default;
|
||||
CullingList(const CullingList& renderable) = delete;
|
||||
CullingList(CullingList&& renderable) = delete;
|
||||
~CullingList();
|
||||
|
||||
std::size_t Cull(const Frustumf& frustum, bool* forceInvalidation = nullptr);
|
||||
|
||||
NoTestEntry RegisterNoTest(const T* renderable);
|
||||
SphereEntry RegisterSphereTest(const T* renderable);
|
||||
VolumeEntry RegisterVolumeTest(const T* renderable);
|
||||
|
||||
CullingList& operator=(const CullingList& renderable) = delete;
|
||||
CullingList& operator=(CullingList&& renderable) = delete;
|
||||
|
||||
// STL API
|
||||
typename ResultContainer::iterator begin();
|
||||
typename ResultContainer::const_iterator begin() const;
|
||||
|
||||
typename ResultContainer::const_iterator cbegin() const;
|
||||
typename ResultContainer::const_iterator cend() const;
|
||||
typename ResultContainer::const_reverse_iterator crbegin() const;
|
||||
typename ResultContainer::const_reverse_iterator crend() const;
|
||||
|
||||
bool empty() const;
|
||||
|
||||
typename ResultContainer::iterator end();
|
||||
typename ResultContainer::const_iterator end() const;
|
||||
|
||||
typename ResultContainer::reverse_iterator rbegin();
|
||||
typename ResultContainer::const_reverse_iterator rbegin() const;
|
||||
|
||||
typename ResultContainer::reverse_iterator rend();
|
||||
typename ResultContainer::const_reverse_iterator rend() const;
|
||||
|
||||
typename ResultContainer::size_type size() const;
|
||||
|
||||
NazaraSignal(OnCullingListRelease, CullingList* /*cullingList*/);
|
||||
|
||||
private:
|
||||
inline void NotifyForceInvalidation(CullTest type, std::size_t index);
|
||||
inline void NotifyMovement(CullTest type, std::size_t index, void* oldPtr, void* newPtr);
|
||||
inline void NotifyRelease(CullTest type, std::size_t index);
|
||||
inline void NotifySphereUpdate(std::size_t index, const Spheref& sphere);
|
||||
inline void NotifyVolumeUpdate(std::size_t index, const BoundingVolumef& boundingVolume);
|
||||
|
||||
struct NoTestVisibilityEntry
|
||||
{
|
||||
NoTestEntry* entry;
|
||||
const T* renderable;
|
||||
bool forceInvalidation;
|
||||
};
|
||||
|
||||
struct SphereVisibilityEntry
|
||||
{
|
||||
Spheref sphere;
|
||||
SphereEntry* entry;
|
||||
const T* renderable;
|
||||
bool forceInvalidation;
|
||||
};
|
||||
|
||||
struct VolumeVisibilityEntry
|
||||
{
|
||||
BoundingVolumef volume;
|
||||
VolumeEntry* entry;
|
||||
const T* renderable;
|
||||
bool forceInvalidation;
|
||||
};
|
||||
|
||||
std::vector<NoTestVisibilityEntry> m_noTestList;
|
||||
std::vector<SphereVisibilityEntry> m_sphereTestList;
|
||||
std::vector<VolumeVisibilityEntry> m_volumeTestList;
|
||||
ResultContainer m_results;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
template<CullTest Type>
|
||||
class CullingList<T>::Entry
|
||||
{
|
||||
public:
|
||||
Entry();
|
||||
Entry(const Entry&) = delete;
|
||||
Entry(Entry&& entry);
|
||||
~Entry();
|
||||
|
||||
void ForceInvalidation();
|
||||
|
||||
CullingList* GetParent() const;
|
||||
|
||||
void UpdateIndex(std::size_t index);
|
||||
|
||||
Entry& operator=(const Entry&) = delete;
|
||||
Entry& operator=(Entry&& entry);
|
||||
|
||||
protected:
|
||||
Entry(CullingList* parent, std::size_t index);
|
||||
|
||||
std::size_t m_index;
|
||||
CullingList* m_parent;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class CullingList<T>::NoTestEntry : public CullingList::template Entry<CullTest::NoTest>
|
||||
{
|
||||
friend CullingList;
|
||||
|
||||
public:
|
||||
NoTestEntry();
|
||||
|
||||
private:
|
||||
NoTestEntry(CullingList* parent, std::size_t index);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class CullingList<T>::SphereEntry : public CullingList::template Entry<CullTest::Sphere>
|
||||
{
|
||||
friend CullingList;
|
||||
|
||||
public:
|
||||
SphereEntry();
|
||||
|
||||
void UpdateSphere(const Spheref& sphere);
|
||||
|
||||
private:
|
||||
SphereEntry(CullingList* parent, std::size_t index);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class CullingList<T>::VolumeEntry : public CullingList::template Entry<CullTest::Volume>
|
||||
{
|
||||
friend CullingList;
|
||||
|
||||
public:
|
||||
VolumeEntry();
|
||||
|
||||
void UpdateVolume(const BoundingVolumef& sphere);
|
||||
|
||||
private:
|
||||
VolumeEntry(CullingList* parent, std::size_t index);
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Graphics/CullingList.inl>
|
||||
|
||||
#endif // NAZARA_CULLINGLIST_HPP
|
||||
431
include/Nazara/Graphics/CullingList.inl
Normal file
431
include/Nazara/Graphics/CullingList.inl
Normal file
@@ -0,0 +1,431 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Graphics/CullingList.hpp>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
template<typename T>
|
||||
CullingList<T>::~CullingList()
|
||||
{
|
||||
OnCullingListRelease(this);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::size_t CullingList<T>::Cull(const Frustumf& frustum, bool* forceInvalidation)
|
||||
{
|
||||
m_results.clear();
|
||||
|
||||
bool forcedInvalidation = false;
|
||||
|
||||
std::size_t visibleHash = 0U;
|
||||
|
||||
for (NoTestVisibilityEntry& entry : m_noTestList)
|
||||
{
|
||||
m_results.push_back(entry.renderable);
|
||||
Nz::HashCombine(visibleHash, entry.renderable);
|
||||
|
||||
if (entry.forceInvalidation)
|
||||
{
|
||||
forcedInvalidation = true;
|
||||
entry.forceInvalidation = false;
|
||||
}
|
||||
}
|
||||
|
||||
for (SphereVisibilityEntry& entry : m_sphereTestList)
|
||||
{
|
||||
if (frustum.Contains(entry.sphere))
|
||||
{
|
||||
m_results.push_back(entry.renderable);
|
||||
Nz::HashCombine(visibleHash, entry.renderable);
|
||||
|
||||
if (entry.forceInvalidation)
|
||||
{
|
||||
forcedInvalidation = true;
|
||||
entry.forceInvalidation = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (VolumeVisibilityEntry& entry : m_volumeTestList)
|
||||
{
|
||||
if (frustum.Contains(entry.volume))
|
||||
{
|
||||
m_results.push_back(entry.renderable);
|
||||
Nz::HashCombine(visibleHash, entry.renderable);
|
||||
|
||||
if (entry.forceInvalidation)
|
||||
{
|
||||
forcedInvalidation = true;
|
||||
entry.forceInvalidation = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (forceInvalidation)
|
||||
*forceInvalidation = forcedInvalidation;
|
||||
|
||||
return visibleHash;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename CullingList<T>::NoTestEntry CullingList<T>::RegisterNoTest(const T* renderable)
|
||||
{
|
||||
NoTestEntry entry(this, m_noTestList.size());
|
||||
m_noTestList.emplace_back(NoTestVisibilityEntry{&entry, renderable, false}); //< Address of entry will be updated when moving
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename CullingList<T>::SphereEntry CullingList<T>::RegisterSphereTest(const T* renderable)
|
||||
{
|
||||
SphereEntry entry(this, m_sphereTestList.size());
|
||||
m_sphereTestList.emplace_back(SphereVisibilityEntry{Nz::Spheref(), &entry, renderable, false}); //< Address of entry will be updated when moving
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename CullingList<T>::VolumeEntry CullingList<T>::RegisterVolumeTest(const T* renderable)
|
||||
{
|
||||
VolumeEntry entry(this, m_volumeTestList.size());
|
||||
m_volumeTestList.emplace_back(VolumeVisibilityEntry{Nz::BoundingVolumef(), &entry, renderable, false}); //< Address of entry will be updated when moving
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
// Interface STD
|
||||
template<typename T>
|
||||
typename CullingList<T>::ResultContainer::iterator CullingList<T>::begin()
|
||||
{
|
||||
return m_results.begin();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename CullingList<T>::ResultContainer::const_iterator CullingList<T>::begin() const
|
||||
{
|
||||
return m_results.begin();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename CullingList<T>::ResultContainer::const_iterator CullingList<T>::cbegin() const
|
||||
{
|
||||
return m_results.cbegin();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename CullingList<T>::ResultContainer::const_iterator CullingList<T>::cend() const
|
||||
{
|
||||
return m_results.cend();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename CullingList<T>::ResultContainer::const_reverse_iterator CullingList<T>::crbegin() const
|
||||
{
|
||||
return m_results.crbegin();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename CullingList<T>::ResultContainer::const_reverse_iterator CullingList<T>::crend() const
|
||||
{
|
||||
return m_results.crend();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool CullingList<T>::empty() const
|
||||
{
|
||||
return m_results.empty();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename CullingList<T>::ResultContainer::iterator CullingList<T>::end()
|
||||
{
|
||||
return m_results.end();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename CullingList<T>::ResultContainer::const_iterator CullingList<T>::end() const
|
||||
{
|
||||
return m_results.end();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename CullingList<T>::ResultContainer::reverse_iterator CullingList<T>::rbegin()
|
||||
{
|
||||
return m_results.rbegin();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename CullingList<T>::ResultContainer::const_reverse_iterator CullingList<T>::rbegin() const
|
||||
{
|
||||
return m_results.rbegin();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename CullingList<T>::ResultContainer::reverse_iterator CullingList<T>::rend()
|
||||
{
|
||||
return m_results.rend();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename CullingList<T>::ResultContainer::const_reverse_iterator CullingList<T>::rend() const
|
||||
{
|
||||
return m_results.rend();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename CullingList<T>::ResultContainer::size_type CullingList<T>::size() const
|
||||
{
|
||||
return m_results.size();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CullingList<T>::NotifyForceInvalidation(CullTest type, std::size_t index)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CullTest::NoTest:
|
||||
{
|
||||
m_noTestList[index].forceInvalidation = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case CullTest::Sphere:
|
||||
{
|
||||
m_sphereTestList[index].forceInvalidation = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case CullTest::Volume:
|
||||
{
|
||||
m_volumeTestList[index].forceInvalidation = true;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
NazaraInternalError("Unhandled culltype");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CullingList<T>::NotifyMovement(CullTest type, std::size_t index, void* oldPtr, void* newPtr)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CullTest::NoTest:
|
||||
{
|
||||
NoTestVisibilityEntry& entry = m_noTestList[index];
|
||||
NazaraAssert(entry.entry == oldPtr, "Invalid entry");
|
||||
|
||||
entry.entry = static_cast<NoTestEntry*>(newPtr);
|
||||
break;
|
||||
}
|
||||
|
||||
case CullTest::Sphere:
|
||||
{
|
||||
SphereVisibilityEntry& entry = m_sphereTestList[index];
|
||||
NazaraAssert(entry.entry == oldPtr, "Invalid sphere entry");
|
||||
|
||||
entry.entry = static_cast<SphereEntry*>(newPtr);
|
||||
break;
|
||||
}
|
||||
|
||||
case CullTest::Volume:
|
||||
{
|
||||
VolumeVisibilityEntry& entry = m_volumeTestList[index];
|
||||
NazaraAssert(entry.entry == oldPtr, "Invalid volume entry");
|
||||
|
||||
entry.entry = static_cast<VolumeEntry*>(newPtr);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
NazaraInternalError("Unhandled culltype");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CullingList<T>::NotifyRelease(CullTest type, std::size_t index)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CullTest::NoTest:
|
||||
{
|
||||
m_noTestList[index] = std::move(m_noTestList.back());
|
||||
m_noTestList[index].entry->UpdateIndex(index);
|
||||
m_noTestList.pop_back();
|
||||
break;
|
||||
}
|
||||
|
||||
case CullTest::Sphere:
|
||||
{
|
||||
m_sphereTestList[index] = std::move(m_sphereTestList.back());
|
||||
m_sphereTestList[index].entry->UpdateIndex(index);
|
||||
m_sphereTestList.pop_back();
|
||||
break;
|
||||
}
|
||||
|
||||
case CullTest::Volume:
|
||||
{
|
||||
m_volumeTestList[index] = std::move(m_volumeTestList.back());
|
||||
m_volumeTestList[index].entry->UpdateIndex(index);
|
||||
m_volumeTestList.pop_back();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
NazaraInternalError("Unhandled culltype");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CullingList<T>::NotifySphereUpdate(std::size_t index, const Spheref& sphere)
|
||||
{
|
||||
m_sphereTestList[index].sphere = sphere;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CullingList<T>::NotifyVolumeUpdate(std::size_t index, const BoundingVolumef& boundingVolume)
|
||||
{
|
||||
m_volumeTestList[index].volume = boundingVolume;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename T>
|
||||
template<CullTest Type>
|
||||
CullingList<T>::Entry<Type>::Entry() :
|
||||
m_parent(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<CullTest Type>
|
||||
CullingList<T>::Entry<Type>::Entry(CullingList* parent, std::size_t index) :
|
||||
m_index(index),
|
||||
m_parent(parent)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<CullTest Type>
|
||||
CullingList<T>::Entry<Type>::Entry(Entry&& entry) :
|
||||
m_index(entry.m_index),
|
||||
m_parent(entry.m_parent)
|
||||
{
|
||||
if (m_parent)
|
||||
m_parent->NotifyMovement(Type, m_index, &entry, this);
|
||||
|
||||
entry.m_parent = nullptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<CullTest Type>
|
||||
CullingList<T>::Entry<Type>::~Entry()
|
||||
{
|
||||
if (m_parent)
|
||||
m_parent->NotifyRelease(Type, m_index);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<CullTest Type>
|
||||
void CullingList<T>::Entry<Type>::ForceInvalidation()
|
||||
{
|
||||
m_parent->NotifyForceInvalidation(Type, m_index);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<CullTest Type>
|
||||
CullingList<T>* CullingList<T>::Entry<Type>::GetParent() const
|
||||
{
|
||||
return m_parent;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<CullTest Type>
|
||||
void CullingList<T>::Entry<Type>::UpdateIndex(std::size_t index)
|
||||
{
|
||||
m_index = index;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<CullTest Type>
|
||||
#ifdef NAZARA_COMPILER_MSVC
|
||||
// MSVC bug
|
||||
typename CullingList<T>::Entry<Type>& CullingList<T>::Entry<Type>::operator=(Entry&& entry)
|
||||
#else
|
||||
typename CullingList<T>::template Entry<Type>& CullingList<T>::Entry<Type>::operator=(Entry&& entry)
|
||||
#endif
|
||||
{
|
||||
m_index = entry.m_index;
|
||||
m_parent = entry.m_parent;
|
||||
if (m_parent)
|
||||
m_parent->NotifyMovement(Type, m_index, &entry, this);
|
||||
|
||||
entry.m_parent = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename T>
|
||||
CullingList<T>::NoTestEntry::NoTestEntry() :
|
||||
Entry<CullTest::NoTest>()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
CullingList<T>::NoTestEntry::NoTestEntry(CullingList* parent, std::size_t index) :
|
||||
Entry<CullTest::NoTest>(parent, index)
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename T>
|
||||
CullingList<T>::SphereEntry::SphereEntry() :
|
||||
Entry<CullTest::Sphere>()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
CullingList<T>::SphereEntry::SphereEntry(CullingList* parent, std::size_t index) :
|
||||
Entry<CullTest::Sphere>(parent, index)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CullingList<T>::SphereEntry::UpdateSphere(const Spheref& sphere)
|
||||
{
|
||||
this->m_parent->NotifySphereUpdate(this->m_index, sphere);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename T>
|
||||
CullingList<T>::VolumeEntry::VolumeEntry() :
|
||||
Entry<CullTest::Volume>()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
CullingList<T>::VolumeEntry::VolumeEntry(CullingList* parent, std::size_t index) :
|
||||
Entry<CullTest::Volume>(parent, index)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CullingList<T>::VolumeEntry::UpdateVolume(const BoundingVolumef& volume)
|
||||
{
|
||||
this->m_parent->NotifyVolumeUpdate(this->m_index, volume);
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Graphics/DebugOff.hpp>
|
||||
@@ -19,6 +19,13 @@ namespace Nz
|
||||
BackgroundType_Max = BackgroundType_User
|
||||
};
|
||||
|
||||
enum class CullTest
|
||||
{
|
||||
NoTest,
|
||||
Sphere,
|
||||
Volume
|
||||
};
|
||||
|
||||
enum ProjectionType
|
||||
{
|
||||
ProjectionType_Orthogonal,
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <Nazara/Core/RefCounted.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Graphics/CullingList.hpp>
|
||||
#include <Nazara/Math/BoundingVolume.hpp>
|
||||
#include <Nazara/Math/Frustum.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
@@ -31,15 +32,17 @@ namespace Nz
|
||||
public:
|
||||
struct InstanceData;
|
||||
|
||||
InstancedRenderable() = default;
|
||||
inline InstancedRenderable();
|
||||
inline InstancedRenderable(const InstancedRenderable& renderable);
|
||||
InstancedRenderable(InstancedRenderable&& renderable) = delete;
|
||||
virtual ~InstancedRenderable();
|
||||
|
||||
virtual void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const = 0;
|
||||
|
||||
virtual bool Cull(const Frustumf& frustum, const InstanceData& instanceData) const;
|
||||
|
||||
inline void EnsureBoundingVolumeUpdated() const;
|
||||
|
||||
virtual void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const = 0;
|
||||
virtual bool Cull(const Frustumf& frustum, const InstanceData& instanceData) const;
|
||||
virtual const BoundingVolumef& GetBoundingVolume() const;
|
||||
virtual void InvalidateData(InstanceData* instanceData, UInt32 flags) const;
|
||||
virtual void UpdateBoundingVolume(InstanceData* instanceData) const;
|
||||
@@ -49,6 +52,7 @@ namespace Nz
|
||||
InstancedRenderable& operator=(InstancedRenderable&& renderable) = delete;
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnInstancedRenderableInvalidateBoundingVolume, const InstancedRenderable* /*instancedRenderable*/);
|
||||
NazaraSignal(OnInstancedRenderableInvalidateData, const InstancedRenderable* /*instancedRenderable*/, UInt32 /*flags*/);
|
||||
NazaraSignal(OnInstancedRenderableRelease, const InstancedRenderable* /*instancedRenderable*/);
|
||||
|
||||
@@ -83,14 +87,16 @@ namespace Nz
|
||||
};
|
||||
|
||||
protected:
|
||||
virtual void MakeBoundingVolume() const = 0;
|
||||
void InvalidateBoundingVolume();
|
||||
inline void InvalidateBoundingVolume();
|
||||
inline void InvalidateInstanceData(UInt32 flags);
|
||||
inline void UpdateBoundingVolume() const;
|
||||
|
||||
virtual void MakeBoundingVolume() const = 0;
|
||||
|
||||
mutable BoundingVolumef m_boundingVolume;
|
||||
|
||||
private:
|
||||
inline void UpdateBoundingVolume() const;
|
||||
|
||||
mutable bool m_boundingVolumeUpdated;
|
||||
|
||||
static InstancedRenderableLibrary::LibraryMap s_library;
|
||||
|
||||
@@ -4,12 +4,19 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
* \brief Constructs a InstancedRenderable object by default
|
||||
*/
|
||||
inline InstancedRenderable::InstancedRenderable() :
|
||||
m_boundingVolumeUpdated(false)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a InstancedRenderable object by assignation
|
||||
*
|
||||
* \param renderable InstancedRenderable to copy into this
|
||||
*/
|
||||
|
||||
inline InstancedRenderable::InstancedRenderable(const InstancedRenderable& renderable) :
|
||||
RefCounted(),
|
||||
m_boundingVolume(renderable.m_boundingVolume),
|
||||
@@ -34,6 +41,8 @@ namespace Nz
|
||||
inline void InstancedRenderable::InvalidateBoundingVolume()
|
||||
{
|
||||
m_boundingVolumeUpdated = false;
|
||||
|
||||
OnInstancedRenderableInvalidateBoundingVolume(this);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -69,6 +78,7 @@ namespace Nz
|
||||
inline void InstancedRenderable::UpdateBoundingVolume() const
|
||||
{
|
||||
MakeBoundingVolume();
|
||||
|
||||
m_boundingVolumeUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ namespace Nz
|
||||
void* GenerateParticle();
|
||||
void* GenerateParticles(unsigned int count);
|
||||
|
||||
inline void* GetBuffer();
|
||||
inline const void* GetBuffer() const;
|
||||
const ParticleDeclarationConstRef& GetDeclaration() const;
|
||||
std::size_t GetMaxParticleCount() const;
|
||||
std::size_t GetParticleCount() const;
|
||||
@@ -94,4 +96,6 @@ namespace Nz
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Graphics/ParticleGroup.inl>
|
||||
|
||||
#endif // NAZARA_PARTICLEGROUP_HPP
|
||||
|
||||
40
include/Nazara/Graphics/ParticleGroup.inl
Normal file
40
include/Nazara/Graphics/ParticleGroup.inl
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2016 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Graphics/ParticleGroup.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
* \brief Gets a raw pointer to the particle buffer
|
||||
*
|
||||
* This can be useful when working directly with a struct, or needing to iterate over all particles.
|
||||
*
|
||||
* \return Pointer to the buffer
|
||||
*
|
||||
* \see GetParticleCount
|
||||
*/
|
||||
inline void* ParticleGroup::GetBuffer()
|
||||
{
|
||||
return m_buffer.data();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets a raw pointer to the particle buffer
|
||||
*
|
||||
* This can be useful when working directly with a struct, or needing to iterate over all particles.
|
||||
*
|
||||
* \return Pointer to the buffer
|
||||
*
|
||||
* \see GetParticleCount
|
||||
*/
|
||||
inline const void* ParticleGroup::GetBuffer() const
|
||||
{
|
||||
return m_buffer.data();
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Graphics/DebugOff.hpp>
|
||||
@@ -22,6 +22,7 @@ namespace Nz
|
||||
|
||||
template<typename T> SparsePtr<T> GetComponentPtr(ParticleComponent component);
|
||||
template<typename T> SparsePtr<const T> GetComponentPtr(ParticleComponent component) const;
|
||||
inline void* GetPointer();
|
||||
|
||||
private:
|
||||
const ParticleDeclaration* m_declaration;
|
||||
|
||||
@@ -68,6 +68,18 @@ namespace Nz
|
||||
return SparsePtr<const T>();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets a raw pointer to the particle buffer
|
||||
*
|
||||
* This can be useful when working directly with a struct
|
||||
*
|
||||
* \return Pointer to the buffer
|
||||
*/
|
||||
inline void* ParticleMapper::GetPointer()
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Graphics/DebugOff.hpp>
|
||||
|
||||
@@ -21,16 +21,16 @@ namespace Nz
|
||||
Vector3f normal;
|
||||
Vector3f position;
|
||||
Vector3f velocity;
|
||||
UInt32 life;
|
||||
float life;
|
||||
float rotation;
|
||||
};
|
||||
|
||||
struct ParticleStruct_Model
|
||||
{
|
||||
Quaternionf rotation;
|
||||
Vector3f position;
|
||||
Vector3f velocity;
|
||||
UInt32 life;
|
||||
Quaternionf rotation;
|
||||
float life;
|
||||
};
|
||||
|
||||
struct ParticleStruct_Sprite
|
||||
@@ -38,7 +38,7 @@ namespace Nz
|
||||
Color color;
|
||||
Vector3f position;
|
||||
Vector3f velocity;
|
||||
UInt32 life;
|
||||
float life;
|
||||
float rotation;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -25,7 +25,9 @@ namespace Nz
|
||||
virtual ~Renderable();
|
||||
|
||||
virtual void AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix) const = 0;
|
||||
|
||||
virtual bool Cull(const Frustumf& frustum, const Matrix4f& transformMatrix) const;
|
||||
|
||||
inline void EnsureBoundingVolumeUpdated() const;
|
||||
virtual const BoundingVolumef& GetBoundingVolume() const;
|
||||
virtual void UpdateBoundingVolume(const Matrix4f& transformMatrix);
|
||||
@@ -36,11 +38,12 @@ namespace Nz
|
||||
protected:
|
||||
virtual void MakeBoundingVolume() const = 0;
|
||||
inline void InvalidateBoundingVolume();
|
||||
inline void UpdateBoundingVolume() const;
|
||||
|
||||
mutable BoundingVolumef m_boundingVolume;
|
||||
|
||||
private:
|
||||
inline void UpdateBoundingVolume() const;
|
||||
|
||||
mutable bool m_boundingVolumeUpdated;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -149,6 +149,7 @@ namespace Nz
|
||||
{
|
||||
m_scale = scale;
|
||||
|
||||
InvalidateBoundingVolume();
|
||||
InvalidateVertices();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <Nazara/Lua/LuaInstance.hpp>
|
||||
#include <Nazara/Core/Algorithm.hpp>
|
||||
#include <Nazara/Core/Flags.hpp>
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <limits>
|
||||
@@ -99,19 +100,50 @@ namespace Nz
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_enum<T>::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, TypeTag<T>)
|
||||
std::enable_if_t<std::is_enum<T>::value && !EnableFlagsOperators<T>::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, TypeTag<T>)
|
||||
{
|
||||
using UnderlyingT = std::underlying_type_t<T>;
|
||||
return LuaImplQueryArg(instance, index, reinterpret_cast<UnderlyingT*>(arg), TypeTag<UnderlyingT>());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_enum<T>::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, T defValue, TypeTag<T>)
|
||||
std::enable_if_t<std::is_enum<T>::value && !EnableFlagsOperators<T>::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, T defValue, TypeTag<T>)
|
||||
{
|
||||
using UnderlyingT = std::underlying_type_t<T>;
|
||||
return LuaImplQueryArg(instance, index, reinterpret_cast<UnderlyingT*>(arg), static_cast<UnderlyingT>(defValue), TypeTag<UnderlyingT>());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_enum<T>::value && EnableFlagsOperators<T>::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, TypeTag<T>)
|
||||
{
|
||||
using UnderlyingT = std::underlying_type_t<T>;
|
||||
|
||||
UnderlyingT pot2Val;
|
||||
unsigned int ret = LuaImplQueryArg(instance, index, &pot2Val, TypeTag<UnderlyingT>());
|
||||
|
||||
*arg = static_cast<T>(IntegralLog2Pot(pot2Val));
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_enum<T>::value && EnableFlagsOperators<T>::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, T defValue, TypeTag<T>)
|
||||
{
|
||||
using UnderlyingT = std::underlying_type_t<T>;
|
||||
|
||||
UnderlyingT pot2Val;
|
||||
unsigned int ret = LuaImplQueryArg(instance, index, &pot2Val, 1U << static_cast<UnderlyingT>(defValue), TypeTag<UnderlyingT>());
|
||||
|
||||
*arg = static_cast<T>(IntegralLog2Pot(pot2Val));
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Flags<E>* arg, TypeTag<Flags<E>>)
|
||||
{
|
||||
*arg = Flags<E>(instance.CheckBoundInteger<UInt32>(index));
|
||||
return 1;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_floating_point<T>::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, TypeTag<T>)
|
||||
{
|
||||
@@ -184,12 +216,26 @@ namespace Nz
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_enum<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<T>)
|
||||
std::enable_if_t<std::is_enum<T>::value && !EnableFlagsOperators<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<T>)
|
||||
{
|
||||
using EnumT = typename std::underlying_type<T>::type;
|
||||
return LuaImplReplyVal(instance, static_cast<EnumT>(val), TypeTag<EnumT>());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_enum<T>::value && EnableFlagsOperators<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<T>)
|
||||
{
|
||||
Flags<T> flags(val);
|
||||
return LuaImplReplyVal(instance, flags, TypeTag<decltype(flags)>());
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
int LuaImplReplyVal(const LuaInstance& instance, Flags<E> val, TypeTag<Flags<E>>)
|
||||
{
|
||||
instance.PushInteger(UInt32(val));
|
||||
return 1;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_integral<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<T>)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Nz
|
||||
void OnEmptyStream() override;
|
||||
|
||||
void FreeStream();
|
||||
void InitStream(std::size_t minCapacity, UInt64 cursorPos, UInt32 openMode);
|
||||
void InitStream(std::size_t minCapacity, UInt64 cursorPos, OpenModeFlags openMode);
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
@@ -28,17 +28,14 @@
|
||||
// Try to identify the compiler
|
||||
#if defined(__BORLANDC__)
|
||||
#define NAZARA_COMPILER_BORDLAND
|
||||
#define NAZARA_COMPILER_SUPPORTS_CPP11 (defined(__cplusplus) && __cplusplus >= 201103L)
|
||||
#define NAZARA_DEPRECATED(txt)
|
||||
#define NAZARA_FUNCTION __FUNC__
|
||||
#elif defined(__clang__)
|
||||
#define NAZARA_COMPILER_CLANG
|
||||
#define NAZARA_COMPILER_SUPPORTS_CPP11 (defined(__cplusplus) && __cplusplus >= 201103L)
|
||||
#define NAZARA_DEPRECATED(txt) __attribute__((__deprecated__(txt)))
|
||||
#define NAZARA_FUNCTION __PRETTY_FUNCTION__
|
||||
#elif defined(__GNUC__) || defined(__MINGW32__)
|
||||
#define NAZARA_COMPILER_GCC
|
||||
#define NAZARA_COMPILER_SUPPORTS_CPP11 (defined(__cplusplus) && __cplusplus >= 201103L)
|
||||
#define NAZARA_DEPRECATED(txt) __attribute__((__deprecated__(txt)))
|
||||
#define NAZARA_FUNCTION __PRETTY_FUNCTION__
|
||||
|
||||
@@ -50,26 +47,31 @@
|
||||
#endif
|
||||
#elif defined(__INTEL_COMPILER) || defined(__ICL)
|
||||
#define NAZARA_COMPILER_INTEL
|
||||
#define NAZARA_COMPILER_SUPPORTS_CPP11 (defined(__cplusplus) && __cplusplus >= 201103L)
|
||||
#define NAZARA_DEPRECATED(txt)
|
||||
#define NAZARA_FUNCTION __FUNCTION__
|
||||
#elif defined(_MSC_VER)
|
||||
#define NAZARA_COMPILER_MSVC
|
||||
#define NAZARA_COMPILER_SUPPORTS_CPP11 (_MSC_VER >= 1900)
|
||||
#define NAZARA_DEPRECATED(txt) __declspec(deprecated(txt))
|
||||
#define NAZARA_FUNCTION __FUNCSIG__
|
||||
|
||||
#if _MSC_VER >= 1900
|
||||
#define NAZARA_COMPILER_SUPPORTS_CPP11
|
||||
#endif
|
||||
|
||||
#pragma warning(disable: 4251)
|
||||
#else
|
||||
#define NAZARA_COMPILER_UNKNOWN
|
||||
#define NAZARA_COMPILER_SUPPORTS_CPP11 (defined(__cplusplus) && __cplusplus >= 201103L)
|
||||
#define NAZARA_DEPRECATED(txt)
|
||||
#define NAZARA_FUNCTION __func__ // __func__ has been standardized in C++ 2011
|
||||
|
||||
#pragma message This compiler is not fully supported
|
||||
#endif
|
||||
|
||||
#if !NAZARA_COMPILER_SUPPORTS_CPP11
|
||||
#if !defined(NAZARA_COMPILER_SUPPORTS_CPP11) && defined(__cplusplus) && __cplusplus >= 201103L
|
||||
#define NAZARA_COMPILER_SUPPORTS_CPP11
|
||||
#endif
|
||||
|
||||
#ifndef NAZARA_COMPILER_SUPPORTS_CPP11
|
||||
#error Nazara requires a C++11 compliant compiler
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,13 +23,14 @@ namespace Nz
|
||||
{
|
||||
public:
|
||||
inline RenderWindow();
|
||||
inline RenderWindow(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const RenderWindowParameters& parameters = RenderWindowParameters());
|
||||
inline RenderWindow(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default, const RenderWindowParameters& parameters = RenderWindowParameters());
|
||||
inline RenderWindow(WindowHandle handle, const RenderWindowParameters& parameters = RenderWindowParameters());
|
||||
|
||||
RenderWindow(const RenderWindow&) = delete;
|
||||
RenderWindow(RenderWindow&&) = delete; ///TODO
|
||||
virtual ~RenderWindow();
|
||||
|
||||
inline bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const RenderWindowParameters& parameters = RenderWindowParameters());
|
||||
inline bool Create(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default, const RenderWindowParameters& parameters = RenderWindowParameters());
|
||||
inline bool Create(WindowHandle handle, const RenderWindowParameters& parameters = RenderWindowParameters());
|
||||
|
||||
void Display();
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
inline RenderWindow::RenderWindow(VideoMode mode, const String& title, UInt32 style, const RenderWindowParameters& parameters) :
|
||||
inline RenderWindow::RenderWindow(VideoMode mode, const String& title, WindowStyleFlags style, const RenderWindowParameters& parameters) :
|
||||
RenderWindow()
|
||||
{
|
||||
ErrorFlags errFlags(ErrorFlag_ThrowException, true);
|
||||
@@ -27,7 +27,7 @@ namespace Nz
|
||||
Create(handle, parameters);
|
||||
}
|
||||
|
||||
inline bool RenderWindow::Create(VideoMode mode, const String& title, UInt32 style, const RenderWindowParameters& parameters)
|
||||
inline bool RenderWindow::Create(VideoMode mode, const String& title, WindowStyleFlags style, const RenderWindowParameters& parameters)
|
||||
{
|
||||
m_parameters = parameters;
|
||||
|
||||
|
||||
139
include/Nazara/Renderer/Texture.hpp
Normal file
139
include/Nazara/Renderer/Texture.hpp
Normal file
@@ -0,0 +1,139 @@
|
||||
// Copyright (C) 2015 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/ObjectLibrary.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceManager.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Utility/AbstractImage.hpp>
|
||||
#include <Nazara/Utility/CubemapParams.hpp>
|
||||
#include <Nazara/Utility/Image.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class Texture;
|
||||
|
||||
using TextureConstRef = ObjectRef<const Texture>;
|
||||
using TextureLibrary = ObjectLibrary<Texture>;
|
||||
using TextureManager = ResourceManager<Texture, ImageParams>;
|
||||
using TextureRef = ObjectRef<Texture>;
|
||||
|
||||
struct TextureImpl;
|
||||
|
||||
class NAZARA_RENDERER_API Texture : public AbstractImage, public Resource
|
||||
{
|
||||
friend TextureLibrary;
|
||||
friend TextureManager;
|
||||
friend class Renderer;
|
||||
|
||||
public:
|
||||
Texture() = default;
|
||||
Texture(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1);
|
||||
explicit Texture(const Image& image);
|
||||
Texture(const Texture&) = delete;
|
||||
Texture(Texture&&) = delete;
|
||||
~Texture();
|
||||
|
||||
bool Create(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1);
|
||||
void Destroy();
|
||||
|
||||
bool Download(Image* image) const;
|
||||
|
||||
bool EnableMipmapping(bool enable);
|
||||
|
||||
void EnsureMipmapsUpdate() const;
|
||||
|
||||
unsigned int GetDepth(UInt8 level = 0) const override;
|
||||
PixelFormatType GetFormat() const override;
|
||||
unsigned int GetHeight(UInt8 level = 0) const override;
|
||||
UInt8 GetLevelCount() const override;
|
||||
UInt8 GetMaxLevel() const override;
|
||||
std::size_t GetMemoryUsage() const override;
|
||||
std::size_t GetMemoryUsage(UInt8 level) const override;
|
||||
Vector3ui GetSize(UInt8 level = 0) const override;
|
||||
ImageType GetType() const override;
|
||||
unsigned int GetWidth(UInt8 level = 0) const override;
|
||||
|
||||
bool HasMipmaps() const;
|
||||
|
||||
void InvalidateMipmaps();
|
||||
bool IsValid() const;
|
||||
|
||||
// Load
|
||||
bool LoadFromFile(const String& filePath, const ImageParams& params = ImageParams(), bool generateMipmaps = true);
|
||||
bool LoadFromImage(const Image& image, bool generateMipmaps = true);
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const ImageParams& params = ImageParams(), bool generateMipmaps = true);
|
||||
bool LoadFromStream(Stream& stream, const ImageParams& params = ImageParams(), bool generateMipmaps = true);
|
||||
|
||||
// LoadArray
|
||||
bool LoadArrayFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||
bool LoadArrayFromImage(const Image& image, bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||
bool LoadArrayFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||
bool LoadArrayFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||
|
||||
// LoadCubemap
|
||||
bool LoadCubemapFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
||||
bool LoadCubemapFromImage(const Image& image, bool generateMipmaps = true, const CubemapParams& params = CubemapParams());
|
||||
bool LoadCubemapFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
||||
bool LoadCubemapFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
||||
|
||||
// LoadFace
|
||||
bool LoadFaceFromFile(CubemapFace face, const String& filePath, const ImageParams& params = ImageParams());
|
||||
bool LoadFaceFromMemory(CubemapFace face, const void* data, std::size_t size, const ImageParams& params = ImageParams());
|
||||
bool LoadFaceFromStream(CubemapFace face, Stream& stream, const ImageParams& params = ImageParams());
|
||||
|
||||
// Save
|
||||
bool SaveToFile(const String& filePath, const ImageParams& params = ImageParams());
|
||||
bool SaveToStream(Stream& stream, const String& format, const ImageParams& params = ImageParams());
|
||||
|
||||
bool SetMipmapRange(UInt8 minLevel, UInt8 maxLevel);
|
||||
|
||||
bool Update(const Image& image, UInt8 level = 0);
|
||||
bool Update(const Image& image, const Boxui& box, UInt8 level = 0);
|
||||
bool Update(const Image& image, const Rectui& rect, unsigned int z = 0, UInt8 level = 0);
|
||||
bool Update(const UInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) override;
|
||||
bool Update(const UInt8* pixels, const Boxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) override;
|
||||
bool Update(const UInt8* pixels, const Rectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) override;
|
||||
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
|
||||
Texture& operator=(const Texture&) = delete;
|
||||
Texture& operator=(Texture&&) = delete;
|
||||
|
||||
static bool IsFormatSupported(PixelFormatType format);
|
||||
static bool IsMipmappingSupported();
|
||||
static bool IsTypeSupported(ImageType type);
|
||||
template<typename... Args> static TextureRef New(Args&&... args);
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnTextureDestroy, const Texture* /*texture*/);
|
||||
NazaraSignal(OnTextureRelease, const Texture* /*texture*/);
|
||||
|
||||
private:
|
||||
bool CreateTexture(bool proxy);
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
TextureImpl* m_impl = nullptr;
|
||||
|
||||
static TextureLibrary::LibraryMap s_library;
|
||||
static TextureManager::ManagerMap s_managerMap;
|
||||
static TextureManager::ManagerParams s_managerParameters;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/Texture.inl>
|
||||
|
||||
#endif // NAZARA_TEXTURE_HPP
|
||||
@@ -22,6 +22,7 @@ namespace Nz
|
||||
{
|
||||
public:
|
||||
struct Glyph;
|
||||
struct Line;
|
||||
|
||||
AbstractTextDrawer() = default;
|
||||
virtual ~AbstractTextDrawer();
|
||||
@@ -31,15 +32,24 @@ namespace Nz
|
||||
virtual std::size_t GetFontCount() const = 0;
|
||||
virtual const Glyph& GetGlyph(std::size_t index) const = 0;
|
||||
virtual std::size_t GetGlyphCount() const = 0;
|
||||
virtual const Line& GetLine(std::size_t index) const = 0;
|
||||
virtual std::size_t GetLineCount() const = 0;
|
||||
|
||||
struct Glyph
|
||||
{
|
||||
Color color;
|
||||
Rectf bounds;
|
||||
Rectui atlasRect;
|
||||
Vector2f corners[4];
|
||||
AbstractImage* atlas;
|
||||
bool flipped;
|
||||
};
|
||||
|
||||
struct Line
|
||||
{
|
||||
Rectf bounds;
|
||||
std::size_t glyphIndex;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#ifndef NAZARA_ENUMS_UTILITY_HPP
|
||||
#define NAZARA_ENUMS_UTILITY_HPP
|
||||
|
||||
#include <Nazara/Core/Flags.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
enum AnimationType
|
||||
@@ -430,20 +432,29 @@ namespace Nz
|
||||
WindowEventType_Max = WindowEventType_TextEntered
|
||||
};
|
||||
|
||||
enum WindowStyleFlags
|
||||
enum WindowStyle
|
||||
{
|
||||
WindowStyle_None = 0x0, ///< Window has no border nor titlebar.
|
||||
WindowStyle_Fullscreen = 0x1, ///< At the window creation, the OS tries to set it in fullscreen.
|
||||
WindowStyle_None, ///< Window has no border nor titlebar.
|
||||
WindowStyle_Fullscreen, ///< At the window creation, the OS tries to set it in fullscreen.
|
||||
|
||||
WindowStyle_Closable = 0x2, ///< Allows the window to be closed by a button in the titlebar, generating a Quit event.
|
||||
WindowStyle_Resizable = 0x4, ///< Allows the window to be resized by dragging its corners or by a button of the titlebar.
|
||||
WindowStyle_Titlebar = 0x8, ///< Adds a titlebar to the window, this option is automatically enabled if buttons of the titlebar are enabled.
|
||||
WindowStyle_Closable, ///< Allows the window to be closed by a button in the titlebar, generating a Quit event.
|
||||
WindowStyle_Resizable, ///< Allows the window to be resized by dragging its corners or by a button of the titlebar.
|
||||
WindowStyle_Titlebar, ///< Adds a titlebar to the window, this option is automatically enabled if buttons of the titlebar are enabled.
|
||||
|
||||
WindowStyle_Threaded = 0x10, ///< Runs the window into a thread, allowing the application to keep updating while resizing/dragging the window.
|
||||
WindowStyle_Threaded, ///< Runs the window into a thread, allowing the application to keep updating while resizing/dragging the window.
|
||||
|
||||
WindowStyle_Default = WindowStyle_Closable | WindowStyle_Resizable | WindowStyle_Titlebar,
|
||||
WindowStyle_Max = WindowStyle_Threaded*2-1
|
||||
WindowStyle_Max = WindowStyle_Threaded
|
||||
};
|
||||
|
||||
template<>
|
||||
struct EnableFlagsOperators<WindowStyle>
|
||||
{
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
using WindowStyleFlags = Flags<WindowStyle>;
|
||||
|
||||
constexpr WindowStyleFlags WindowStyle_Default = WindowStyle_Closable | WindowStyle_Resizable | WindowStyle_Titlebar;
|
||||
}
|
||||
|
||||
#endif // NAZARA_ENUMS_UTILITY_HPP
|
||||
|
||||
@@ -28,25 +28,15 @@ namespace Nz
|
||||
{
|
||||
struct NAZARA_UTILITY_API MeshParams : ResourceParameters
|
||||
{
|
||||
MeshParams(); // Vérifie que le storage par défaut est supporté (software autrement)
|
||||
MeshParams();
|
||||
|
||||
// La transformation appliquée à tous les sommets du mesh
|
||||
Matrix4f matrix = Matrix4f::Identity();
|
||||
|
||||
// Si ceci sera le stockage utilisé par les buffers
|
||||
UInt32 storage = DataStorage_Hardware;
|
||||
|
||||
// Charger une version animée du mesh si possible ?
|
||||
bool animated = true;
|
||||
|
||||
// Faut-il centrer le mesh autour de l'origine ?
|
||||
bool center = false;
|
||||
|
||||
// Faut-il retourner les UV ?
|
||||
bool flipUVs = false;
|
||||
|
||||
// Faut-il optimiser les index buffers ? (Rendu plus rapide, mais le chargement dure plus longtemps)
|
||||
bool optimizeIndexBuffers = true;
|
||||
Matrix4f matrix = Matrix4f::Identity(); ///< A matrix which will transform every vertex position
|
||||
UInt32 storage = DataStorage_Hardware; ///< The place where the buffers will be allocated
|
||||
Vector2f texCoordOffset = {0.f, 0.f}; ///< Offset to apply on the texture coordinates (not scaled)
|
||||
Vector2f texCoordScale = {1.f, 1.f}; ///< Scale to apply on the texture coordinates
|
||||
bool animated = true; ///< If true, will load an animated version of the model if possible
|
||||
bool center = false; ///< If true, will center the mesh vertices around the origin
|
||||
bool optimizeIndexBuffers = true; ///< Optimize the index buffers after loading, improve cache locality (and thus rendering speed) but increase loading time.
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
|
||||
@@ -36,6 +36,8 @@ namespace Nz
|
||||
std::size_t GetFontCount() const override;
|
||||
const Glyph& GetGlyph(std::size_t index) const override;
|
||||
std::size_t GetGlyphCount() const override;
|
||||
const Line& GetLine(std::size_t index) const override;
|
||||
std::size_t GetLineCount() const override;
|
||||
UInt32 GetStyle() const;
|
||||
const String& GetText() const;
|
||||
|
||||
@@ -68,6 +70,7 @@ namespace Nz
|
||||
NazaraSlot(Font, OnFontRelease, m_fontReleaseSlot);
|
||||
|
||||
mutable std::vector<Glyph> m_glyphs;
|
||||
mutable std::vector<Line> m_lines;
|
||||
Color m_color;
|
||||
FontRef m_font;
|
||||
mutable Rectf m_workingBounds;
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Nz
|
||||
|
||||
public:
|
||||
inline Window();
|
||||
inline Window(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default);
|
||||
inline Window(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default);
|
||||
inline Window(WindowHandle handle);
|
||||
Window(const Window&) = delete;
|
||||
inline Window(Window&& window) noexcept;
|
||||
@@ -44,7 +44,7 @@ namespace Nz
|
||||
|
||||
inline void Close();
|
||||
|
||||
bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default);
|
||||
bool Create(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default);
|
||||
bool Create(WindowHandle handle);
|
||||
|
||||
void Destroy();
|
||||
@@ -62,7 +62,7 @@ namespace Nz
|
||||
unsigned int GetHeight() const;
|
||||
Vector2i GetPosition() const;
|
||||
Vector2ui GetSize() const;
|
||||
UInt32 GetStyle() const;
|
||||
WindowStyleFlags GetStyle() const;
|
||||
String GetTitle() const;
|
||||
unsigned int GetWidth() const;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
inline Window::Window(VideoMode mode, const String& title, UInt32 style) :
|
||||
inline Window::Window(VideoMode mode, const String& title, WindowStyleFlags style) :
|
||||
Window()
|
||||
{
|
||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||
|
||||
Reference in New Issue
Block a user