istereo

annotate 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
rev   line source
nuclear@2 1 #include <stdio.h>
nuclear@2 2 #include <assert.h>
nuclear@3 3 #include <unistd.h>
nuclear@1 4 #include "opengl.h"
nuclear@0 5 #include "istereo.h"
nuclear@2 6 #include "sanegl.h"
nuclear@2 7 #include "sdr.h"
nuclear@3 8 #include "objcsucks.h"
nuclear@2 9
nuclear@2 10 unsigned int prog;
nuclear@0 11
nuclear@0 12 int init(void)
nuclear@0 13 {
nuclear@3 14 char *path = ocs_get_path(OCS_PATH_RESOURCES);
nuclear@3 15 chdir(path);
nuclear@3 16
nuclear@3 17 if(!(prog = create_program_load("test.v.glsl", "test.p.glsl"))) {
nuclear@2 18 fprintf(stderr, "failed to load shader program\n");
nuclear@2 19 return -1;
nuclear@2 20 }
nuclear@2 21
nuclear@0 22 return 0;
nuclear@0 23 }
nuclear@0 24
nuclear@0 25 void cleanup(void)
nuclear@0 26 {
nuclear@2 27 free_program(prog);
nuclear@0 28 }
nuclear@0 29
nuclear@0 30 void redraw(void)
nuclear@0 31 {
nuclear@0 32 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
nuclear@2 33
nuclear@2 34 bind_program(prog);
nuclear@2 35
nuclear@2 36 gl_matrix_mode(GL_MODELVIEW);
nuclear@2 37 gl_load_identity();
nuclear@2 38 gl_translatef(0, 0, -8);
nuclear@2 39
nuclear@2 40 gl_begin(GL_QUADS);
nuclear@2 41 gl_color3f(1, 0, 0);
nuclear@2 42 gl_vertex3f(-1, -1, 0);
nuclear@2 43 gl_color3f(0, 1, 0);
nuclear@2 44 gl_vertex3f(1, -1, 0);
nuclear@2 45 gl_color3f(0, 0, 1);
nuclear@2 46 gl_vertex3f(1, 1, 0);
nuclear@2 47 gl_color3f(1, 1, 0);
nuclear@2 48 gl_vertex3f(-1, 1, 0);
nuclear@2 49 gl_end();
nuclear@2 50
nuclear@2 51 assert(glGetError() == GL_NO_ERROR);
nuclear@0 52 }
nuclear@2 53
nuclear@2 54 void reshape(int x, int y)
nuclear@2 55 {
nuclear@2 56 glViewport(0, 0, x, y);
nuclear@2 57
nuclear@2 58 gl_matrix_mode(GL_PROJECTION);
nuclear@2 59 gl_load_identity();
nuclear@2 60 glu_perspective(45.0, (float)x / (float)y, 1.0, 1000.0);
nuclear@2 61 }