istereo

view src/istereo.c @ 3:2c5620f0670c

trying to make this piece of crap work
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 07 Sep 2011 05:33:19 +0300
parents bb68fac22579
children 14bbdfcb9030
line source
1 #include <stdio.h>
2 #include <assert.h>
3 #include <unistd.h>
4 #include "opengl.h"
5 #include "istereo.h"
6 #include "sanegl.h"
7 #include "sdr.h"
8 #include "objcsucks.h"
10 unsigned int prog;
12 int init(void)
13 {
14 char *path = ocs_get_path(OCS_PATH_RESOURCES);
15 chdir(path);
17 if(!(prog = create_program_load("test.v.glsl", "test.p.glsl"))) {
18 fprintf(stderr, "failed to load shader program\n");
19 return -1;
20 }
22 return 0;
23 }
25 void cleanup(void)
26 {
27 free_program(prog);
28 }
30 void redraw(void)
31 {
32 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
34 bind_program(prog);
36 gl_matrix_mode(GL_MODELVIEW);
37 gl_load_identity();
38 gl_translatef(0, 0, -8);
40 gl_begin(GL_QUADS);
41 gl_color3f(1, 0, 0);
42 gl_vertex3f(-1, -1, 0);
43 gl_color3f(0, 1, 0);
44 gl_vertex3f(1, -1, 0);
45 gl_color3f(0, 0, 1);
46 gl_vertex3f(1, 1, 0);
47 gl_color3f(1, 1, 0);
48 gl_vertex3f(-1, 1, 0);
49 gl_end();
51 assert(glGetError() == GL_NO_ERROR);
52 }
54 void reshape(int x, int y)
55 {
56 glViewport(0, 0, x, y);
58 gl_matrix_mode(GL_PROJECTION);
59 gl_load_identity();
60 glu_perspective(45.0, (float)x / (float)y, 1.0, 1000.0);
61 }