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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
#include <string.h>
#include <lua.h>
#include <lauxlib.h>
#include <cglm/cglm.h>
#include "glm.h"
int glm_frustum_bind(lua_State *L)
{
float left = luaL_checknumber(L, 1);
float right = luaL_checknumber(L, 2);
float bottom = luaL_checknumber(L, 3);
float top = luaL_checknumber(L, 4);
float nearVal = luaL_checknumber(L, 5);
float farVal = luaL_checknumber(L, 6);
mat4 *dest = luaL_checkudata(L, 7, glm_mat4_tname);
glm_frustum(left, right, bottom, top, nearVal, farVal, *dest);
return 0;
}
int glm_ortho_bind(lua_State *L)
{
float left = luaL_checknumber(L, 1);
float right = luaL_checknumber(L, 2);
float bottom = luaL_checknumber(L, 3);
float top = luaL_checknumber(L, 4);
float nearVal = luaL_checknumber(L, 5);
float farVal = luaL_checknumber(L, 6);
mat4 *dest = luaL_checkudata(L, 7, glm_mat4_tname);
glm_ortho(left, right, bottom, top, nearVal, farVal, *dest);
return 0;
}
int glm_ortho_aabb_bind(lua_State *L)
{
vec3 *aa = luaL_checkudata(L, 1, glm_vec3_tname);
vec3 *bb = luaL_checkudata(L, 2, glm_vec3_tname);
mat4 *dest = luaL_checkudata(L, 3, glm_mat4_tname);
vec3 box[2];
memcpy(box, *aa, sizeof(vec3));
memcpy(box+1, *bb, sizeof(vec3));
glm_ortho_aabb(box, *dest);
return 0;
}
int glm_ortho_aabb_p_bind(lua_State *L)
{
vec3 *aa = luaL_checkudata(L, 1, glm_vec3_tname);
vec3 *bb = luaL_checkudata(L, 2, glm_vec3_tname);
float padding = luaL_checknumber(L, 3);
mat4 *dest = luaL_checkudata(L, 4, glm_mat4_tname);
vec3 box[2];
memcpy(box, *aa, sizeof(vec3));
memcpy(box+1, *bb, sizeof(vec3));
glm_ortho_aabb_p(box, padding, *dest);
return 0;
}
int glm_ortho_aabb_pz_bind(lua_State *L)
{
vec3 *aa = luaL_checkudata(L, 1, glm_vec3_tname);
vec3 *bb = luaL_checkudata(L, 2, glm_vec3_tname);
float padding = luaL_checknumber(L, 3);
mat4 *dest = luaL_checkudata(L, 4, glm_mat4_tname);
vec3 box[2];
memcpy(box, *aa, sizeof(vec3));
memcpy(box+1, *bb, sizeof(vec3));
glm_ortho_aabb_pz(box, padding, *dest);
return 0;
}
int glm_ortho_default_bind(lua_State *L)
{
float aspect = luaL_checknumber(L, 1);
mat4 *dest = luaL_checkudata(L, 2, glm_mat4_tname);
glm_ortho_default(aspect, *dest);
return 0;
}
int glm_ortho_default_s_bind(lua_State *L)
{
float aspect = luaL_checknumber(L, 1);
float size = luaL_checknumber(L, 2);
mat4 *dest = luaL_checkudata(L, 3, glm_mat4_tname);
glm_ortho_default_s(aspect, size, *dest);
return 0;
}
int glm_perspective_bind(lua_State *L)
{
float fovy = luaL_checknumber(L, 1);
float aspect = luaL_checknumber(L, 2);
float nearVal = luaL_checknumber(L, 3);
float farVal = luaL_checknumber(L, 4);
mat4 *dest = luaL_checkudata(L, 5, glm_mat4_tname);
glm_perspective(fovy, aspect, nearVal, farVal, *dest);
return 0;
}
int glm_persp_move_far_bind(lua_State *L)
{
mat4 *proj = luaL_checkudata(L, 1, glm_mat4_tname);
float deltaFar = luaL_checknumber(L, 2);
glm_persp_move_far(*proj, deltaFar);
return 0;
}
int glm_perspective_default_bind(lua_State *L)
{
float aspect = luaL_checknumber(L, 1);
mat4 *dest = luaL_checkudata(L, 2, glm_mat4_tname);
glm_perspective_default(aspect, *dest);
return 0;
}
int glm_perspective_resize_bind(lua_State *L)
{
float aspect = luaL_checknumber(L, 1);
mat4 *proj = luaL_checkudata(L, 2, glm_mat4_tname);
glm_perspective_resize(aspect, *proj);
return 0;
}
int glm_lookat_bind(lua_State *L)
{
vec3 *eye = luaL_checkudata(L, 1, glm_vec3_tname);
vec3 *center = luaL_checkudata(L, 2, glm_vec3_tname);
vec3 *up = luaL_checkudata(L, 3, glm_vec3_tname);
mat4 *dest = luaL_checkudata(L, 4, glm_mat4_tname);
glm_lookat(*eye, *center, *up, *dest);
return 0;
}
int glm_look_bind(lua_State *L)
{
vec3 *eye = luaL_checkudata(L, 1, glm_vec3_tname);
vec3 *dir = luaL_checkudata(L, 2, glm_vec3_tname);
vec3 *up = luaL_checkudata(L, 3, glm_vec3_tname);
mat4 *dest = luaL_checkudata(L, 4, glm_mat4_tname);
glm_look(*eye, *dir, *up, *dest);
return 0;
}
int glm_look_anyup_bind(lua_State *L)
{
vec3 *eye = luaL_checkudata(L, 1, glm_vec3_tname);
vec3 *dir = luaL_checkudata(L, 2, glm_vec3_tname);
mat4 *dest = luaL_checkudata(L, 3, glm_mat4_tname);
glm_look_anyup(*eye, *dir, *dest);
return 0;
}
int glm_persp_decomp_bind(lua_State *L)
{
mat4 *proj = luaL_checkudata(L, 1, glm_mat4_tname);
float nearVal, farVal, top, bottom, left, right;
glm_persp_decomp(*proj, &nearVal, &farVal, &top, &bottom, &left, &right);
lua_pushnumber(L, nearVal);
lua_pushnumber(L, farVal);
lua_pushnumber(L, top);
lua_pushnumber(L, bottom);
lua_pushnumber(L, left);
lua_pushnumber(L, right);
return 6;
}
/* glm_persp_decompv would provide an identical interface to glm_persp_decomp, so it's not bound */
int glm_persp_decomp_x_bind(lua_State *L)
{
mat4 *proj = luaL_checkudata(L, 1, glm_mat4_tname);
float left, right;
glm_persp_decomp_x(*proj, &left, &right);
lua_pushnumber(L, left);
lua_pushnumber(L, right);
return 2;
}
int glm_persp_decomp_y_bind(lua_State *L)
{
mat4 *proj = luaL_checkudata(L, 1, glm_mat4_tname);
float top, bottom;
glm_persp_decomp_y(*proj, &top, &bottom);
lua_pushnumber(L, top);
lua_pushnumber(L, bottom);
return 2;
}
int glm_persp_decomp_z_bind(lua_State *L)
{
mat4 *proj = luaL_checkudata(L, 1, glm_mat4_tname);
float nearVal, farVal;
glm_persp_decomp_z(*proj, &nearVal, &farVal);
lua_pushnumber(L, nearVal);
lua_pushnumber(L, farVal);
return 2;
}
int glm_persp_decomp_far_bind(lua_State *L)
{
mat4 *proj = luaL_checkudata(L, 1, glm_mat4_tname);
float farVal;
glm_persp_decomp_far(*proj, &farVal);
return 0;
}
int glm_persp_decomp_near_bind(lua_State *L)
{
mat4 *proj = luaL_checkudata(L, 1, glm_mat4_tname);
float nearVal;
glm_persp_decomp_near(*proj, &nearVal);
return 0;
}
int glm_persp_fovy_bind(lua_State *L)
{
mat4 *proj = luaL_checkudata(L, 1, glm_mat4_tname);
float bind_result = glm_persp_fovy(*proj);
lua_pushnumber(L, bind_result);
return 1;
}
int glm_persp_aspect_bind(lua_State *L)
{
mat4 *proj = luaL_checkudata(L, 1, glm_mat4_tname);
float bind_result = glm_persp_aspect(*proj);
lua_pushnumber(L, bind_result);
return 1;
}
int glm_persp_sizes_bind(lua_State *L)
{
mat4 *proj = luaL_checkudata(L, 1, glm_mat4_tname);
float fovy = luaL_checknumber(L, 2);
vec4 *dest = luaL_checkudata(L, 3, glm_vec4_tname);
glm_persp_sizes(*proj, fovy, *dest);
return 0;
}
|