Compare commits
6 Commits
a0f2b128d7
...
c1f429e916
| Author | SHA1 | Date |
|---|---|---|
|
|
c1f429e916 | |
|
|
4d15cbcc2b | |
|
|
8c3e8956ca | |
|
|
a147ef411a | |
|
|
a0a4f63847 | |
|
|
e9f95d4d0f |
|
|
@ -25,6 +25,9 @@ namespace Nz
|
|||
bool IsValid() const;
|
||||
};
|
||||
|
||||
NAZARA_CORE_API bool Serialize(SerializationContext& context, SoundStreamParams& params, TypeTag<SoundStreamParams>);
|
||||
NAZARA_CORE_API bool Unserialize(SerializationContext& context, SoundStreamParams* params, TypeTag<SoundStreamParams>);
|
||||
|
||||
class Mutex;
|
||||
class SoundStream;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ namespace Nz
|
|||
: public SerializationContext
|
||||
{
|
||||
public:
|
||||
EnumSerializationMode GetEnumSerializationMode() const override { return EnumSerializationMode::Binary; }
|
||||
|
||||
bool PushObject(std::string_view name) override;
|
||||
bool PopObject() override;
|
||||
bool PushArray(std::string_view name) override;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
#pragma once
|
||||
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
#include <Nazara/Core/Export.hpp>
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
template <typename T>
|
||||
concept Enum = std::is_enum_v<T>;
|
||||
|
||||
template <Enum TEnum> TEnum EnumFromString(std::string_view) { return TEnum{}; }
|
||||
|
||||
#define DEF_ENUM(Type) \
|
||||
NAZARA_CORE_API std::string_view EnumToString(Type t); \
|
||||
NAZARA_CORE_API Type EnumFromString_##Type(std::string_view); \
|
||||
template<> inline Type EnumFromString(std::string_view v) { return EnumFromString_##Type(v); }
|
||||
|
||||
DEF_ENUM(AnimationType);
|
||||
DEF_ENUM(BlendEquation);
|
||||
DEF_ENUM(BlendFunc);
|
||||
DEF_ENUM(BufferAccess);
|
||||
DEF_ENUM(BufferType);
|
||||
DEF_ENUM(BufferUsage);
|
||||
DEF_ENUM(ComponentType);
|
||||
DEF_ENUM(CoordSys);
|
||||
DEF_ENUM(CursorPosition);
|
||||
DEF_ENUM(CubemapFace);
|
||||
DEF_ENUM(DataStorage);
|
||||
DEF_ENUM(ErrorMode);
|
||||
DEF_ENUM(ErrorType);
|
||||
DEF_ENUM(FaceFilling);
|
||||
DEF_ENUM(FaceCulling);
|
||||
DEF_ENUM(FrontFace);
|
||||
DEF_ENUM(ImageType);
|
||||
DEF_ENUM(IndexType);
|
||||
DEF_ENUM(HashType);
|
||||
DEF_ENUM(OpenMode);
|
||||
DEF_ENUM(ParameterType);
|
||||
DEF_ENUM(PixelFormatContent);
|
||||
DEF_ENUM(PixelFormat);
|
||||
DEF_ENUM(PixelFormatSubType);
|
||||
DEF_ENUM(PixelFlipping);
|
||||
DEF_ENUM(PrimitiveMode);
|
||||
DEF_ENUM(PrimitiveType);
|
||||
DEF_ENUM(ProcessorCap);
|
||||
DEF_ENUM(ProcessorVendor);
|
||||
DEF_ENUM(RendererComparison);
|
||||
DEF_ENUM(ResourceLoadingError);
|
||||
DEF_ENUM(SamplerFilter);
|
||||
DEF_ENUM(SamplerMipmapMode);
|
||||
DEF_ENUM(SamplerWrap);
|
||||
DEF_ENUM(SphereType);
|
||||
DEF_ENUM(StencilOperation);
|
||||
DEF_ENUM(StreamOption);
|
||||
DEF_ENUM(TextAlign);
|
||||
DEF_ENUM(TextStyle);
|
||||
DEF_ENUM(VertexComponent);
|
||||
DEF_ENUM(VertexInputRate);
|
||||
DEF_ENUM(VertexLayout);
|
||||
|
||||
#undef DEF_ENUM
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
#include <Nazara/Core/ResourceManager.hpp>
|
||||
#include <Nazara/Core/ResourceParameters.hpp>
|
||||
#include <Nazara/Core/ResourceSaver.hpp>
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <NazaraUtils/MovablePtr.hpp>
|
||||
#include <NazaraUtils/Signal.hpp>
|
||||
#include <atomic>
|
||||
|
|
@ -37,6 +38,9 @@ namespace Nz
|
|||
void Merge(const ImageParams& params);
|
||||
};
|
||||
|
||||
NAZARA_CORE_API bool Serialize(SerializationContext& context, ImageParams& params, TypeTag<ImageParams>);
|
||||
NAZARA_CORE_API bool Unserialize(SerializationContext& context, ImageParams* params, TypeTag<ImageParams>);
|
||||
|
||||
class Image;
|
||||
|
||||
using ImageLibrary = ObjectLibrary<Image>;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
namespace Nz
|
||||
{
|
||||
struct SerializationContext;
|
||||
|
||||
struct NAZARA_CORE_API MeshParams : ResourceParameters
|
||||
{
|
||||
// How buffer will be allocated (by default in RAM)
|
||||
|
|
@ -74,6 +76,9 @@ namespace Nz
|
|||
bool IsValid() const;
|
||||
};
|
||||
|
||||
NAZARA_CORE_API bool Serialize(SerializationContext& context, const MeshParams& params, TypeTag<MeshParams>);
|
||||
NAZARA_CORE_API bool Unserialize(SerializationContext& context, MeshParams* params, TypeTag<MeshParams>);
|
||||
|
||||
class Mesh;
|
||||
struct Primitive;
|
||||
class PrimitiveList;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#define NAZARA_CORE_RESOURCEPARAMETERS_HPP
|
||||
|
||||
#include <Nazara/Core/ParameterList.hpp>
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
|
@ -17,6 +18,9 @@ namespace Nz
|
|||
|
||||
ParameterList custom;
|
||||
};
|
||||
|
||||
NAZARA_CORE_API bool Serialize(SerializationContext& context, ResourceParameters& params, TypeTag<ResourceParameters>);
|
||||
NAZARA_CORE_API bool Unserialize(SerializationContext& context, ResourceParameters* params, TypeTag<ResourceParameters>);
|
||||
}
|
||||
|
||||
#endif // NAZARA_CORE_RESOURCEPARAMETERS_HPP
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#define NAZARA_CORE_SERIALIZATION_HPP
|
||||
|
||||
#include <NazaraUtils/Prerequisites.hpp>
|
||||
#include <Nazara/Core/EnumSerialization.hpp>
|
||||
#include <Nazara/Core/Export.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <NazaraUtils/Endianness.hpp>
|
||||
|
|
@ -21,9 +22,17 @@ namespace Nz
|
|||
template <typename T>
|
||||
concept Numeric = std::is_arithmetic<T>::value;
|
||||
|
||||
enum class EnumSerializationMode
|
||||
{
|
||||
Binary,
|
||||
String,
|
||||
};
|
||||
|
||||
struct NAZARA_CORE_API SerializationContext
|
||||
{
|
||||
public:
|
||||
virtual EnumSerializationMode GetEnumSerializationMode() const = 0;
|
||||
|
||||
virtual bool PushObject(std::string_view name) = 0;
|
||||
virtual bool PopObject() = 0;
|
||||
virtual bool PushArray(std::string_view name) = 0;
|
||||
|
|
@ -67,6 +76,7 @@ namespace Nz
|
|||
|
||||
inline bool Serialize(SerializationContext& context, std::string_view name, const bool& value, TypeTag<bool>);
|
||||
inline bool Serialize(SerializationContext& context, std::string_view name, const std::string& value, TypeTag<std::string>);
|
||||
inline bool Serialize(SerializationContext& context, std::string_view name, const std::filesystem::path& value, TypeTag<std::filesystem::path>);
|
||||
|
||||
template<typename T, size_t N>
|
||||
bool Serialize(SerializationContext& context, std::string_view name, const T (&values)[N]);
|
||||
|
|
@ -83,6 +93,12 @@ namespace Nz
|
|||
template<Numeric T>
|
||||
inline bool Serialize(SerializationContext& context, std::string_view name, const T& value, TypeTag<T>);
|
||||
|
||||
template<Enum T>
|
||||
inline bool Serialize(SerializationContext& context, std::string_view name, const T& value, TypeTag<T>);
|
||||
|
||||
template<typename T>
|
||||
inline bool Serialize(SerializationContext& context, std::string_view name, const Flags<T>& flags, TypeTag<Flags<T>>);
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline bool Unserialize(SerializationContext&, T*, TypeTag<T>) { return false; }
|
||||
|
|
@ -93,11 +109,9 @@ namespace Nz
|
|||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, std::string_view name, T* value, TypeTag<T>);
|
||||
|
||||
template <>
|
||||
inline bool Unserialize(SerializationContext& context, std::string_view name, bool* value, TypeTag<bool>);
|
||||
|
||||
template <>
|
||||
inline bool Unserialize(SerializationContext& context, std::string_view name, std::string* value, TypeTag<std::string>);
|
||||
inline bool Unserialize(SerializationContext& context, std::string_view name, std::filesystem::path* value, TypeTag<std::filesystem::path>);
|
||||
|
||||
template<typename T, size_t N>
|
||||
bool Unserialize(SerializationContext& context, std::string_view name, T (*values)[N]);
|
||||
|
|
@ -113,6 +127,12 @@ namespace Nz
|
|||
|
||||
template<Numeric T>
|
||||
inline bool Unserialize(SerializationContext& context, std::string_view name, T* value, TypeTag<T>);
|
||||
|
||||
template<Enum T>
|
||||
bool Unserialize(SerializationContext& context, std::string_view name, T* value, TypeTag<T>);
|
||||
|
||||
template <typename T>
|
||||
inline bool Unserialize(SerializationContext& context, std::string_view name, Flags<T>* flags, TypeTag<Flags<T>>);
|
||||
}
|
||||
|
||||
#include <Nazara/Core/Serialization.inl>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Export.hpp
|
||||
|
||||
#include <Nazara/Core/EnumSerialization.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
|
@ -17,10 +18,10 @@ namespace Nz
|
|||
if (!context.PushObject(name))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, value, TypeTag<std::decay_t<T>>()))
|
||||
return false;
|
||||
bool bRes = Serialize(context, value, TypeTag<std::decay_t<T>>());
|
||||
|
||||
return context.PopObject();
|
||||
context.PopObject();
|
||||
return bRes;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -51,19 +52,27 @@ namespace Nz
|
|||
return context.Write(name, value);
|
||||
}
|
||||
|
||||
inline bool Serialize(SerializationContext& context, std::string_view name, const std::filesystem::path& value, TypeTag<std::filesystem::path>)
|
||||
{
|
||||
std::string str = value.string();
|
||||
return context.Write(name, str);
|
||||
}
|
||||
|
||||
template<typename T, size_t N>
|
||||
bool Serialize(SerializationContext& context, std::string_view name, const T(&values)[N])
|
||||
{
|
||||
if (!context.PushArray(name))
|
||||
return false;
|
||||
|
||||
bool bRes = true;
|
||||
for (size_t i = 0; i < N; ++i)
|
||||
{
|
||||
if (!Serialize(context, "", values[i]))
|
||||
return false;
|
||||
bRes = false;
|
||||
}
|
||||
|
||||
return context.PopArray();
|
||||
context.PopArray();
|
||||
return bRes;
|
||||
}
|
||||
|
||||
template<typename T, size_t N>
|
||||
|
|
@ -72,13 +81,15 @@ namespace Nz
|
|||
if (!context.PushArray(name))
|
||||
return false;
|
||||
|
||||
bool bRes = true;
|
||||
for (auto&& value : values)
|
||||
{
|
||||
if (!Serialize(context, "", value))
|
||||
return false;
|
||||
bRes = false;
|
||||
}
|
||||
|
||||
return context.PopArray();
|
||||
context.PopArray();
|
||||
return bRes;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -87,13 +98,15 @@ namespace Nz
|
|||
if (!context.PushArray(name))
|
||||
return false;
|
||||
|
||||
bool bRes = true;
|
||||
for (auto&& value : values)
|
||||
{
|
||||
if (!Serialize(context, "", value))
|
||||
return false;
|
||||
bRes = false;
|
||||
}
|
||||
|
||||
return context.PopArray();
|
||||
context.PopArray();
|
||||
return bRes;
|
||||
}
|
||||
|
||||
template<typename E, typename T>
|
||||
|
|
@ -102,13 +115,15 @@ namespace Nz
|
|||
if (!context.PushArray(name))
|
||||
return false;
|
||||
|
||||
bool bRes = true;
|
||||
for (auto&& value : values)
|
||||
{
|
||||
if (!Serialize(context, "", value))
|
||||
return false;
|
||||
bRes = false;
|
||||
}
|
||||
|
||||
return context.PopArray();
|
||||
context.PopArray();
|
||||
return bRes;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -127,6 +142,19 @@ namespace Nz
|
|||
return context.Write(name, value);
|
||||
}
|
||||
|
||||
template<Enum T>
|
||||
inline bool Serialize(SerializationContext& context, std::string_view name, const T& value, TypeTag<T>)
|
||||
{
|
||||
switch (context.GetEnumSerializationMode())
|
||||
{
|
||||
case EnumSerializationMode::Binary:
|
||||
return Serialize(context, name, std::underlying_type_t<T>(value), TypeTag<std::decay_t<std::underlying_type_t<T>>>());
|
||||
case EnumSerializationMode::String:
|
||||
return Serialize(context, name, std::string(EnumToString(value)), TypeTag<std::string>());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline bool Unserialize(SerializationContext& context, std::string_view name, T* value)
|
||||
|
|
@ -140,10 +168,10 @@ namespace Nz
|
|||
if (!context.PushObject(name))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, value, TypeTag<T>()))
|
||||
return false;
|
||||
bool bRes = Unserialize(context, value, TypeTag<T>());
|
||||
|
||||
return context.PopObject();
|
||||
context.PopObject();
|
||||
return bRes;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -173,19 +201,31 @@ namespace Nz
|
|||
return context.Read(name, string);
|
||||
}
|
||||
|
||||
inline bool Unserialize(SerializationContext& context, std::string_view name, std::filesystem::path* value, TypeTag<std::filesystem::path>)
|
||||
{
|
||||
std::string str;
|
||||
if (!context.Read(name, &str))
|
||||
return false;
|
||||
|
||||
*value = str;
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T, size_t N>
|
||||
bool Unserialize(SerializationContext& context, std::string_view name, T(*values)[N])
|
||||
{
|
||||
if (!context.PushArray(name))
|
||||
return false;
|
||||
|
||||
bool bRes = true;
|
||||
for (size_t i = 0; i < N; ++i)
|
||||
{
|
||||
if (!Unserialize(context, "", &(*values[i])))
|
||||
return false;
|
||||
bRes = false;
|
||||
}
|
||||
|
||||
return context.PopArray();
|
||||
context.PopArray();
|
||||
return bRes;
|
||||
}
|
||||
|
||||
template<typename T, size_t N>
|
||||
|
|
@ -194,13 +234,15 @@ namespace Nz
|
|||
if (!context.PushArray(name))
|
||||
return false;
|
||||
|
||||
bool bRes = true;
|
||||
for (auto&& value : *values)
|
||||
{
|
||||
if (!Unserialize(context, "", &value))
|
||||
return false;
|
||||
bRes = false;
|
||||
}
|
||||
|
||||
return context.PopArray();
|
||||
context.PopArray();
|
||||
return bRes;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -209,13 +251,15 @@ namespace Nz
|
|||
if (!context.PushArray(name))
|
||||
return false;
|
||||
|
||||
bool bRes = true;
|
||||
for (auto&& value : *values)
|
||||
{
|
||||
if (!Unserialize(context, "", &value))
|
||||
return false;
|
||||
bRes = false;
|
||||
}
|
||||
|
||||
return context.PopArray();
|
||||
context.PopArray();
|
||||
return bRes;
|
||||
}
|
||||
|
||||
template<typename E, typename T>
|
||||
|
|
@ -224,13 +268,15 @@ namespace Nz
|
|||
if (!context.PushArray(name))
|
||||
return false;
|
||||
|
||||
bool bRes = true;
|
||||
for (auto&& value : *values)
|
||||
{
|
||||
if (!Unserialize(context, "", &value))
|
||||
return false;
|
||||
bRes = false;
|
||||
}
|
||||
|
||||
return context.PopArray();
|
||||
context.PopArray();
|
||||
return bRes;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -250,5 +296,47 @@ namespace Nz
|
|||
{
|
||||
return context.Read(name, value);
|
||||
}
|
||||
|
||||
template<Enum T>
|
||||
bool Unserialize(SerializationContext& context, std::string_view name, T* value, TypeTag<T>)
|
||||
{
|
||||
switch (context.GetEnumSerializationMode())
|
||||
{
|
||||
case EnumSerializationMode::Binary:
|
||||
{
|
||||
std::underlying_type_t<T> v = 0;
|
||||
if (!Unserialize(context, name, &v, TypeTag<std::decay_t<std::underlying_type_t<T>>>()))
|
||||
return false;
|
||||
|
||||
*value = static_cast<T>(v);
|
||||
return true;
|
||||
}
|
||||
case EnumSerializationMode::String:
|
||||
{
|
||||
std::string str;
|
||||
if (!Unserialize(context, name, &str, TypeTag<std::string>()))
|
||||
return false;
|
||||
|
||||
*value = EnumFromString<T>(str);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline bool Serialize(SerializationContext& context, std::string_view name, const Flags<T>& flags, TypeTag<Flags<T>>)
|
||||
{
|
||||
return Serialize(context, name, static_cast<typename Flags<T>::BitField>(flags), TypeTag<std::decay_t<typename Flags<T>::BitField>>());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline bool Unserialize(SerializationContext& context, std::string_view name, Flags<T>* flags, TypeTag<Flags<T>>)
|
||||
{
|
||||
typename Flags<T>::BitField v;
|
||||
if (Unserialize(context, name, &v, TypeTag<std::decay_t<typename Flags<T>::BitField>>()))
|
||||
*flags = v;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ namespace Nz
|
|||
VertexDeclaration& operator=(VertexDeclaration&&) = delete;
|
||||
|
||||
static inline const std::shared_ptr<VertexDeclaration>& Get(VertexLayout layout);
|
||||
static inline const VertexLayout Find(const std::shared_ptr<VertexDeclaration>& declaration);
|
||||
static bool IsTypeSupported(ComponentType type);
|
||||
|
||||
struct Component
|
||||
|
|
|
|||
|
|
@ -75,5 +75,15 @@ namespace Nz
|
|||
NazaraAssert(layout <= VertexLayout::Max, "Vertex layout out of enum");
|
||||
return s_declarations[layout];
|
||||
}
|
||||
|
||||
inline const VertexLayout VertexDeclaration::Find(const std::shared_ptr<VertexDeclaration>& declaration)
|
||||
{
|
||||
for (size_t i = 0; i < (size_t)VertexLayout::Max; ++i)
|
||||
if (s_declarations[(VertexLayout)i].get() == declaration.get())
|
||||
return (VertexLayout)i;
|
||||
|
||||
NazaraAssert(declaration, "Invalid declaration");
|
||||
return VertexLayout::Max;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -294,13 +294,13 @@ namespace Nz
|
|||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const EulerAngles<T>& angles, TypeTag<EulerAngles<T>>)
|
||||
{
|
||||
if (!Serialize(context, "pitch", angles.pitch))
|
||||
if (!Serialize(context, "pitch", angles.pitch.value))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, "yaw", angles.yaw))
|
||||
if (!Serialize(context, "yaw", angles.yaw.value))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, "roll", angles.roll))
|
||||
if (!Serialize(context, "roll", angles.roll.value))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
@ -316,13 +316,13 @@ namespace Nz
|
|||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, EulerAngles<T>* angles, TypeTag<EulerAngles<T>>)
|
||||
{
|
||||
if (!Unserialize(context, "pitch", &angles->pitch))
|
||||
if (!Unserialize(context, "pitch", &angles->pitch.value))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, "yaw", &angles->yaw))
|
||||
if (!Unserialize(context, "yaw", &angles->yaw.value))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, "roll", &angles->roll))
|
||||
if (!Unserialize(context, "roll", &angles->roll.value))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/ResourceManager.hpp>
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/Export.hpp>
|
||||
|
|
@ -53,6 +54,9 @@ namespace Nz
|
|||
void Merge(const TextureParams& params);
|
||||
};
|
||||
|
||||
NAZARA_RENDERER_API bool Serialize(SerializationContext& context, TextureParams& params, TypeTag<TextureParams>);
|
||||
NAZARA_RENDERER_API bool Unserialize(SerializationContext& context, TextureParams* params, TypeTag<TextureParams>);
|
||||
|
||||
class Texture;
|
||||
|
||||
using TextureLibrary = ObjectLibrary<Texture>;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,20 @@
|
|||
|
||||
namespace Nz
|
||||
{
|
||||
bool Serialize(SerializationContext& context, SoundStreamParams& params, TypeTag<SoundStreamParams>)
|
||||
{
|
||||
Serialize(context, params, TypeTag<ResourceParameters>());
|
||||
Serialize(context, "forceMono", params.forceMono);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Unserialize(SerializationContext& context, SoundStreamParams* params, TypeTag<SoundStreamParams>)
|
||||
{
|
||||
Unserialize(context, params, TypeTag<ResourceParameters>());
|
||||
Unserialize(context, "forceMono", ¶ms->forceMono);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SoundStreamParams::IsValid() const
|
||||
{
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,501 @@
|
|||
#include <Nazara/Core/EnumSerialization.hpp>
|
||||
|
||||
#include <unordered_map>
|
||||
#include <string_view>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
template<Enum TEnum>
|
||||
inline TEnum Find(const std::unordered_map<TEnum, std::string_view>& m, std::string_view v)
|
||||
{
|
||||
auto it = std::find_if(m.begin(), m.end(), [v](const auto& kp) { return kp.second == v; });
|
||||
return it != m.end() ? it->first : TEnum{};
|
||||
}
|
||||
|
||||
#define DEF_ENUM(Type) \
|
||||
namespace Type ## _Generated { \
|
||||
std::unordered_map<Type, std::string_view> ValuesToString = {
|
||||
|
||||
#define DEF_ENUM_VALUE(Type, Value) \
|
||||
{ Type::Value, #Value },
|
||||
|
||||
#define DEF_ENUM_END(Type) \
|
||||
}; \
|
||||
} \
|
||||
std::string_view EnumToString(Type v) { return Type ## _Generated::ValuesToString[v]; }; \
|
||||
Type EnumFromString_##Type(std::string_view v) { return Find(Type ## _Generated::ValuesToString, v);}
|
||||
|
||||
|
||||
DEF_ENUM(AnimationType)
|
||||
DEF_ENUM_VALUE(AnimationType, Skeletal)
|
||||
DEF_ENUM_VALUE(AnimationType, Static)
|
||||
DEF_ENUM_END(AnimationType)
|
||||
|
||||
DEF_ENUM(BlendEquation)
|
||||
DEF_ENUM_VALUE(BlendEquation, Add)
|
||||
DEF_ENUM_VALUE(BlendEquation, Max)
|
||||
DEF_ENUM_VALUE(BlendEquation, Min)
|
||||
DEF_ENUM_VALUE(BlendEquation, ReverseSubtract)
|
||||
DEF_ENUM_VALUE(BlendEquation, Subtract)
|
||||
DEF_ENUM_END(BlendEquation)
|
||||
|
||||
DEF_ENUM(BlendFunc)
|
||||
DEF_ENUM_VALUE(BlendFunc, ConstantColor)
|
||||
DEF_ENUM_VALUE(BlendFunc, ConstantAlpha)
|
||||
DEF_ENUM_VALUE(BlendFunc, DstAlpha)
|
||||
DEF_ENUM_VALUE(BlendFunc, DstColor)
|
||||
DEF_ENUM_VALUE(BlendFunc, SrcAlpha)
|
||||
DEF_ENUM_VALUE(BlendFunc, SrcColor)
|
||||
DEF_ENUM_VALUE(BlendFunc, InvConstantColor)
|
||||
DEF_ENUM_VALUE(BlendFunc, InvConstantAlpha)
|
||||
DEF_ENUM_VALUE(BlendFunc, InvDstAlpha)
|
||||
DEF_ENUM_VALUE(BlendFunc, InvDstColor)
|
||||
DEF_ENUM_VALUE(BlendFunc, InvSrcAlpha)
|
||||
DEF_ENUM_VALUE(BlendFunc, InvSrcColor)
|
||||
DEF_ENUM_VALUE(BlendFunc, One)
|
||||
DEF_ENUM_VALUE(BlendFunc, Zero)
|
||||
DEF_ENUM_END(BlendFunc)
|
||||
|
||||
DEF_ENUM(BufferAccess)
|
||||
DEF_ENUM_VALUE(BufferAccess, DiscardAndWrite)
|
||||
DEF_ENUM_VALUE(BufferAccess, ReadOnly)
|
||||
DEF_ENUM_VALUE(BufferAccess, ReadWrite)
|
||||
DEF_ENUM_VALUE(BufferAccess, WriteOnly)
|
||||
DEF_ENUM_VALUE(BufferAccess, Max)
|
||||
DEF_ENUM_END(BufferAccess)
|
||||
|
||||
DEF_ENUM(BufferType)
|
||||
DEF_ENUM_VALUE(BufferType, Index)
|
||||
DEF_ENUM_VALUE(BufferType, Vertex)
|
||||
DEF_ENUM_VALUE(BufferType, Storage)
|
||||
DEF_ENUM_VALUE(BufferType, Uniform)
|
||||
DEF_ENUM_VALUE(BufferType, Upload)
|
||||
DEF_ENUM_VALUE(BufferType, Max)
|
||||
DEF_ENUM_END(BufferType)
|
||||
|
||||
DEF_ENUM(BufferUsage)
|
||||
DEF_ENUM_VALUE(BufferUsage, DeviceLocal)
|
||||
DEF_ENUM_VALUE(BufferUsage, DirectMapping)
|
||||
DEF_ENUM_VALUE(BufferUsage, Dynamic)
|
||||
DEF_ENUM_VALUE(BufferUsage, Read)
|
||||
DEF_ENUM_VALUE(BufferUsage, PersistentMapping)
|
||||
DEF_ENUM_VALUE(BufferUsage, Write)
|
||||
DEF_ENUM_VALUE(BufferUsage, Max)
|
||||
DEF_ENUM_END(BufferUsage)
|
||||
|
||||
DEF_ENUM(ComponentType)
|
||||
DEF_ENUM_VALUE(ComponentType, Color)
|
||||
DEF_ENUM_VALUE(ComponentType, Double1)
|
||||
DEF_ENUM_VALUE(ComponentType, Double2)
|
||||
DEF_ENUM_VALUE(ComponentType, Double3)
|
||||
DEF_ENUM_VALUE(ComponentType, Double4)
|
||||
DEF_ENUM_VALUE(ComponentType, Float1)
|
||||
DEF_ENUM_VALUE(ComponentType, Float2)
|
||||
DEF_ENUM_VALUE(ComponentType, Float3)
|
||||
DEF_ENUM_VALUE(ComponentType, Float4)
|
||||
DEF_ENUM_VALUE(ComponentType, Int1)
|
||||
DEF_ENUM_VALUE(ComponentType, Int2)
|
||||
DEF_ENUM_VALUE(ComponentType, Int3)
|
||||
DEF_ENUM_VALUE(ComponentType, Int4)
|
||||
DEF_ENUM_VALUE(ComponentType, Max)
|
||||
DEF_ENUM_END(ComponentType)
|
||||
|
||||
DEF_ENUM(CoordSys)
|
||||
DEF_ENUM_VALUE(CoordSys, Global)
|
||||
DEF_ENUM_VALUE(CoordSys, Local)
|
||||
DEF_ENUM_VALUE(CoordSys, Max)
|
||||
DEF_ENUM_END(CoordSys)
|
||||
|
||||
DEF_ENUM(CursorPosition)
|
||||
DEF_ENUM_VALUE(CursorPosition, AtBegin)
|
||||
DEF_ENUM_VALUE(CursorPosition, AtCurrent)
|
||||
DEF_ENUM_VALUE(CursorPosition, AtEnd)
|
||||
DEF_ENUM_VALUE(CursorPosition, Max)
|
||||
DEF_ENUM_END(CursorPosition)
|
||||
|
||||
DEF_ENUM(CubemapFace)
|
||||
DEF_ENUM_VALUE(CubemapFace, PositiveX)
|
||||
DEF_ENUM_VALUE(CubemapFace, PositiveY)
|
||||
DEF_ENUM_VALUE(CubemapFace, PositiveZ)
|
||||
DEF_ENUM_VALUE(CubemapFace, NegativeX)
|
||||
DEF_ENUM_VALUE(CubemapFace, NegativeY)
|
||||
DEF_ENUM_VALUE(CubemapFace, NegativeZ)
|
||||
DEF_ENUM_VALUE(CubemapFace, Max)
|
||||
DEF_ENUM_END(CubemapFace)
|
||||
|
||||
DEF_ENUM(DataStorage)
|
||||
DEF_ENUM_VALUE(DataStorage, Hardware)
|
||||
DEF_ENUM_VALUE(DataStorage, Software)
|
||||
DEF_ENUM_VALUE(DataStorage, Max)
|
||||
DEF_ENUM_END(DataStorage)
|
||||
|
||||
DEF_ENUM(ErrorMode)
|
||||
DEF_ENUM_VALUE(ErrorMode, Silent)
|
||||
DEF_ENUM_VALUE(ErrorMode, ThrowException)
|
||||
DEF_ENUM_VALUE(ErrorMode, Max)
|
||||
DEF_ENUM_END(ErrorMode)
|
||||
|
||||
DEF_ENUM(ErrorType)
|
||||
DEF_ENUM_VALUE(ErrorType, AssertFailed)
|
||||
DEF_ENUM_VALUE(ErrorType, Internal)
|
||||
DEF_ENUM_VALUE(ErrorType, Normal)
|
||||
DEF_ENUM_VALUE(ErrorType, Warning)
|
||||
DEF_ENUM_VALUE(ErrorType, Max)
|
||||
DEF_ENUM_END(ErrorType)
|
||||
|
||||
DEF_ENUM(FaceFilling)
|
||||
DEF_ENUM_VALUE(FaceFilling, Fill)
|
||||
DEF_ENUM_VALUE(FaceFilling, Line)
|
||||
DEF_ENUM_VALUE(FaceFilling, Point)
|
||||
DEF_ENUM_VALUE(FaceFilling, Max)
|
||||
DEF_ENUM_END(FaceFilling)
|
||||
|
||||
DEF_ENUM(FaceCulling)
|
||||
DEF_ENUM_VALUE(FaceCulling, None)
|
||||
DEF_ENUM_VALUE(FaceCulling, Back)
|
||||
DEF_ENUM_VALUE(FaceCulling, Front)
|
||||
DEF_ENUM_VALUE(FaceCulling, FrontAndBack)
|
||||
DEF_ENUM_VALUE(FaceCulling, Max)
|
||||
DEF_ENUM_END(FaceCulling)
|
||||
|
||||
DEF_ENUM(FrontFace)
|
||||
DEF_ENUM_VALUE(FrontFace, Clockwise)
|
||||
DEF_ENUM_VALUE(FrontFace, CounterClockwise)
|
||||
DEF_ENUM_VALUE(FrontFace, Max)
|
||||
DEF_ENUM_END(FrontFace)
|
||||
|
||||
DEF_ENUM(ImageType)
|
||||
DEF_ENUM_VALUE(ImageType, E1D)
|
||||
DEF_ENUM_VALUE(ImageType, E1D_Array)
|
||||
DEF_ENUM_VALUE(ImageType, E2D)
|
||||
DEF_ENUM_VALUE(ImageType, E2D_Array)
|
||||
DEF_ENUM_VALUE(ImageType, E3D)
|
||||
DEF_ENUM_VALUE(ImageType, Cubemap)
|
||||
DEF_ENUM_VALUE(ImageType, Max)
|
||||
DEF_ENUM_END(ImageType)
|
||||
|
||||
DEF_ENUM(IndexType)
|
||||
DEF_ENUM_VALUE(IndexType, U8)
|
||||
DEF_ENUM_VALUE(IndexType, U16)
|
||||
DEF_ENUM_VALUE(IndexType, U32)
|
||||
DEF_ENUM_VALUE(IndexType, Max)
|
||||
DEF_ENUM_END(IndexType)
|
||||
|
||||
DEF_ENUM(HashType)
|
||||
DEF_ENUM_VALUE(HashType, CRC32)
|
||||
DEF_ENUM_VALUE(HashType, CRC64)
|
||||
DEF_ENUM_VALUE(HashType, Fletcher16)
|
||||
DEF_ENUM_VALUE(HashType, MD5)
|
||||
DEF_ENUM_VALUE(HashType, SHA1)
|
||||
DEF_ENUM_VALUE(HashType, SHA224)
|
||||
DEF_ENUM_VALUE(HashType, SHA256)
|
||||
DEF_ENUM_VALUE(HashType, SHA384)
|
||||
DEF_ENUM_VALUE(HashType, SHA512)
|
||||
DEF_ENUM_VALUE(HashType, Whirlpool)
|
||||
DEF_ENUM_VALUE(HashType, Max)
|
||||
DEF_ENUM_END(HashType)
|
||||
|
||||
DEF_ENUM(OpenMode)
|
||||
DEF_ENUM_VALUE(OpenMode, NotOpen)
|
||||
DEF_ENUM_VALUE(OpenMode, Append)
|
||||
DEF_ENUM_VALUE(OpenMode, Defer)
|
||||
DEF_ENUM_VALUE(OpenMode, Lock)
|
||||
DEF_ENUM_VALUE(OpenMode, MustExist)
|
||||
DEF_ENUM_VALUE(OpenMode, Read)
|
||||
DEF_ENUM_VALUE(OpenMode, Text)
|
||||
DEF_ENUM_VALUE(OpenMode, Truncate)
|
||||
DEF_ENUM_VALUE(OpenMode, Unbuffered)
|
||||
DEF_ENUM_VALUE(OpenMode, Write)
|
||||
DEF_ENUM_VALUE(OpenMode, Max)
|
||||
DEF_ENUM_END(OpenMode)
|
||||
|
||||
DEF_ENUM(ParameterType)
|
||||
DEF_ENUM_VALUE(ParameterType, Boolean)
|
||||
DEF_ENUM_VALUE(ParameterType, Color)
|
||||
DEF_ENUM_VALUE(ParameterType, Double)
|
||||
DEF_ENUM_VALUE(ParameterType, Integer)
|
||||
DEF_ENUM_VALUE(ParameterType, None)
|
||||
DEF_ENUM_VALUE(ParameterType, Pointer)
|
||||
DEF_ENUM_VALUE(ParameterType, String)
|
||||
DEF_ENUM_VALUE(ParameterType, Userdata)
|
||||
DEF_ENUM_VALUE(ParameterType, Max)
|
||||
DEF_ENUM_END(ParameterType)
|
||||
|
||||
DEF_ENUM(PixelFormatContent)
|
||||
DEF_ENUM_VALUE(PixelFormatContent, Undefined)
|
||||
DEF_ENUM_VALUE(PixelFormatContent, ColorRGBA)
|
||||
DEF_ENUM_VALUE(PixelFormatContent, Depth)
|
||||
DEF_ENUM_VALUE(PixelFormatContent, DepthStencil)
|
||||
DEF_ENUM_VALUE(PixelFormatContent, Stencil)
|
||||
DEF_ENUM_VALUE(PixelFormatContent, Max)
|
||||
DEF_ENUM_END(PixelFormatContent)
|
||||
|
||||
DEF_ENUM(PixelFormat)
|
||||
DEF_ENUM_VALUE(PixelFormat, Undefined)
|
||||
DEF_ENUM_VALUE(PixelFormat, A8)
|
||||
DEF_ENUM_VALUE(PixelFormat, BGR8)
|
||||
DEF_ENUM_VALUE(PixelFormat, BGR8_SRGB)
|
||||
DEF_ENUM_VALUE(PixelFormat, BGRA8)
|
||||
DEF_ENUM_VALUE(PixelFormat, BGRA8_SRGB)
|
||||
DEF_ENUM_VALUE(PixelFormat, DXT1)
|
||||
DEF_ENUM_VALUE(PixelFormat, DXT3)
|
||||
DEF_ENUM_VALUE(PixelFormat, DXT5)
|
||||
DEF_ENUM_VALUE(PixelFormat, L8)
|
||||
DEF_ENUM_VALUE(PixelFormat, LA8)
|
||||
DEF_ENUM_VALUE(PixelFormat, R8)
|
||||
DEF_ENUM_VALUE(PixelFormat, R8I)
|
||||
DEF_ENUM_VALUE(PixelFormat, R8UI)
|
||||
DEF_ENUM_VALUE(PixelFormat, R16)
|
||||
DEF_ENUM_VALUE(PixelFormat, R16F)
|
||||
DEF_ENUM_VALUE(PixelFormat, R16I)
|
||||
DEF_ENUM_VALUE(PixelFormat, R16UI)
|
||||
DEF_ENUM_VALUE(PixelFormat, R32F)
|
||||
DEF_ENUM_VALUE(PixelFormat, R32I)
|
||||
DEF_ENUM_VALUE(PixelFormat, R32UI)
|
||||
DEF_ENUM_VALUE(PixelFormat, RG8)
|
||||
DEF_ENUM_VALUE(PixelFormat, RG8I)
|
||||
DEF_ENUM_VALUE(PixelFormat, RG8UI)
|
||||
DEF_ENUM_VALUE(PixelFormat, RG16)
|
||||
DEF_ENUM_VALUE(PixelFormat, RG16F)
|
||||
DEF_ENUM_VALUE(PixelFormat, RG16I)
|
||||
DEF_ENUM_VALUE(PixelFormat, RG16UI)
|
||||
DEF_ENUM_VALUE(PixelFormat, RG32F)
|
||||
DEF_ENUM_VALUE(PixelFormat, RG32I)
|
||||
DEF_ENUM_VALUE(PixelFormat, RG32UI)
|
||||
DEF_ENUM_VALUE(PixelFormat, RGB5A1)
|
||||
DEF_ENUM_VALUE(PixelFormat, RGB8)
|
||||
DEF_ENUM_VALUE(PixelFormat, RGB8_SRGB)
|
||||
DEF_ENUM_VALUE(PixelFormat, RGB16F)
|
||||
DEF_ENUM_VALUE(PixelFormat, RGB16I)
|
||||
DEF_ENUM_VALUE(PixelFormat, RGB16UI)
|
||||
DEF_ENUM_VALUE(PixelFormat, RGB32F)
|
||||
DEF_ENUM_VALUE(PixelFormat, RGB32I)
|
||||
DEF_ENUM_VALUE(PixelFormat, RGB32UI)
|
||||
DEF_ENUM_VALUE(PixelFormat, RGBA4)
|
||||
DEF_ENUM_VALUE(PixelFormat, RGBA8)
|
||||
DEF_ENUM_VALUE(PixelFormat, RGBA8_SRGB)
|
||||
DEF_ENUM_VALUE(PixelFormat, RGBA16F)
|
||||
DEF_ENUM_VALUE(PixelFormat, RGBA16I)
|
||||
DEF_ENUM_VALUE(PixelFormat, RGBA16UI)
|
||||
DEF_ENUM_VALUE(PixelFormat, RGBA32F)
|
||||
DEF_ENUM_VALUE(PixelFormat, RGBA32I)
|
||||
DEF_ENUM_VALUE(PixelFormat, RGBA32UI)
|
||||
DEF_ENUM_VALUE(PixelFormat, Depth16)
|
||||
DEF_ENUM_VALUE(PixelFormat, Depth16Stencil8)
|
||||
DEF_ENUM_VALUE(PixelFormat, Depth24)
|
||||
DEF_ENUM_VALUE(PixelFormat, Depth24Stencil8)
|
||||
DEF_ENUM_VALUE(PixelFormat, Depth32F)
|
||||
DEF_ENUM_VALUE(PixelFormat, Depth32FStencil8)
|
||||
DEF_ENUM_VALUE(PixelFormat, Stencil1)
|
||||
DEF_ENUM_VALUE(PixelFormat, Stencil4)
|
||||
DEF_ENUM_VALUE(PixelFormat, Stencil8)
|
||||
DEF_ENUM_VALUE(PixelFormat, Stencil16)
|
||||
DEF_ENUM_VALUE(PixelFormat, Max)
|
||||
DEF_ENUM_END(PixelFormat)
|
||||
|
||||
|
||||
DEF_ENUM(PixelFormatSubType)
|
||||
DEF_ENUM_VALUE(PixelFormatSubType, Compressed)
|
||||
DEF_ENUM_VALUE(PixelFormatSubType, Double)
|
||||
DEF_ENUM_VALUE(PixelFormatSubType, Float)
|
||||
DEF_ENUM_VALUE(PixelFormatSubType, Half)
|
||||
DEF_ENUM_VALUE(PixelFormatSubType, Int)
|
||||
DEF_ENUM_VALUE(PixelFormatSubType, Unsigned)
|
||||
DEF_ENUM_VALUE(PixelFormatSubType, Max)
|
||||
DEF_ENUM_END(PixelFormatSubType)
|
||||
|
||||
DEF_ENUM(PixelFlipping)
|
||||
DEF_ENUM_VALUE(PixelFlipping, Horizontally)
|
||||
DEF_ENUM_VALUE(PixelFlipping, Vertically)
|
||||
DEF_ENUM_VALUE(PixelFlipping, Max)
|
||||
DEF_ENUM_END(PixelFlipping)
|
||||
|
||||
DEF_ENUM(PrimitiveMode)
|
||||
DEF_ENUM_VALUE(PrimitiveMode, LineList)
|
||||
DEF_ENUM_VALUE(PrimitiveMode, LineStrip)
|
||||
DEF_ENUM_VALUE(PrimitiveMode, PointList)
|
||||
DEF_ENUM_VALUE(PrimitiveMode, TriangleList)
|
||||
DEF_ENUM_VALUE(PrimitiveMode, TriangleStrip)
|
||||
DEF_ENUM_VALUE(PrimitiveMode, TriangleFan)
|
||||
DEF_ENUM_VALUE(PrimitiveMode, Max)
|
||||
DEF_ENUM_END(PrimitiveMode)
|
||||
|
||||
DEF_ENUM(PrimitiveType)
|
||||
DEF_ENUM_VALUE(PrimitiveType, Box)
|
||||
DEF_ENUM_VALUE(PrimitiveType, Cone)
|
||||
DEF_ENUM_VALUE(PrimitiveType, Plane)
|
||||
DEF_ENUM_VALUE(PrimitiveType, Sphere)
|
||||
DEF_ENUM_VALUE(PrimitiveType, Max)
|
||||
DEF_ENUM_END(PrimitiveType)
|
||||
|
||||
DEF_ENUM(ProcessorCap)
|
||||
DEF_ENUM_VALUE(ProcessorCap, x64)
|
||||
DEF_ENUM_VALUE(ProcessorCap, AES)
|
||||
DEF_ENUM_VALUE(ProcessorCap, AVX)
|
||||
DEF_ENUM_VALUE(ProcessorCap, FMA3)
|
||||
DEF_ENUM_VALUE(ProcessorCap, FMA4)
|
||||
DEF_ENUM_VALUE(ProcessorCap, MMX)
|
||||
DEF_ENUM_VALUE(ProcessorCap, Popcnt)
|
||||
DEF_ENUM_VALUE(ProcessorCap, RDRAND)
|
||||
DEF_ENUM_VALUE(ProcessorCap, XOP)
|
||||
DEF_ENUM_VALUE(ProcessorCap, SSE)
|
||||
DEF_ENUM_VALUE(ProcessorCap, SSE2)
|
||||
DEF_ENUM_VALUE(ProcessorCap, SSE3)
|
||||
DEF_ENUM_VALUE(ProcessorCap, SSSE3)
|
||||
DEF_ENUM_VALUE(ProcessorCap, SSE41)
|
||||
DEF_ENUM_VALUE(ProcessorCap, SSE42)
|
||||
DEF_ENUM_VALUE(ProcessorCap, SSE4a)
|
||||
DEF_ENUM_VALUE(ProcessorCap, Max)
|
||||
DEF_ENUM_END(ProcessorCap)
|
||||
|
||||
DEF_ENUM(ProcessorVendor)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, Unknown)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, ACRN)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, AMD)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, Ao486)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, AppleRosetta2)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, Bhyve)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, Centaur)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, Cyrix)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, Elbrus)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, Hygon)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, HyperV)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, Intel)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, KVM)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, MicrosoftXTA)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, NSC)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, NexGen)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, Parallels)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, QEMU)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, QNX)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, Rise)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, SIS)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, Transmeta)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, UMC)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, VIA)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, VMware)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, Vortex)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, XenHVM)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, Zhaoxin)
|
||||
DEF_ENUM_VALUE(ProcessorVendor, Max)
|
||||
DEF_ENUM_END(ProcessorVendor)
|
||||
|
||||
DEF_ENUM(RendererComparison)
|
||||
DEF_ENUM_VALUE(RendererComparison, Always)
|
||||
DEF_ENUM_VALUE(RendererComparison, Equal)
|
||||
DEF_ENUM_VALUE(RendererComparison, Greater)
|
||||
DEF_ENUM_VALUE(RendererComparison, GreaterOrEqual)
|
||||
DEF_ENUM_VALUE(RendererComparison, Less)
|
||||
DEF_ENUM_VALUE(RendererComparison, LessOrEqual)
|
||||
DEF_ENUM_VALUE(RendererComparison, Never)
|
||||
DEF_ENUM_VALUE(RendererComparison, NotEqual)
|
||||
DEF_ENUM_VALUE(RendererComparison, Max)
|
||||
DEF_ENUM_END(RendererComparison)
|
||||
|
||||
DEF_ENUM(ResourceLoadingError)
|
||||
DEF_ENUM_VALUE(ResourceLoadingError, DecodingError)
|
||||
DEF_ENUM_VALUE(ResourceLoadingError, FailedToOpenFile)
|
||||
DEF_ENUM_VALUE(ResourceLoadingError, Internal)
|
||||
DEF_ENUM_VALUE(ResourceLoadingError, Unsupported)
|
||||
DEF_ENUM_VALUE(ResourceLoadingError, Unrecognized)
|
||||
DEF_ENUM_END(ResourceLoadingError)
|
||||
|
||||
DEF_ENUM(SamplerFilter)
|
||||
DEF_ENUM_VALUE(SamplerFilter, Linear)
|
||||
DEF_ENUM_VALUE(SamplerFilter, Nearest)
|
||||
DEF_ENUM_VALUE(SamplerFilter, Max)
|
||||
DEF_ENUM_END(SamplerFilter)
|
||||
|
||||
DEF_ENUM(SamplerMipmapMode)
|
||||
DEF_ENUM_VALUE(SamplerMipmapMode, Linear)
|
||||
DEF_ENUM_VALUE(SamplerMipmapMode, Nearest)
|
||||
DEF_ENUM_VALUE(SamplerMipmapMode, Max)
|
||||
DEF_ENUM_END(SamplerMipmapMode)
|
||||
|
||||
DEF_ENUM(SamplerWrap)
|
||||
DEF_ENUM_VALUE(SamplerWrap, Clamp)
|
||||
DEF_ENUM_VALUE(SamplerWrap, MirroredRepeat)
|
||||
DEF_ENUM_VALUE(SamplerWrap, Repeat)
|
||||
DEF_ENUM_VALUE(SamplerWrap, Max)
|
||||
DEF_ENUM_END(SamplerWrap)
|
||||
|
||||
DEF_ENUM(SphereType)
|
||||
DEF_ENUM_VALUE(SphereType, Cubic)
|
||||
DEF_ENUM_VALUE(SphereType, Ico)
|
||||
DEF_ENUM_VALUE(SphereType, UV)
|
||||
DEF_ENUM_VALUE(SphereType, Max)
|
||||
DEF_ENUM_END(SphereType)
|
||||
|
||||
DEF_ENUM(StencilOperation)
|
||||
DEF_ENUM_VALUE(StencilOperation, Decrement)
|
||||
DEF_ENUM_VALUE(StencilOperation, DecrementNoClamp)
|
||||
DEF_ENUM_VALUE(StencilOperation, Increment)
|
||||
DEF_ENUM_VALUE(StencilOperation, IncrementNoClamp)
|
||||
DEF_ENUM_VALUE(StencilOperation, Invert)
|
||||
DEF_ENUM_VALUE(StencilOperation, Keep)
|
||||
DEF_ENUM_VALUE(StencilOperation, Replace)
|
||||
DEF_ENUM_VALUE(StencilOperation, Zero)
|
||||
DEF_ENUM_VALUE(StencilOperation, Max)
|
||||
DEF_ENUM_END(StencilOperation)
|
||||
|
||||
DEF_ENUM(StreamOption)
|
||||
DEF_ENUM_VALUE(StreamOption, None)
|
||||
DEF_ENUM_VALUE(StreamOption, MemoryMapped)
|
||||
DEF_ENUM_VALUE(StreamOption, Sequential)
|
||||
DEF_ENUM_VALUE(StreamOption, Text)
|
||||
DEF_ENUM_VALUE(StreamOption, Unbuffered)
|
||||
DEF_ENUM_VALUE(StreamOption, Max)
|
||||
DEF_ENUM_END(StreamOption)
|
||||
|
||||
DEF_ENUM(TextAlign)
|
||||
DEF_ENUM_VALUE(TextAlign, Left)
|
||||
DEF_ENUM_VALUE(TextAlign, Middle)
|
||||
DEF_ENUM_VALUE(TextAlign, Right)
|
||||
DEF_ENUM_VALUE(TextAlign, Max)
|
||||
DEF_ENUM_END(TextAlign)
|
||||
|
||||
DEF_ENUM(TextStyle)
|
||||
DEF_ENUM_VALUE(TextStyle, Bold)
|
||||
DEF_ENUM_VALUE(TextStyle, Italic)
|
||||
DEF_ENUM_VALUE(TextStyle, StrikeThrough)
|
||||
DEF_ENUM_VALUE(TextStyle, Underlined)
|
||||
DEF_ENUM_VALUE(TextStyle, Max)
|
||||
DEF_ENUM_END(TextStyle)
|
||||
|
||||
DEF_ENUM(VertexComponent)
|
||||
DEF_ENUM_VALUE(VertexComponent, Unused)
|
||||
DEF_ENUM_VALUE(VertexComponent, Color)
|
||||
DEF_ENUM_VALUE(VertexComponent, JointIndices)
|
||||
DEF_ENUM_VALUE(VertexComponent, JointWeights)
|
||||
DEF_ENUM_VALUE(VertexComponent, Normal)
|
||||
DEF_ENUM_VALUE(VertexComponent, Position)
|
||||
DEF_ENUM_VALUE(VertexComponent, SizeSinCos)
|
||||
DEF_ENUM_VALUE(VertexComponent, Tangent)
|
||||
DEF_ENUM_VALUE(VertexComponent, TexCoord)
|
||||
DEF_ENUM_VALUE(VertexComponent, Userdata)
|
||||
DEF_ENUM_VALUE(VertexComponent, Max)
|
||||
DEF_ENUM_END(VertexComponent)
|
||||
|
||||
DEF_ENUM(VertexInputRate)
|
||||
DEF_ENUM_VALUE(VertexInputRate, Instance)
|
||||
DEF_ENUM_VALUE(VertexInputRate, Vertex)
|
||||
DEF_ENUM_END(VertexInputRate)
|
||||
|
||||
DEF_ENUM(VertexLayout)
|
||||
DEF_ENUM_VALUE(VertexLayout, UV_SizeSinCos)
|
||||
DEF_ENUM_VALUE(VertexLayout, XY)
|
||||
DEF_ENUM_VALUE(VertexLayout, XY_Color)
|
||||
DEF_ENUM_VALUE(VertexLayout, XY_UV)
|
||||
DEF_ENUM_VALUE(VertexLayout, XYZ)
|
||||
DEF_ENUM_VALUE(VertexLayout, XYZ_Color)
|
||||
DEF_ENUM_VALUE(VertexLayout, XYZ_Color_UV)
|
||||
DEF_ENUM_VALUE(VertexLayout, XYZ_Normal)
|
||||
DEF_ENUM_VALUE(VertexLayout, XYZ_Normal_UV)
|
||||
DEF_ENUM_VALUE(VertexLayout, XYZ_Normal_UV_Tangent)
|
||||
DEF_ENUM_VALUE(VertexLayout, XYZ_Normal_UV_Tangent_Skinning)
|
||||
DEF_ENUM_VALUE(VertexLayout, UV_SizeSinCos_Color)
|
||||
DEF_ENUM_VALUE(VertexLayout, XYZ_UV)
|
||||
DEF_ENUM_VALUE(VertexLayout, Matrix4)
|
||||
DEF_ENUM_VALUE(VertexLayout, Max)
|
||||
DEF_ENUM_END(VertexLayout)
|
||||
}
|
||||
|
|
@ -45,6 +45,22 @@ namespace Nz
|
|||
loadFormat = params.loadFormat;
|
||||
}
|
||||
|
||||
bool Serialize(SerializationContext& context, ImageParams& params, TypeTag<ImageParams>)
|
||||
{
|
||||
Serialize(context, params, TypeTag<ResourceParameters>());
|
||||
|
||||
Serialize(context, "loadFormat", params.loadFormat);
|
||||
Serialize(context, "levelCount", params.levelCount);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Unserialize(SerializationContext& context, ImageParams* params, TypeTag<ImageParams>)
|
||||
{
|
||||
Unserialize(context, params, TypeTag<ResourceParameters>());
|
||||
Unserialize(context, "loadFormat", ¶ms->loadFormat);
|
||||
Unserialize(context, "levelCount", ¶ms->levelCount);
|
||||
return true;
|
||||
}
|
||||
|
||||
Image::Image() :
|
||||
m_sharedImage(&emptyImage)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
#include <Nazara/Core/StringExt.hpp>
|
||||
#include <Nazara/Core/SubMesh.hpp>
|
||||
#include <Nazara/Core/VertexMapper.hpp>
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
|
@ -39,6 +40,50 @@ namespace Nz
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Serialize(SerializationContext& context, const MeshParams& params, TypeTag<MeshParams>)
|
||||
{
|
||||
Serialize(context, "indexBufferFlags", params.indexBufferFlags);
|
||||
Serialize(context, "vertexBufferFlags", params.vertexBufferFlags);
|
||||
Serialize(context, "vertexOffset", params.vertexOffset);
|
||||
|
||||
Nz::EulerAnglesf rot = params.vertexRotation;
|
||||
Serialize(context, "vertexRotation", rot);
|
||||
|
||||
Serialize(context, "vertexScale", params.vertexScale);
|
||||
Serialize(context, "texCoordOffset", params.texCoordOffset);
|
||||
Serialize(context, "texCoordScale", params.texCoordScale);
|
||||
Serialize(context, "animated", params.animated);
|
||||
Serialize(context, "center", params.center);
|
||||
Serialize(context, "optimizeIndexBuffers", params.optimizeIndexBuffers);
|
||||
|
||||
Serialize(context, "vertexDeclaration", VertexDeclaration::Find(params.vertexDeclaration));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Unserialize(SerializationContext& context, MeshParams* params, TypeTag<MeshParams>)
|
||||
{
|
||||
Unserialize(context, "indexBufferFlags", ¶ms->indexBufferFlags);
|
||||
Unserialize(context, "vertexBufferFlags", ¶ms->vertexBufferFlags);
|
||||
Unserialize(context, "vertexOffset", ¶ms->vertexOffset);
|
||||
|
||||
Nz::EulerAnglesf rot;
|
||||
if (Unserialize(context, "vertexRotation", &rot))
|
||||
params->vertexRotation = rot;
|
||||
|
||||
Unserialize(context, "vertexScale", ¶ms->vertexScale);
|
||||
Unserialize(context, "texCoordOffset", ¶ms->texCoordOffset);
|
||||
Unserialize(context, "texCoordScale", ¶ms->texCoordScale);
|
||||
Unserialize(context, "animated", ¶ms->animated);
|
||||
Unserialize(context, "center", ¶ms->center);
|
||||
Unserialize(context, "optimizeIndexBuffers", ¶ms->optimizeIndexBuffers);
|
||||
|
||||
VertexLayout layout;
|
||||
if (Unserialize(context, "vertexDeclaration", &layout))
|
||||
params->vertexDeclaration = VertexDeclaration::Get(layout);
|
||||
|
||||
return params->IsValid();
|
||||
}
|
||||
|
||||
|
||||
void Mesh::AddSubMesh(std::shared_ptr<SubMesh> subMesh)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,4 +7,18 @@
|
|||
namespace Nz
|
||||
{
|
||||
ResourceParameters::~ResourceParameters() = default;
|
||||
|
||||
bool Serialize(SerializationContext& context, ResourceParameters& params, TypeTag<ResourceParameters>)
|
||||
{
|
||||
NazaraUnused(context);
|
||||
NazaraUnused(params);
|
||||
return true;// Serialize(context, "custom", descriptor.custom);
|
||||
}
|
||||
|
||||
bool Unserialize(SerializationContext& context, ResourceParameters* params, TypeTag<ResourceParameters>)
|
||||
{
|
||||
NazaraUnused(context);
|
||||
NazaraUnused(params);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,28 @@
|
|||
|
||||
namespace Nz
|
||||
{
|
||||
bool Serialize(SerializationContext& context, TextureParams& params, TypeTag<TextureParams>)
|
||||
{
|
||||
Serialize(context, params, TypeTag<ImageParams>());
|
||||
|
||||
int v = int(params.usageFlags);
|
||||
Serialize(context, "usageFlags", v);
|
||||
Serialize(context, "buildMipmaps", params.buildMipmaps);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Unserialize(SerializationContext& context, TextureParams* params, TypeTag<TextureParams>)
|
||||
{
|
||||
Unserialize(context, params, TypeTag<ImageParams>());
|
||||
|
||||
int usageFlags = 0;
|
||||
if (Unserialize(context, "usageFlags", &usageFlags))
|
||||
params->usageFlags = usageFlags;
|
||||
|
||||
Unserialize(context, "buildMipmaps", ¶ms->buildMipmaps);
|
||||
return true;
|
||||
}
|
||||
|
||||
Texture::~Texture() = default;
|
||||
|
||||
bool TextureParams::IsValid() const
|
||||
|
|
|
|||
Loading…
Reference in New Issue