summaryrefslogtreecommitdiff
path: root/Runtime/Scripting/Rendering/Rendering.bind.cpp
blob: 9fb9a4862ccb928d778abe5568718fda65605aee (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
#include "Runtime/Graphics/Shader.h"
#include "Runtime/Graphics/Texture.h"
#include "Runtime/Graphics/ImageData.h"
#include "Runtime/Graphics/GfxDevice.h"
#include "Runtime/Rendering/UIQuad.h"

// Rendering.DrawUIQuad({})
static int DrawUIQuad(lua_State* L)
{
    LUA_BIND_STATE(L);
    Internal::Rect rect = state.GetValue<Internal::Rect>(1, Internal::Rect());
    UIQuad quad = UIQuad(rect.x, rect.x + rect.width, rect.y, rect.y + rect.height);
    quad.Draw();
    return 0;
}

static int ResetUniformState(lua_State* L)
{
    g_GfxDevice.ResetUniformsState();
    return 0;
}

static luaL_Reg funcs[] = {
    {"DrawUIQuad", DrawUIQuad},
    {"ResetUniformState", ResetUniformState},
    {0, 0}
};

int luaopen_GameLab_Engine_Rendering(lua_State* L)
{
	log_info("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;
}