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
|
#include "Runtime/Graphics/Shader.h"
#include "Runtime/Graphics/Texture.h"
#include "Runtime/Graphics/ImageData.h"
#include "Runtime/Graphics/GfxDevice.h"
#include "Runtime/GUI/UIQuad.h"
#include "Runtime/GUI/UI9Slicing.h"
#include "Runtime/Math/Math.h"
// Rendering.DrawUIQuad({})
static int DrawUIQuad(lua_State* L)
{
LUA_BIND_STATE(L);
Rect rect = state.GetValue<Rect>(1, Rect());
UIQuad quad = UIQuad(rect.x, rect.x + rect.width, rect.y, rect.y + rect.height);
quad.Draw();
return 0;
}
// mode, horizontal, vertical, texSize, quadSize
static int DrawUI9Slicing(lua_State* L)
{
LUA_BIND_STATE(L);
int mode = state.GetValue<int>(1, ESlicing::Slicing_Simple);
Vector2 horizontal = state.GetValue<Vector2>(2, Vector2::zero);
Vector2 vertical = state.GetValue<Vector2>(3, Vector2::zero);
Vector2 texSize = state.GetValue<Vector2>(4, Vector2::zero);
Vector2 quadSize = state.GetValue<Vector2>(5, Vector2::zero);
UI9Slicing slicing = UI9Slicing(mode, horizontal, vertical, texSize, quadSize);
slicing.Draw();
return 0;
}
static luaL_Reg funcs[] = {
{"DrawUIQuad", DrawUIQuad},
{"DrawUI9Slicing", DrawUI9Slicing},
{0, 0}
};
int luaopen_GameLab_Engine_Rendering(lua_State* L)
{
log_info_tag("Scripting", "luaopen_GameLab_Engine_Rendering()");
LUA_BIND_STATE(L);
state.PushGlobalNamespace();
state.PushNamespace("GameLab");
state.PushNamespace("Engine");
state.PushNamespace("Rendering");
state.RegisterMethods(funcs);
state.RegisterNativeClass<Shader>();
state.RegisterNativeClass<ImageData>();
state.RegisterNativeClass<Texture>();
return 1;
}
|