3dphotoshoot

diff src/game.c @ 8:9fc7d52f578d

FINALLY I'm getting an image out of the camera
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 25 May 2015 04:14:38 +0300
parents 7f6e6eb3d20e
children d1b456d08713
line diff
     1.1 --- a/src/game.c	Sat May 23 23:14:44 2015 +0300
     1.2 +++ b/src/game.c	Mon May 25 04:14:38 2015 +0300
     1.3 @@ -5,7 +5,7 @@
     1.4  #include "game.h"
     1.5  #include "camera.h"
     1.6  
     1.7 -static void draw_quad(float sz);
     1.8 +static void draw_quad(float hsz, float vsz);
     1.9  
    1.10  static int win_width, win_height;
    1.11  
    1.12 @@ -17,17 +17,20 @@
    1.13  	//glEnable(GL_LIGHTING);
    1.14  
    1.15  	glClearColor(0.4, 0.4, 0.4, 1);
    1.16 +
    1.17 +	cam_start_video();
    1.18  	return 0;
    1.19  }
    1.20  
    1.21  void game_shutdown(void)
    1.22  {
    1.23 +	cam_shutdown();
    1.24  }
    1.25  
    1.26  void game_display(unsigned long msec)
    1.27  {
    1.28  	unsigned int tex = cam_texture();
    1.29 -	//cam_update();
    1.30 +	cam_update();
    1.31  
    1.32  	//float tsec = (float)msec / 1000.0f;
    1.33  
    1.34 @@ -40,21 +43,23 @@
    1.35  	if(tex) {
    1.36  		glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex);
    1.37  		glEnable(GL_TEXTURE_EXTERNAL_OES);
    1.38 +	}
    1.39  
    1.40 -		draw_quad(0.5);
    1.41 +	draw_quad(0.5 * 1.33333, 0.5);
    1.42  
    1.43 +	if(tex) {
    1.44  		glDisable(GL_TEXTURE_EXTERNAL_OES);
    1.45  	}
    1.46  }
    1.47  
    1.48 -static void draw_quad(float sz)
    1.49 +static void draw_quad(float hsz, float vsz)
    1.50  {
    1.51  	static const float varr[] = {-1, -1, 1, -1, 1, 1, -1, 1};
    1.52 -	static const float tcarr[] = {0, 0, 1, 0, 1, 1, 0, 1};
    1.53 -	static const float colarr[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
    1.54 +	static const float tcarr[] = {0, 1, 1, 1, 1, 0, 0, 0};
    1.55 +	static const float colarr[] = {1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1};
    1.56  
    1.57  	glPushMatrix();
    1.58 -	glScalef(sz, sz, sz);
    1.59 +	glScalef(hsz, vsz, 1);
    1.60  
    1.61  	glEnableClientState(GL_VERTEX_ARRAY);
    1.62  	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    1.63 @@ -62,9 +67,9 @@
    1.64  
    1.65  	glVertexPointer(2, GL_FLOAT, 0, varr);
    1.66  	glTexCoordPointer(2, GL_FLOAT, 0, tcarr);
    1.67 -	glColorPointer(3, GL_FLOAT, 0, colarr);
    1.68 +	glColorPointer(4, GL_FLOAT, 0, colarr);
    1.69  
    1.70 -	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    1.71 +	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
    1.72  
    1.73  	glDisableClientState(GL_VERTEX_ARRAY);
    1.74  	glDisableClientState(GL_TEXTURE_COORD_ARRAY);