summaryrefslogtreecommitdiff
path: root/Runtime/Graphics/TextureSettings.h
blob: 3082a5a82f3eb0719fa0fc3feb1301cbc5dc3de4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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<class TransferFunc>
void TextureSettings::Transfer (TransferFunc& transfer)
{
	TRANSFER (m_FilterMode);
	TRANSFER (m_Aniso);
	TRANSFER (m_MipBias);
	TRANSFER (m_WrapMode);
}