Merge remote-tracking branch 'refs/remotes/origin/master' into culling
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)
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Nz
|
||||
{
|
||||
public:
|
||||
RenderWindow() = default;
|
||||
RenderWindow(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters());
|
||||
RenderWindow(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters());
|
||||
RenderWindow(WindowHandle handle, const ContextParameters& parameters = ContextParameters());
|
||||
RenderWindow(const RenderWindow&) = delete;
|
||||
RenderWindow(RenderWindow&&) = delete; ///TODO
|
||||
@@ -39,7 +39,7 @@ namespace Nz
|
||||
bool CopyToImage(AbstractImage* image, const Vector3ui& dstPos = Vector3ui(0U)) const;
|
||||
bool CopyToImage(AbstractImage* image, const Rectui& rect, const Vector3ui& dstPos = Vector3ui(0U)) const;
|
||||
|
||||
bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters());
|
||||
bool Create(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters());
|
||||
bool Create(WindowHandle handle, const ContextParameters& parameters = ContextParameters());
|
||||
|
||||
void Display();
|
||||
|
||||
@@ -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,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