diff options
author | kitty piapiac <kcp@bsd.computer> | 2023-04-17 23:46:30 -0700 |
---|---|---|
committer | kitty piapiac <kcp@bsd.computer> | 2023-04-17 23:46:30 -0700 |
commit | 5393ce93d05f9979b7882c686b241f6738011c64 (patch) | |
tree | b68d664d2c5c47490c0dbba8ef72a4974e516210 /mino.c | |
parent | f92b613698b5c4066068bb937b5993b1c5a3bd24 (diff) |
mat4 transformations
Diffstat (limited to 'mino.c')
-rw-r--r-- | mino.c | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -1,5 +1,7 @@ #include<stdio.h> #include<stdlib.h> +#include<cglm/affine.h> +#include<cglm/cglm.h> #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(), |