summaryrefslogtreecommitdiff
path: root/src/glm/glm.c
blob: ca6238a32f928b1ae01100cf49ebb97841089c0a (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
#include <lua.h>
#include <honeysuckle.h>
#include "glm.h"


void setup_glm(lua_State *L, int honey_index)
{
	lua_createtable(L, 0, 1);
	int glm_tbl = lua_gettop(L);

	setup_vec3(L, glm_tbl);
	setup_mat4(L, glm_tbl);

	setup_transform(L, glm_tbl);
	setup_camera(L, glm_tbl);

	lua_setfield(L, honey_index, "glm");
}


void array_get(lua_State *L, int max, float *array, int index)
{
	if (index < 0 || index >= max)
		hs_throw_error(L, "index %d is out of range [0-%d]", index, max-1);
	lua_pushnumber(L, array[index]);
}


void array_set(lua_State *L, int max, float *array, int index, float value)
{
	if (index < 0 || index >= max)
		hs_throw_error(L, "index %d is out of range [0-%d]", index, max-1);
	array[index] = value;
}