summaryrefslogtreecommitdiff
path: root/mino.c
diff options
context:
space:
mode:
authorkitty piapiac <kcp@bsd.computer>2023-04-17 22:15:31 -0700
committerkitty piapiac <kcp@bsd.computer>2023-04-17 22:15:31 -0700
commitf92b613698b5c4066068bb937b5993b1c5a3bd24 (patch)
tree23ef82f444f08a1a6fe97ae525b458f6b61a2a1e /mino.c
parent28e849b3c5d683a5cdb56047189b4d73e523bbf4 (diff)
separate shader stuff from graph.c
Diffstat (limited to 'mino.c')
-rw-r--r--mino.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/mino.c b/mino.c
index 2da1700..3362ab3 100644
--- a/mino.c
+++ b/mino.c
@@ -8,9 +8,40 @@ V*make(Uz z){V*p;N(p=malloc(z), die("oom"))R p;}
V*remk(V*p,Uz z){N(p=realloc(p,z),die("oom"))R p;}
V del(V*p){free(p);}
-I main(I ac,C**av){(V)ac,(V)av;U32 cat;
+_ 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;
+ void main(){gl_Position=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 buf0;
+ uniform sampler2D buf1;
+ void main(){Frag=texture(buf0,Tex)*texture(buf1,Tex);});
+_ U32 shader_tex;
+
+_ V shader_tex_init(V){
+ shader_tex=graph_shader_create(shader_tex_vert,shader_tex_frag),
+ graph_shader_use(shader_tex),
+ 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");
- WH(1,graph_before(),graph_events(),graph_quad(cat),graph_after());
+ fart=graph_tex_create("res/tex/fart.jpg");
+ WH(1,graph_before(),graph_events(),
+ graph_shader_use(shader_tex),
+ graph_tex_use(cat,0),
+ graph_tex_use(fart,1),
+ graph_quad(),
+ graph_after());
R 0;}