3dphotoshoot

diff src/game.c @ 7:7f6e6eb3d20e

some progress...
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 23 May 2015 23:14:44 +0300
parents 38377f54527a
children 9fc7d52f578d
line diff
     1.1 --- a/src/game.c	Thu May 21 19:03:00 2015 +0300
     1.2 +++ b/src/game.c	Sat May 23 23:14:44 2015 +0300
     1.3 @@ -3,6 +3,9 @@
     1.4  #include <math.h>
     1.5  #include "opengl.h"
     1.6  #include "game.h"
     1.7 +#include "camera.h"
     1.8 +
     1.9 +static void draw_quad(float sz);
    1.10  
    1.11  static int win_width, win_height;
    1.12  
    1.13 @@ -11,7 +14,7 @@
    1.14  {
    1.15  	glEnable(GL_DEPTH_TEST);
    1.16  	glEnable(GL_CULL_FACE);
    1.17 -	glEnable(GL_LIGHTING);
    1.18 +	//glEnable(GL_LIGHTING);
    1.19  
    1.20  	glClearColor(0.4, 0.4, 0.4, 1);
    1.21  	return 0;
    1.22 @@ -23,6 +26,9 @@
    1.23  
    1.24  void game_display(unsigned long msec)
    1.25  {
    1.26 +	unsigned int tex = cam_texture();
    1.27 +	//cam_update();
    1.28 +
    1.29  	//float tsec = (float)msec / 1000.0f;
    1.30  
    1.31  	//glClearColor(sin(tsec * 10.0), cos(tsec * 10.0), -sin(tsec * 10.0), 1.0);
    1.32 @@ -30,6 +36,41 @@
    1.33  
    1.34  	glMatrixMode(GL_MODELVIEW);
    1.35  	glLoadIdentity();
    1.36 +
    1.37 +	if(tex) {
    1.38 +		glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex);
    1.39 +		glEnable(GL_TEXTURE_EXTERNAL_OES);
    1.40 +
    1.41 +		draw_quad(0.5);
    1.42 +
    1.43 +		glDisable(GL_TEXTURE_EXTERNAL_OES);
    1.44 +	}
    1.45 +}
    1.46 +
    1.47 +static void draw_quad(float sz)
    1.48 +{
    1.49 +	static const float varr[] = {-1, -1, 1, -1, 1, 1, -1, 1};
    1.50 +	static const float tcarr[] = {0, 0, 1, 0, 1, 1, 0, 1};
    1.51 +	static const float colarr[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
    1.52 +
    1.53 +	glPushMatrix();
    1.54 +	glScalef(sz, sz, sz);
    1.55 +
    1.56 +	glEnableClientState(GL_VERTEX_ARRAY);
    1.57 +	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    1.58 +	glEnableClientState(GL_COLOR_ARRAY);
    1.59 +
    1.60 +	glVertexPointer(2, GL_FLOAT, 0, varr);
    1.61 +	glTexCoordPointer(2, GL_FLOAT, 0, tcarr);
    1.62 +	glColorPointer(3, GL_FLOAT, 0, colarr);
    1.63 +
    1.64 +	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    1.65 +
    1.66 +	glDisableClientState(GL_VERTEX_ARRAY);
    1.67 +	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    1.68 +	glDisableClientState(GL_COLOR_ARRAY);
    1.69 +
    1.70 +	glPopMatrix();
    1.71  }
    1.72  
    1.73  void game_reshape(int x, int y)