From 2da3c8f5df311d7ce4c3e2f5badd2160be9fdfe4 Mon Sep 17 00:00:00 2001 From: kdx Date: Wed, 10 May 2023 00:06:35 +0200 Subject: MA BOI ROTATED I'M CRYING --- Tupfile | 2 +- src/main.c | 14 ++++++++++++++ src/vertex.glsl | 4 +++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Tupfile b/Tupfile index 056357d..91997c7 100644 --- a/Tupfile +++ b/Tupfile @@ -1,7 +1,7 @@ CC = gcc LD = $(CC) -fuse-ld=mold CFLAGS = -std=c99 -Wall -Wextra -Iglad -Isrc -Istb -DSTBI_ONLY_JPG= -LDFLAGS = -lm -lGL -lglfw +LDFLAGS = -lcglm -lm -lGL -lglfw .gitignore : foreach src/*.glsl |> cembed -z -s %f >%o |> build/src/embed_%B.c diff --git a/src/main.c b/src/main.c index b46095d..d8400ee 100644 --- a/src/main.c +++ b/src/main.c @@ -2,6 +2,7 @@ #include "texture.h" #include #include +#include #include #include @@ -10,6 +11,12 @@ extern unsigned char src_fragment_glsl[]; static void framebuffer_size_callback(GLFWwindow *window, int w, int h); +static float +radians(float x) +{ + return x * 0.01745329f; +} + int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv) { @@ -95,6 +102,10 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char **argv) const GLint vertex_color_location = shader_uniform_location(&shader, "ourColor"); + mat4 trans = GLM_MAT4_IDENTITY_INIT; + glm_rotate(trans, radians(90), (vec3){0.0f, 0.0f, 1.0f}); + glm_scale(trans, (vec3){0.5f, 0.5f, 0.5f}); + //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, GL_LINEAR); @@ -106,6 +117,9 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char **argv) !(r&1), !(r&2), !(r&4), !(r&8)); glUniform1i(shader_uniform_location(&shader, "texture0"), 0); glUniform1i(shader_uniform_location(&shader, "texture1"), 1); + glUniformMatrix4fv(shader_uniform_location(&shader, + "transform"), + 1, GL_FALSE, trans[0]); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture.id); glActiveTexture(GL_TEXTURE1); diff --git a/src/vertex.glsl b/src/vertex.glsl index ec813d4..bad790f 100644 --- a/src/vertex.glsl +++ b/src/vertex.glsl @@ -6,10 +6,12 @@ layout (location = 2) in vec2 aTexCoord; out vec4 vertexColor; out vec2 texCoord; +uniform mat4 transform; + void main() { - gl_Position = vec4(aPos, 1.0); + gl_Position = transform * vec4(aPos, 1.0); vertexColor = vec4(aColor, 1.0); texCoord = aTexCoord; } -- cgit v1.2.3