From f1d602f5dcf862907affd1479eb3b2d132d7d639 Mon Sep 17 00:00:00 2001 From: kitty piapiac Date: Tue, 18 Apr 2023 12:29:55 -0700 Subject: scenes a bit crude and untested --- scene-title.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 scene-title.c (limited to 'scene-title.c') 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 +#include +#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}; -- cgit v1.2.3