diff options
author | kdx <kikoodx@paranoici.org> | 2023-05-10 00:06:35 +0200 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-05-10 00:06:35 +0200 |
commit | 2da3c8f5df311d7ce4c3e2f5badd2160be9fdfe4 (patch) | |
tree | 3990276db817090b3fac7bbb9f6c81a81f54d693 | |
parent | be707e8590516b67a61b5d23130c556a141be185 (diff) | |
download | learnopengl-2da3c8f5df311d7ce4c3e2f5badd2160be9fdfe4.tar.gz |
MA BOI ROTATED I'M CRYING
-rw-r--r-- | Tupfile | 2 | ||||
-rw-r--r-- | src/main.c | 14 | ||||
-rw-r--r-- | src/vertex.glsl | 4 |
3 files changed, 18 insertions, 2 deletions
@@ -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 @@ -2,6 +2,7 @@ #include "texture.h" #include <glad/glad.h> #include <GLFW/glfw3.h> +#include <cglm/cglm.h> #include <stdio.h> #include <stdlib.h> @@ -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; } |