demosystem
[andemo] / src / scr / testa.c
1 #include "demo.h"
2 #include "noise.h"
3 #include "cgmath/cgmath.h"
4
5 static int init(void);
6 static void destroy(void);
7 static void draw(void);
8
9 static unsigned int sdr_foo;
10
11 static struct demoscreen scr = { "testa", init, destroy, 0, 0, 0, 0, draw };
12
13 void regscr_testa(void)
14 {
15         dsys_add_screen(&scr);
16 }
17
18 static int init(void)
19 {
20         if(!(sdr_foo = get_sdrprog("sdr/foo.v.glsl", "sdr/foo-notex.p.glsl"))) {
21                 return -1;
22         }
23         return 0;
24 }
25
26 static void destroy(void)
27 {
28 }
29
30 static void draw(void)
31 {
32         int i;
33         float t = dsys_time / 1000.0f;
34         float gap = cgm_lerp(0, 0.01, scr.vis);
35
36         glUseProgram(sdr_foo);
37         gl_begin(GL_QUADS);
38         for(i=0; i<16; i++) {
39                 float x0 = i / 8.0f - 1.0f + gap;
40                 float x1 = (i + 1) / 8.0f - 1.0f - gap;
41                 float y = cgm_lerp(1.0f, noise2((float)i * 1.24f, t), scr.vis);
42                 gl_vertex2f(x0, -1);
43                 gl_vertex2f(x1, -1);
44                 gl_vertex2f(x1, y);
45                 gl_vertex2f(x0, y);
46         }
47         gl_end();
48 }