istereo
diff 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 diff
1.1 --- a/src/istereo.c Tue Sep 06 12:48:39 2011 +0300 1.2 +++ b/src/istereo.c Wed Sep 07 02:48:35 2011 +0300 1.3 @@ -1,17 +1,58 @@ 1.4 +#include <stdio.h> 1.5 +#include <assert.h> 1.6 #include "opengl.h" 1.7 #include "istereo.h" 1.8 +#include "sanegl.h" 1.9 +#include "sdr.h" 1.10 + 1.11 +unsigned int prog; 1.12 1.13 int init(void) 1.14 { 1.15 + if(!(prog = create_program_load("sdr/test.v.glsl", "sdr/test.p.glsl"))) { 1.16 + fprintf(stderr, "failed to load shader program\n"); 1.17 + return -1; 1.18 + } 1.19 + 1.20 return 0; 1.21 } 1.22 1.23 void cleanup(void) 1.24 { 1.25 + free_program(prog); 1.26 } 1.27 1.28 void redraw(void) 1.29 { 1.30 - glClearColor(0, 1, 0, 1); 1.31 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 1.32 + 1.33 + bind_program(prog); 1.34 + 1.35 + gl_matrix_mode(GL_MODELVIEW); 1.36 + gl_load_identity(); 1.37 + gl_translatef(0, 0, -8); 1.38 + 1.39 + gl_apply_xform(prog); 1.40 + 1.41 + gl_begin(GL_QUADS); 1.42 + gl_color3f(1, 0, 0); 1.43 + gl_vertex3f(-1, -1, 0); 1.44 + gl_color3f(0, 1, 0); 1.45 + gl_vertex3f(1, -1, 0); 1.46 + gl_color3f(0, 0, 1); 1.47 + gl_vertex3f(1, 1, 0); 1.48 + gl_color3f(1, 1, 0); 1.49 + gl_vertex3f(-1, 1, 0); 1.50 + gl_end(); 1.51 + 1.52 + assert(glGetError() == GL_NO_ERROR); 1.53 } 1.54 + 1.55 +void reshape(int x, int y) 1.56 +{ 1.57 + glViewport(0, 0, x, y); 1.58 + 1.59 + gl_matrix_mode(GL_PROJECTION); 1.60 + gl_load_identity(); 1.61 + glu_perspective(45.0, (float)x / (float)y, 1.0, 1000.0); 1.62 +}