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