istereo

view src/istereo.c @ 2:bb68fac22579

sanegl and shit
author John Tsiombikas <nuclear@mutantstargoat.com>
date Wed, 07 Sep 2011 02:48:35 +0300
parents 4d25539806d2
children 2c5620f0670c
line source
1 #include <stdio.h>
2 #include <assert.h>
3 #include "opengl.h"
4 #include "istereo.h"
5 #include "sanegl.h"
6 #include "sdr.h"
8 unsigned int prog;
10 int init(void)
11 {
12 if(!(prog = create_program_load("sdr/test.v.glsl", "sdr/test.p.glsl"))) {
13 fprintf(stderr, "failed to load shader program\n");
14 return -1;
15 }
17 return 0;
18 }
20 void cleanup(void)
21 {
22 free_program(prog);
23 }
25 void redraw(void)
26 {
27 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
29 bind_program(prog);
31 gl_matrix_mode(GL_MODELVIEW);
32 gl_load_identity();
33 gl_translatef(0, 0, -8);
35 gl_apply_xform(prog);
37 gl_begin(GL_QUADS);
38 gl_color3f(1, 0, 0);
39 gl_vertex3f(-1, -1, 0);
40 gl_color3f(0, 1, 0);
41 gl_vertex3f(1, -1, 0);
42 gl_color3f(0, 0, 1);
43 gl_vertex3f(1, 1, 0);
44 gl_color3f(1, 1, 0);
45 gl_vertex3f(-1, 1, 0);
46 gl_end();
48 assert(glGetError() == GL_NO_ERROR);
49 }
51 void reshape(int x, int y)
52 {
53 glViewport(0, 0, x, y);
55 gl_matrix_mode(GL_PROJECTION);
56 gl_load_identity();
57 glu_perspective(45.0, (float)x / (float)y, 1.0, 1000.0);
58 }