From 5393ce93d05f9979b7882c686b241f6738011c64 Mon Sep 17 00:00:00 2001 From: kitty piapiac Date: Mon, 17 Apr 2023 23:46:30 -0700 Subject: mat4 transformations --- mino.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'mino.c') diff --git a/mino.c b/mino.c index 3362ab3..f59a8f0 100644 --- a/mino.c +++ b/mino.c @@ -1,5 +1,7 @@ #include #include +#include +#include #include"mino.h" #include"graph.h" @@ -14,7 +16,8 @@ _ IM C shader_tex_vert[]=GRAPH_GLSL( layout (location=2) in vec2 tex; out vec3 Col; out vec2 Tex; - void main(){gl_Position=vec4(pos,1.0);Col=col;Tex=tex;}); + uniform mat4 trans; + void main(){gl_Position=trans*vec4(pos,1.0);Col=col;Tex=tex;}); _ IM C shader_tex_frag[]=GRAPH_GLSL( out vec4 Frag; @@ -27,19 +30,23 @@ _ U32 shader_tex; _ V shader_tex_init(V){ shader_tex=graph_shader_create(shader_tex_vert,shader_tex_frag), + graph_shader_use(shader_tex); + mat4 trans; + glm_mat4_identity(trans), + glm_translate(trans,(vec3){0.5,-0.5,0.5}), + glm_rotate(trans,0.2,(vec3){0,0,1}), + graph_shader_setM4("trans",trans), graph_shader_use(shader_tex), - graph_shader_seti("buf0",0), - graph_shader_seti("buf1",1);} + graph_shader_setI("buf0",0), + graph_shader_setI("buf1",1);} I main(I ac,C**av){(V)ac,(V)av;U32 cat,fart; graph_init(); atexit(graph_deinit); - shader_tex_init(); cat=graph_tex_create("res/tex/cat.jpg"); fart=graph_tex_create("res/tex/fart.jpg"); - WH(1,graph_before(),graph_events(), - graph_shader_use(shader_tex), + WH(1,graph_before(),graph_events(); graph_tex_use(cat,0), graph_tex_use(fart,1), graph_quad(), -- cgit v1.2.3