From ae4e17fc743ca0344af818ab767db7311ea7829c Mon Sep 17 00:00:00 2001 From: sanine Date: Tue, 23 Aug 2022 13:28:01 -0500 Subject: add basic transforms --- demo/gl-window | 0 demo/honey.lua | 12 +++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) delete mode 100644 demo/gl-window (limited to 'demo') diff --git a/demo/gl-window b/demo/gl-window deleted file mode 100644 index e69de29..0000000 diff --git a/demo/honey.lua b/demo/honey.lua index 3388b52..822877f 100644 --- a/demo/honey.lua +++ b/demo/honey.lua @@ -30,12 +30,14 @@ layout (location = 0) in vec3 aPos; layout (location = 1) in vec3 aColor; layout (location = 2) in vec2 aTexCoord; +uniform mat4 transform; + out vec3 ourColor; out vec2 TexCoord; void main() { - gl_Position = vec4(aPos, 1.0); + gl_Position = transform * vec4(aPos, 1.0); ourColor = aColor; TexCoord = aTexCoord; } @@ -144,6 +146,8 @@ gl.Uniform1i(gl.GetUniformLocation(shader, 'ourTexture'), 0) --====== main loop ======-- +local transform = honey.glm.mat4() + while not window.shouldClose(w) do gl.ClearColor(0.2, 0.3, 0.3, 1.0) gl.Clear(gl.COLOR_BUFFER_BIT) @@ -152,6 +156,12 @@ while not window.shouldClose(w) do gl.BindTexture(gl.TEXTURE_2D, texture) gl.UseProgram(shader) + honey.glm.mat4_identity(transform) + local time = window.getTime() + honey.glm.rotate_z(transform, time, transform) + local transformLocation = gl.GetUniformLocation(shader, 'transform') + gl.UniformMatrix4fv(transformLocation, false, transform) + gl.BindVertexArray(vertexArray) gl.DrawElements(gl.TRIANGLES, 6, gl.UNSIGNED_INT, 0) -- cgit v1.2.1