Merge remote-tracking branch 'refs/remotes/origin/master' into vulkan
This commit is contained in:
commit
5f7f850d05
|
|
@ -91,9 +91,10 @@ namespace Nz
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct EnableFlagsOperators<OpenMode>
|
struct EnumAsFlags<OpenMode>
|
||||||
{
|
{
|
||||||
static constexpr bool value = true;
|
static constexpr bool value = true;
|
||||||
|
static constexpr int max = OpenMode_Max;
|
||||||
};
|
};
|
||||||
|
|
||||||
using OpenModeFlags = Flags<OpenMode>;
|
using OpenModeFlags = Flags<OpenMode>;
|
||||||
|
|
@ -194,9 +195,10 @@ namespace Nz
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct EnableFlagsOperators<StreamOption>
|
struct EnumAsFlags<StreamOption>
|
||||||
{
|
{
|
||||||
static constexpr bool value = true;
|
static constexpr bool value = true;
|
||||||
|
static constexpr int max = StreamOption_Max;
|
||||||
};
|
};
|
||||||
|
|
||||||
using StreamOptionFlags = Flags<StreamOption>;
|
using StreamOptionFlags = Flags<StreamOption>;
|
||||||
|
|
|
||||||
|
|
@ -12,47 +12,53 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
|
// From: https://www.justsoftwaresolutions.co.uk/cplusplus/using-enum-classes-as-bitfields.html
|
||||||
|
template<typename E>
|
||||||
|
struct EnumAsFlags
|
||||||
|
{
|
||||||
|
static constexpr bool value = false;
|
||||||
|
static constexpr int max = 0;
|
||||||
|
};
|
||||||
|
|
||||||
template<typename E>
|
template<typename E>
|
||||||
class Flags
|
class Flags
|
||||||
{
|
{
|
||||||
static_assert(std::is_enum<E>::value, "Type must be an enumeration");
|
static_assert(std::is_enum<E>::value, "Type must be an enumeration");
|
||||||
|
static_assert(EnumAsFlags<E>::value, "Enum has not been enabled as flags by an EnumAsFlags specialization");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
constexpr Flags(UInt32 value);
|
using BitField = typename std::conditional<(EnumAsFlags<E>::max > 32), UInt64, UInt32>::type;
|
||||||
|
|
||||||
|
constexpr Flags(BitField value);
|
||||||
constexpr Flags(E enumVal);
|
constexpr Flags(E enumVal);
|
||||||
|
|
||||||
explicit constexpr operator bool() const;
|
explicit constexpr operator bool() const;
|
||||||
explicit constexpr operator UInt32() const;
|
explicit constexpr operator BitField() const;
|
||||||
|
|
||||||
constexpr Flags operator~() const;
|
constexpr Flags operator~() const;
|
||||||
constexpr Flags operator&(Flags rhs) const;
|
constexpr Flags operator&(const Flags& rhs) const;
|
||||||
constexpr Flags operator|(Flags rhs) const;
|
constexpr Flags operator|(const Flags& rhs) const;
|
||||||
constexpr Flags operator^(Flags rhs) const;
|
constexpr Flags operator^(const Flags& rhs) const;
|
||||||
|
|
||||||
constexpr bool operator==(Flags rhs) const;
|
constexpr bool operator==(const Flags& rhs) const;
|
||||||
constexpr bool operator!=(Flags rhs) const;
|
constexpr bool operator!=(const Flags& rhs) const;
|
||||||
|
|
||||||
/*constexpr*/ Flags& operator|=(Flags rhs);
|
/*constexpr*/ Flags& operator|=(const Flags& rhs);
|
||||||
/*constexpr*/ Flags& operator&=(Flags rhs);
|
/*constexpr*/ Flags& operator&=(const Flags& rhs);
|
||||||
/*constexpr*/ Flags& operator^=(Flags rhs);
|
/*constexpr*/ Flags& operator^=(const Flags& rhs);
|
||||||
|
|
||||||
static constexpr UInt32 GetFlagValue(E enumValue);
|
static constexpr BitField GetFlagValue(E enumValue);
|
||||||
|
|
||||||
|
static constexpr BitField ValueMask = ((BitField(1) << (EnumAsFlags<E>::max + 1)) - 1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UInt32 m_value;
|
BitField m_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
// From: https://www.justsoftwaresolutions.co.uk/cplusplus/using-enum-classes-as-bitfields.html
|
template<typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator~(E lhs);
|
||||||
template<typename E>
|
template<typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator|(E lhs, E rhs);
|
||||||
struct EnableFlagsOperators
|
template<typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator&(E lhs, E rhs);
|
||||||
{
|
template<typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator^(E lhs, E rhs);
|
||||||
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>
|
#include <Nazara/Core/Flags.inl>
|
||||||
|
|
|
||||||
|
|
@ -10,122 +10,264 @@ namespace Nz
|
||||||
/*!
|
/*!
|
||||||
* \ingroup core
|
* \ingroup core
|
||||||
* \class Nz::Flags
|
* \class Nz::Flags
|
||||||
* \brief Core class that represents a set of bits
|
* \brief Core class used to combine enumeration values into flags bitfield
|
||||||
*
|
|
||||||
* This class meets the requirements of Container, AllocatorAwareContainer, SequenceContainer
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Constructs a Flags object using a bitfield
|
||||||
|
*
|
||||||
|
* \param value Bitfield to be used
|
||||||
|
*
|
||||||
|
* Uses a bitfield to builds the flag value. (e.g. if bit 0 is active, then Enum value 0 will be set as active).
|
||||||
|
*/
|
||||||
template<typename E>
|
template<typename E>
|
||||||
constexpr Flags<E>::Flags(UInt32 value) :
|
constexpr Flags<E>::Flags(BitField value) :
|
||||||
m_value(value)
|
m_value(value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Constructs a Flags object using an Enum value
|
||||||
|
*
|
||||||
|
* \param value enumVal
|
||||||
|
*
|
||||||
|
* Setup a Flags object with only one flag active (corresponding to the enum value passed as argument).
|
||||||
|
*/
|
||||||
template<typename E>
|
template<typename E>
|
||||||
constexpr Flags<E>::Flags(E enumVal) :
|
constexpr Flags<E>::Flags(E enumVal) :
|
||||||
Flags(GetFlagValue(enumVal))
|
Flags(GetFlagValue(enumVal))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Tests a Flags
|
||||||
|
* \return True if any flag is enabled.
|
||||||
|
*
|
||||||
|
* This will convert to a boolean value allowing to check if any flag is set.
|
||||||
|
*/
|
||||||
template<typename E>
|
template<typename E>
|
||||||
constexpr Flags<E>::operator bool() const
|
constexpr Flags<E>::operator bool() const
|
||||||
{
|
{
|
||||||
return m_value != 0;
|
return m_value != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Converts to a bitfield
|
||||||
|
* \return Enabled flags as a bitfield.
|
||||||
|
*
|
||||||
|
* This will convert to a bitfield value.
|
||||||
|
*/
|
||||||
template<typename E>
|
template<typename E>
|
||||||
constexpr Flags<E>::operator UInt32() const
|
constexpr Flags<E>::operator BitField() const
|
||||||
{
|
{
|
||||||
return m_value;
|
return m_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Reverse flag states
|
||||||
|
* \return Opposite enabled flags
|
||||||
|
*
|
||||||
|
* This will returns a copy of the Flags object with reversed flags states.
|
||||||
|
*/
|
||||||
template<typename E>
|
template<typename E>
|
||||||
constexpr Flags<E> Flags<E>::operator~() const
|
constexpr Flags<E> Flags<E>::operator~() const
|
||||||
{
|
{
|
||||||
return Flags(~m_value);
|
return Flags((~m_value) & ValueMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compare flag states
|
||||||
|
* \return Shared flags
|
||||||
|
*
|
||||||
|
* \param rhs Flags to compare with.
|
||||||
|
*
|
||||||
|
* This will returns a copy of the Flags object with only enabled flags in common with the parameter
|
||||||
|
*/
|
||||||
template<typename E>
|
template<typename E>
|
||||||
constexpr Flags<E> Flags<E>::operator&(Flags rhs) const
|
constexpr Flags<E> Flags<E>::operator&(const Flags& rhs) const
|
||||||
{
|
{
|
||||||
return Flags(m_value & rhs.m_value);
|
return Flags(m_value & rhs.m_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Combine flag states
|
||||||
|
* \return Combined flags
|
||||||
|
*
|
||||||
|
* This will returns a copy of the Flags object with combined flags from the parameter.
|
||||||
|
*
|
||||||
|
* \param rhs Flags to combine with.
|
||||||
|
*/
|
||||||
template<typename E>
|
template<typename E>
|
||||||
constexpr Flags<E> Flags<E>::operator|(Flags rhs) const
|
constexpr Flags<E> Flags<E>::operator|(const Flags& rhs) const
|
||||||
{
|
{
|
||||||
return Flags(m_value | rhs.m_value);
|
return Flags(m_value | rhs.m_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief XOR flag states
|
||||||
|
* \return XORed flags.
|
||||||
|
*
|
||||||
|
* \param rhs Flags to XOR with.
|
||||||
|
*
|
||||||
|
* This performs a XOR (Exclusive OR) on a copy of the flag object.
|
||||||
|
* This will returns a copy of the object with disabled common flags and enabled unique ones.
|
||||||
|
*/
|
||||||
template<typename E>
|
template<typename E>
|
||||||
constexpr Flags<E> Flags<E>::operator^(Flags rhs) const
|
constexpr Flags<E> Flags<E>::operator^(const Flags& rhs) const
|
||||||
{
|
{
|
||||||
return Flags(m_value ^ rhs.m_value);
|
return Flags((m_value ^ rhs.m_value) & ValueMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Check equality with flag object
|
||||||
|
* \return True if both flags objects have the same states.
|
||||||
|
*
|
||||||
|
* \param rhs Flags to compare with.
|
||||||
|
*
|
||||||
|
* Compare two Flags object and returns true if the flag states are identical.
|
||||||
|
*/
|
||||||
template<typename E>
|
template<typename E>
|
||||||
constexpr bool Flags<E>::operator==(Flags rhs) const
|
constexpr bool Flags<E>::operator==(const Flags& rhs) const
|
||||||
{
|
{
|
||||||
return m_value == rhs.m_value;
|
return m_value == rhs.m_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Check inequality with flag object
|
||||||
|
* \return True if both flags objects have different states.
|
||||||
|
*
|
||||||
|
* \param rhs Flags to compare with.
|
||||||
|
*
|
||||||
|
* Compare two Flags object and returns true if the flag states are identical.
|
||||||
|
*/
|
||||||
template<typename E>
|
template<typename E>
|
||||||
constexpr bool Flags<E>::operator!=(Flags rhs) const
|
constexpr bool Flags<E>::operator!=(const Flags& rhs) const
|
||||||
{
|
{
|
||||||
return !operator==(rhs);
|
return !operator==(rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Combine flag states
|
||||||
|
* \return A reference to the object.
|
||||||
|
*
|
||||||
|
* \param rhs Flags to combine with.
|
||||||
|
*
|
||||||
|
* This will enable flags which are enabled in parameter object and not in Flag object.
|
||||||
|
*/
|
||||||
template<typename E>
|
template<typename E>
|
||||||
/*constexpr*/ Flags<E>& Flags<E>::operator|=(Flags rhs)
|
/*constexpr*/ Flags<E>& Flags<E>::operator|=(const Flags& rhs)
|
||||||
{
|
{
|
||||||
m_value |= rhs.m_value;
|
m_value |= rhs.m_value;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Compare flag states
|
||||||
|
* \return A reference to the object.
|
||||||
|
*
|
||||||
|
* \param rhs Flags to compare with.
|
||||||
|
*
|
||||||
|
* This will disable flags which are disabled in parameter object and enabled in Flag object (and vice-versa).
|
||||||
|
*/
|
||||||
template<typename E>
|
template<typename E>
|
||||||
/*constexpr*/ Flags<E>& Flags<E>::operator&=(Flags rhs)
|
/*constexpr*/ Flags<E>& Flags<E>::operator&=(const Flags& rhs)
|
||||||
{
|
{
|
||||||
m_value &= rhs.m_value;
|
m_value &= rhs.m_value;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief XOR flag states
|
||||||
|
* \return A reference to the object.
|
||||||
|
*
|
||||||
|
* \param rhs Flags to XOR with.
|
||||||
|
*
|
||||||
|
* This performs a XOR (Exclusive OR) on the flag object.
|
||||||
|
* This will disable flags enabled in both Flags objects and enable those enabled in only one of the Flags objects.
|
||||||
|
*/
|
||||||
template<typename E>
|
template<typename E>
|
||||||
/*constexpr*/ Flags<E>& Flags<E>::operator^=(Flags rhs)
|
/*constexpr*/ Flags<E>& Flags<E>::operator^=(const Flags& rhs)
|
||||||
{
|
{
|
||||||
m_value ^= rhs.m_value;
|
m_value ^= rhs.m_value;
|
||||||
|
m_value &= ValueMask;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns a bitfield corresponding to an enum value.
|
||||||
|
* \return Bitfield representation of the enum value
|
||||||
|
*
|
||||||
|
* \param enumValue Enumeration value to get as a bitfield.
|
||||||
|
*
|
||||||
|
* Internally, every enum option is turned into a bit, this function allows to get a bitfield with only the bit of the enumeration value enabled.
|
||||||
|
*/
|
||||||
template<typename E>
|
template<typename E>
|
||||||
constexpr UInt32 Flags<E>::GetFlagValue(E enumValue)
|
constexpr typename Flags<E>::BitField Flags<E>::GetFlagValue(E enumValue)
|
||||||
{
|
{
|
||||||
return 1U << static_cast<UInt32>(enumValue);
|
return 1U << static_cast<BitField>(enumValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Override binary NOT operator on enum to turns into a Flags object.
|
||||||
|
* \return A Flags object with reversed bits.
|
||||||
|
*
|
||||||
|
* \param lhs Enumeration value to reverse.
|
||||||
|
*
|
||||||
|
* Returns a Flags object with all state enabled except for the enum one.
|
||||||
|
*/
|
||||||
template<typename E>
|
template<typename E>
|
||||||
constexpr std::enable_if_t<EnableFlagsOperators<E>::value, Flags<E>> operator~(E lhs)
|
constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator~(E lhs)
|
||||||
{
|
{
|
||||||
return ~Flags<E>(lhs);
|
return ~Flags<E>(lhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Override binary OR operator on enum to turns into a Flags object.
|
||||||
|
* \return A Flags object with combined enum states.
|
||||||
|
*
|
||||||
|
* \param lhs First enumeration value to combine.
|
||||||
|
* \param rhs Second enumeration value to combine.
|
||||||
|
*
|
||||||
|
* Returns a Flags object with combined states from the two enumeration values.
|
||||||
|
*/
|
||||||
template<typename E>
|
template<typename E>
|
||||||
constexpr std::enable_if_t<EnableFlagsOperators<E>::value, Flags<E>> operator|(E lhs, E rhs)
|
constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator|(E lhs, E rhs)
|
||||||
{
|
{
|
||||||
return Flags<E>(lhs) | rhs;
|
return Flags<E>(lhs) | rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Override binary AND operator on enum to turns into a Flags object.
|
||||||
|
* \return A Flags object with compare enum states.
|
||||||
|
*
|
||||||
|
* \param lhs First enumeration value to compare.
|
||||||
|
* \param rhs Second enumeration value to compare.
|
||||||
|
*
|
||||||
|
* Returns a Flags object with compared states from the two enumeration values.
|
||||||
|
* In this case, only one flag will be enabled if both enumeration values are the same.
|
||||||
|
*/
|
||||||
template<typename E>
|
template<typename E>
|
||||||
constexpr std::enable_if_t<EnableFlagsOperators<E>::value, Flags<E>> operator&(E lhs, E rhs)
|
constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator&(E lhs, E rhs)
|
||||||
{
|
{
|
||||||
return Flags<E>(lhs) & rhs;
|
return Flags<E>(lhs) & rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Override binary XOR operator on enum to turns into a Flags object.
|
||||||
|
* \return A Flags object with XORed enum states.
|
||||||
|
*
|
||||||
|
* \param lhs First enumeration value to compare.
|
||||||
|
* \param rhs Second enumeration value to compare.
|
||||||
|
*
|
||||||
|
* Returns a Flags object with XORed states from the two enumeration values.
|
||||||
|
* In this case, two flags will be enabled if both the enumeration values are different.
|
||||||
|
*/
|
||||||
template<typename E>
|
template<typename E>
|
||||||
constexpr std::enable_if_t<EnableFlagsOperators<E>::value, Flags<E>> operator^(E lhs, E rhs)
|
constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator^(E lhs, E rhs)
|
||||||
{
|
{
|
||||||
return Flags<E>(lhs) ^ rhs;
|
return Flags<E>(lhs) ^ rhs;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -100,21 +100,21 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
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>)
|
std::enable_if_t<std::is_enum<T>::value && !EnumAsFlags<T>::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, TypeTag<T>)
|
||||||
{
|
{
|
||||||
using UnderlyingT = std::underlying_type_t<T>;
|
using UnderlyingT = std::underlying_type_t<T>;
|
||||||
return LuaImplQueryArg(instance, index, reinterpret_cast<UnderlyingT*>(arg), TypeTag<UnderlyingT>());
|
return LuaImplQueryArg(instance, index, reinterpret_cast<UnderlyingT*>(arg), TypeTag<UnderlyingT>());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
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>)
|
std::enable_if_t<std::is_enum<T>::value && !EnumAsFlags<T>::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, T defValue, TypeTag<T>)
|
||||||
{
|
{
|
||||||
using UnderlyingT = std::underlying_type_t<T>;
|
using UnderlyingT = std::underlying_type_t<T>;
|
||||||
return LuaImplQueryArg(instance, index, reinterpret_cast<UnderlyingT*>(arg), static_cast<UnderlyingT>(defValue), TypeTag<UnderlyingT>());
|
return LuaImplQueryArg(instance, index, reinterpret_cast<UnderlyingT*>(arg), static_cast<UnderlyingT>(defValue), TypeTag<UnderlyingT>());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
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>)
|
std::enable_if_t<std::is_enum<T>::value && EnumAsFlags<T>::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, TypeTag<T>)
|
||||||
{
|
{
|
||||||
using UnderlyingT = std::underlying_type_t<T>;
|
using UnderlyingT = std::underlying_type_t<T>;
|
||||||
|
|
||||||
|
|
@ -126,7 +126,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
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>)
|
std::enable_if_t<std::is_enum<T>::value && EnumAsFlags<T>::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, T defValue, TypeTag<T>)
|
||||||
{
|
{
|
||||||
using UnderlyingT = std::underlying_type_t<T>;
|
using UnderlyingT = std::underlying_type_t<T>;
|
||||||
|
|
||||||
|
|
@ -216,14 +216,14 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::enable_if_t<std::is_enum<T>::value && !EnableFlagsOperators<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<T>)
|
std::enable_if_t<std::is_enum<T>::value && !EnumAsFlags<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<T>)
|
||||||
{
|
{
|
||||||
using EnumT = typename std::underlying_type<T>::type;
|
using EnumT = typename std::underlying_type<T>::type;
|
||||||
return LuaImplReplyVal(instance, static_cast<EnumT>(val), TypeTag<EnumT>());
|
return LuaImplReplyVal(instance, static_cast<EnumT>(val), TypeTag<EnumT>());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::enable_if_t<std::is_enum<T>::value && EnableFlagsOperators<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<T>)
|
std::enable_if_t<std::is_enum<T>::value && EnumAsFlags<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<T>)
|
||||||
{
|
{
|
||||||
Flags<T> flags(val);
|
Flags<T> flags(val);
|
||||||
return LuaImplReplyVal(instance, flags, TypeTag<decltype(flags)>());
|
return LuaImplReplyVal(instance, flags, TypeTag<decltype(flags)>());
|
||||||
|
|
|
||||||
|
|
@ -62,9 +62,10 @@ namespace Nz
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct EnableFlagsOperators<BufferUsage>
|
struct EnumAsFlags<BufferUsage>
|
||||||
{
|
{
|
||||||
static constexpr bool value = true;
|
static constexpr bool value = true;
|
||||||
|
static constexpr int max = BufferUsage_Max;
|
||||||
};
|
};
|
||||||
|
|
||||||
using BufferUsageFlags = Flags<BufferUsage>;
|
using BufferUsageFlags = Flags<BufferUsage>;
|
||||||
|
|
@ -453,9 +454,10 @@ namespace Nz
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct EnableFlagsOperators<WindowStyle>
|
struct EnumAsFlags<WindowStyle>
|
||||||
{
|
{
|
||||||
static constexpr bool value = true;
|
static constexpr bool value = true;
|
||||||
|
static constexpr int max = WindowStyle_Max;
|
||||||
};
|
};
|
||||||
|
|
||||||
using WindowStyleFlags = Flags<WindowStyle>;
|
using WindowStyleFlags = Flags<WindowStyle>;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
class Buffer;
|
class Buffer;
|
||||||
|
|
||||||
class SoftwareBuffer : public AbstractBuffer
|
class NAZARA_UTILITY_API SoftwareBuffer : public AbstractBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SoftwareBuffer(Buffer* parent, BufferType type);
|
SoftwareBuffer(Buffer* parent, BufferType type);
|
||||||
|
|
@ -184,7 +184,7 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters)
|
||||||
// Index buffer
|
// Index buffer
|
||||||
bool largeIndices = (vertexCount > std::numeric_limits<UInt16>::max());
|
bool largeIndices = (vertexCount > std::numeric_limits<UInt16>::max());
|
||||||
|
|
||||||
IndexBufferRef indexBuffer = IndexBuffer::New(largeIndices, indexCount, parameters.storage);
|
IndexBufferRef indexBuffer = IndexBuffer::New(largeIndices, indexCount, parameters.storage, 0);
|
||||||
|
|
||||||
IndexMapper indexMapper(indexBuffer, BufferAccess_DiscardAndWrite);
|
IndexMapper indexMapper(indexBuffer, BufferAccess_DiscardAndWrite);
|
||||||
IndexIterator index = indexMapper.begin();
|
IndexIterator index = indexMapper.begin();
|
||||||
|
|
@ -202,7 +202,7 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters)
|
||||||
indexMapper.Unmap();
|
indexMapper.Unmap();
|
||||||
|
|
||||||
// Vertex buffer
|
// Vertex buffer
|
||||||
VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent), vertexCount, parameters.storage);
|
VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent), vertexCount, parameters.storage, 0);
|
||||||
BufferMapper<VertexBuffer> vertexMapper(vertexBuffer, BufferAccess_WriteOnly);
|
BufferMapper<VertexBuffer> vertexMapper(vertexBuffer, BufferAccess_WriteOnly);
|
||||||
|
|
||||||
MeshVertex* vertex = static_cast<MeshVertex*>(vertexMapper.GetPointer());
|
MeshVertex* vertex = static_cast<MeshVertex*>(vertexMapper.GetPointer());
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
Platform | Build Status
|
Platform | Build Status | Nightlies
|
||||||
------------ | -------------
|
------------ | ------------- | -------------
|
||||||
Windows | [](https://ci.appveyor.com/project/DPSLynix/nazaraengine/branch/master)
|
Windows | [](https://ci.appveyor.com/project/DPSLynix/nazaraengine/branch/master) | MSVC14: [x86](https://ci.appveyor.com/api/projects/DPSLynix/NazaraEngine/artifacts/package%2FNazaraEngine.7z?branch=master&job=Environment%3A%20TOOLSET%3Dvs2015%3B%20Configuration%3A%20ReleaseDynamic%3B%20Platform%3A%20Win32) [x86_64](https://ci.appveyor.com/api/projects/DPSLynix/NazaraEngine/artifacts/package%2FNazaraEngine.7z?branch=master&job=Environment%3A%20TOOLSET%3Dvs2015%3B%20Configuration%3A%20ReleaseDynamic%3B%20Platform%3A%20x64)
|
||||||
Linux | [](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine)
|
Linux | [](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine) | No
|
||||||
|
|
||||||
# Nazara Engine
|
# Nazara Engine
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
Platforme | Build Status
|
Platforme | Build Status | Nightlies
|
||||||
------------ | -------------
|
------------ | ------------- | -------------
|
||||||
Windows | [](https://ci.appveyor.com/project/DPSLynix/nazaraengine/branch/master)
|
Windows | [](https://ci.appveyor.com/project/DPSLynix/nazaraengine/branch/master) | MSVC14: [x86](https://ci.appveyor.com/api/projects/DPSLynix/NazaraEngine/artifacts/package%2FNazaraEngine.7z?branch=master&job=Environment%3A%20TOOLSET%3Dvs2015%3B%20Configuration%3A%20ReleaseDynamic%3B%20Platform%3A%20Win32) [x86_64](https://ci.appveyor.com/api/projects/DPSLynix/NazaraEngine/artifacts/package%2FNazaraEngine.7z?branch=master&job=Environment%3A%20TOOLSET%3Dvs2015%3B%20Configuration%3A%20ReleaseDynamic%3B%20Platform%3A%20x64)
|
||||||
Linux | [](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine)
|
Linux | [](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine) | Non
|
||||||
|
|
||||||
# Nazara Engine
|
# Nazara Engine
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue