From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/Graphics/TextureSettings.h | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Runtime/Graphics/TextureSettings.h (limited to 'Runtime/Graphics/TextureSettings.h') diff --git a/Runtime/Graphics/TextureSettings.h b/Runtime/Graphics/TextureSettings.h new file mode 100644 index 0000000..3082a5a --- /dev/null +++ b/Runtime/Graphics/TextureSettings.h @@ -0,0 +1,42 @@ +#pragma once + +#include "Runtime/Serialize/TransferFunctions/SerializeTransfer.h" +#include "Runtime/GfxDevice/GfxDeviceTypes.h" + + +// Texture filter, anisotropy, wrap mode settings. +struct TextureSettings +{ + DECLARE_SERIALIZE_NO_PPTR (GLTextureSettings) // keep the name GLTextureSettings here, it's for serialized stuff! + + int m_FilterMode; ///< enum { Nearest, Bilinear, Trilinear } Texture filter mode + int m_Aniso; ///< Anisotropy factor (1 = None, 0 = Always disabled) + float m_MipBias; ///< Bias used for LOD-selection (0 = none) + int m_WrapMode; ///< enum {Repeat, Clamp} Texture wrapping mode. + + TextureSettings () { Reset (); } + + // Set default values + void Reset(); + + void CheckConsistency(); + + #if UNITY_EDITOR + // Set all numbers to -1, marking them as invalid + void Invalidate(); + #endif + + void Apply (TextureID texture, TextureDimension texDim, bool hasMipMap, TextureColorSpace colorSpace) const; + + static void SetAnisoLimits (int minAniso, int maxAniso); + static void GetAnisoLimits (int& minAniso, int& maxAniso); +}; + +template +void TextureSettings::Transfer (TransferFunc& transfer) +{ + TRANSFER (m_FilterMode); + TRANSFER (m_Aniso); + TRANSFER (m_MipBias); + TRANSFER (m_WrapMode); +} -- cgit v1.1-26-g67d0