diff options
author | kitty piapiac <kcp@bsd.computer> | 2023-04-18 12:29:55 -0700 |
---|---|---|
committer | kitty piapiac <kcp@bsd.computer> | 2023-04-18 12:29:55 -0700 |
commit | f1d602f5dcf862907affd1479eb3b2d132d7d639 (patch) | |
tree | b133327eb0bbf0ff3e854db6955f377a083e2e1e /scene-title.c | |
parent | 84bcb0274fc80d360ff0fbe5ede89643169f6165 (diff) |
scenes
a bit crude and untested
Diffstat (limited to 'scene-title.c')
-rw-r--r-- | scene-title.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/scene-title.c b/scene-title.c new file mode 100644 index 0000000..64429c5 --- /dev/null +++ b/scene-title.c @@ -0,0 +1,49 @@ +/*2d title screen*/ + +#include<cglm/affine.h> +#include<cglm/cglm.h> +#include"mino.h" +#include"graph.h" +#include"scene.h" + +_ mat4 win_proj; + +_ U32 shader_tex; +_ IM C shader_tex_vert[]=GRAPH_GLSL( + layout (location=0) in vec3 pos; + layout (location=1) in vec3 col; + layout (location=2) in vec2 tex; + out vec3 Col; + out vec2 Tex; + uniform mat4 proj; + uniform mat4 model; + void main(){gl_Position=proj*model*vec4(pos,1.0);Col=col;Tex=tex;}); +_ IM C shader_tex_frag[]=GRAPH_GLSL( + out vec4 Frag; + in vec3 Col; + in vec2 Tex; + uniform sampler2D buf; + void main(){Frag=texture(buf,Tex);}); +_ V shader_tex_init(V){ + shader_tex=graph_shader_create(shader_tex_vert,shader_tex_frag), + graph_shader_use(shader_tex), + graph_shader_setM4("proj",win_proj), + graph_shader_setI("buf",0);} + +_ U32 tex_cat; +_ V title_init(V){ + glm_ortho(0,graph_win_w,0,graph_win_h,0,4,win_proj), + shader_tex_init(); + tex_cat=graph_tex_create("res/tex/cat.jpg");} + +_ V title_loop(V){/*prelude*/graph_before(),graph_events(); + glm_ortho(0,graph_win_w,0,graph_win_h,0,4,win_proj), + /*interlude*/ + graph_shader_use(shader_tex),graph_shader_setM4("proj",win_proj), + graph_tex_use(tex_cat,0), + graph_quad_xywh(graph_win_w/2.0,graph_win_h/2.0,256,256), + /*postlude*/ + graph_after();} + +_ Scene*title_run(V){title_init();WH(1,title_loop());R 0;} +Scene scene_title={"title",title_run}; |