summaryrefslogtreecommitdiff
path: root/source/modules/asura-core/graphics/binding/_texture.cpp
blob: f5e5f1771560e6a46e6301e05dac2b8328d86525 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "../texture.h"

using namespace std;

namespace_begin(AsuraEngine)
namespace_begin(Graphics)

		
		LUAX_REGISTRY(Texture)
		{
			LUAX_REGISTER_METHODS(state,
				{ "SetFilterMode", _SetFilterMode },
				{ "SetWrapMode",   _SetWrapMode   },
				{ "GetFilterMode", _GetFilterMode },
				{ "GetWrapMode",   _GetWrapMode   },
				{ "IsGenMipmap",   _IsGenMipmap   }
			);
		}

		LUAX_POSTPROCESS(Texture)
		{
			LUAX_REGISTER_ENUM(state, "EColorFormat",
				{ "UNKNOWN", COLOR_FORMAT_UNKNOWN },
				{ "RGBA8",   COLOR_FORMAT_RGBA8   },
				{ "RGBA32F", COLOR_FORMAT_RGBA32F }
			);
			LUAX_REGISTER_ENUM(state, "EFilterMode",
				{ "NEAREST", FILTER_MODE_NEAREST },
				{ "LINEAR",  FILTER_MODE_LINEAR  }
			);
			LUAX_REGISTER_ENUM(state, "EWrapMode",
				{ "REPEAT",        WRAP_MODE_REPEAT        },
				{ "MIRROR",        WRAP_MODE_MIRROR        },
				{ "CLAMPTOEDGE",   WRAP_MODE_CLAMPTOEDGE   },
				{ "CLAMPTOBORDER", WRAP_MODE_CLAMPTOBORDER }
			);

		}

		// texture:SetFilterMode(minFilter, magFilter)
		LUAX_IMPL_METHOD(Texture, _SetFilterMode)
		{
			LUAX_PREPARE(L, Texture);
			FilterMode min = (FilterMode)state.CheckValue<int>(2);
			FilterMode mag = (FilterMode)state.CheckValue<int>(3);
			self->SetFilterMode(min, mag);
			return 0;
		}

		// texture:SetWrapMode(wrap_mode)
		LUAX_IMPL_METHOD(Texture, _SetWrapMode)
		{
			LUAX_PREPARE(L, Texture);
			WrapMode wrap_mode = (WrapMode)state.CheckValue<int>(2);
			self->SetWrapMode(wrap_mode);
			return 0;
		}

		// min, mag = texture:GetFilterMode()
		LUAX_IMPL_METHOD(Texture, _GetFilterMode)
		{
			LUAX_PREPARE(L, Texture);
			state.Push((int)self->m_MinFilter);
			state.Push((int)self->m_MagFilter);
			return 2;
		}

		// wrapmode=  texture:GetWrapMode()
		LUAX_IMPL_METHOD(Texture, _GetWrapMode)
		{
			LUAX_PREPARE(L, Texture);
			state.Push((int)self->m_WrapMode);
			return 1;
		}

		// texture:IsGenMipmap()
		LUAX_IMPL_METHOD(Texture, _IsGenMipmap)
		{
			LUAX_PREPARE(L, Texture);
			state.Push(self->IsGenMipmap());
			return 1;
		}

	}
}