summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-02-23 00:04:50 -0600
committersanine <sanine.not@pm.me>2023-02-23 00:04:50 -0600
commit7f7c3cea4e0bc564009089b1520303c29164d308 (patch)
tree9ca0c050611e4732e86ce75e0888671b30d9ff93
parent26af60e0e9dfc4ecdf6b1c6f9a2dc5818f4ad8d7 (diff)
fix bug with byte alignment and update fancy demo to use refactored glm bindings
-rw-r--r--CMakeLists.txt3
-rw-r--r--demo/fancy/honey.lua14
-rw-r--r--src/glm/setup.c8
3 files changed, 18 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a4e9a08..d8ebc4b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,6 +26,9 @@ target_include_directories(
${LIB_ROOT}/nanovg/src
)
+# disable byte-alignment in cglm
+add_definitions(-DCGLM_ALL_UNALIGNED)
+
# link to third-party included libraries
target_link_directories(
honey PUBLIC
diff --git a/demo/fancy/honey.lua b/demo/fancy/honey.lua
index bbc8445..5a93a0e 100644
--- a/demo/fancy/honey.lua
+++ b/demo/fancy/honey.lua
@@ -250,32 +250,32 @@ gl.Uniform1i(gl.GetUniformLocation(shader, 'ourTexture'), 0)
--====== matrices ======--
-local model = honey.glm.mat4()
-local axis1 = honey.glm.vec3()
+local model = honey.glm.mat4_create()
+local axis1 = honey.glm.vec3_create()
honey.glm.vec3_set(axis1, 0, 1.0)
honey.glm.vec3_set(axis1, 1, 0.0)
honey.glm.vec3_set(axis1, 2, 0.0)
-local axis2 = honey.glm.vec3()
+local axis2 = honey.glm.vec3_create()
honey.glm.vec3_set(axis2, 0, 0.0)
honey.glm.vec3_set(axis2, 1, 1.0)
honey.glm.vec3_set(axis2, 2, 0.0)
-local view = honey.glm.mat4()
+local view = honey.glm.mat4_create()
honey.glm.mat4_identity(view)
-local translation = honey.glm.vec3()
+local translation = honey.glm.vec3_create()
honey.glm.vec3_set(translation, 0, 0.0)
honey.glm.vec3_set(translation, 1, 0.0)
honey.glm.vec3_set(translation, 2, -3.0)
honey.glm.translate(view, translation)
-local projection = honey.glm.mat4()
+local projection = honey.glm.mat4_create()
honey.glm.perspective(math.rad(45), 800/600, 0.1, 100, projection)
--====== main loop ======--
-local transform = honey.glm.mat4()
+local transform = honey.glm.mat4_create()
while not window.shouldClose(w) do
local time = window.getTime()
diff --git a/src/glm/setup.c b/src/glm/setup.c
index 6b91f0b..332987b 100644
--- a/src/glm/setup.c
+++ b/src/glm/setup.c
@@ -15,6 +15,14 @@ const char *glm_versor_tname = "glm.versor";
void setup_glm(lua_State *L, int honey_index)
{
+ luaL_newmetatable(L, glm_mat2_tname); lua_pop(L, 1);
+ luaL_newmetatable(L, glm_mat3_tname); lua_pop(L, 1);
+ luaL_newmetatable(L, glm_mat4_tname); lua_pop(L, 1);
+ luaL_newmetatable(L, glm_vec2_tname); lua_pop(L, 1);
+ luaL_newmetatable(L, glm_vec3_tname); lua_pop(L, 1);
+ luaL_newmetatable(L, glm_vec4_tname); lua_pop(L, 1);
+ luaL_newmetatable(L, glm_versor_tname); lua_pop(L, 1);
+
struct honey_tbl_t glm[] = {
#define X(name, func) H_FUNC(name, func),
GLM_FUNCTIONS