conworlds

diff src/vr/vr_null.c @ 7:bd8202d6d28d

some progress...
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 22 Aug 2014 16:55:16 +0300
parents 8b7da5ab814e
children 90abf4b93cc9
line diff
     1.1 --- a/src/vr/vr_null.c	Thu Aug 21 01:08:03 2014 +0300
     1.2 +++ b/src/vr/vr_null.c	Fri Aug 22 16:55:16 2014 +0300
     1.3 @@ -11,11 +11,71 @@
     1.4  
     1.5  #include "vr_impl.h"
     1.6  
     1.7 +static unsigned int eye_tex[2];
     1.8 +static float tex_umin[2], tex_umax[2];
     1.9 +static float tex_vmin[2], tex_vmax[2];
    1.10 +
    1.11  static int init(void)
    1.12  {
    1.13  	return 0;
    1.14  }
    1.15  
    1.16 +static void present(void)
    1.17 +{
    1.18 +	int i;
    1.19 +
    1.20 +	glPushAttrib(GL_ENABLE_BIT | GL_TRANSFORM_BIT);
    1.21 +
    1.22 +	glDisable(GL_LIGHTING);
    1.23 +	glDisable(GL_DEPTH_TEST);
    1.24 +	glDisable(GL_FOG);
    1.25 +	glDisable(GL_CULL_FACE);
    1.26 +
    1.27 +	glEnable(GL_TEXTURE_2D);
    1.28 +
    1.29 +	glMatrixMode(GL_MODELVIEW);
    1.30 +	glLoadIdentity();
    1.31 +	glMatrixMode(GL_PROJECTION);
    1.32 +	glLoadIdentity();
    1.33 +
    1.34 +	for(i=0; i<2; i++) {
    1.35 +		float x0 = i == 0 ? -1 : 0;
    1.36 +		float x1 = i == 0 ? 0 : 1;
    1.37 +
    1.38 +		glBindTexture(GL_TEXTURE_2D, eye_tex[i]);
    1.39 +
    1.40 +		glBegin(GL_QUADS);
    1.41 +		glTexCoord2f(tex_umin[i], tex_vmin[i]);
    1.42 +		glVertex2f(x0, -1);
    1.43 +		glTexCoord2f(tex_umax[i], tex_vmin[i]);
    1.44 +		glVertex2f(x1, -1);
    1.45 +		glTexCoord2f(tex_umax[i], tex_vmax[i]);
    1.46 +		glVertex2f(x1, 1);
    1.47 +		glTexCoord2f(tex_umin[i], tex_vmax[i]);
    1.48 +		glVertex2f(x0, 1);
    1.49 +		glEnd();
    1.50 +	}
    1.51 +
    1.52 +	glPopMatrix();
    1.53 +	glMatrixMode(GL_MODELVIEW);
    1.54 +	glPopMatrix();
    1.55 +
    1.56 +	glPopAttrib();
    1.57 +
    1.58 +#ifdef WIN32
    1.59 +	SwapBuffers(wglGetCurrentDC());
    1.60 +#endif
    1.61 +}
    1.62 +
    1.63 +static void set_eye_texture(int eye, unsigned int tex, float umin, float vmin, float umax, float vmax)
    1.64 +{
    1.65 +	eye_tex[eye] = tex;
    1.66 +	tex_umin[eye] = umin;
    1.67 +	tex_umax[eye] = umax;
    1.68 +	tex_vmin[eye] = vmin;
    1.69 +	tex_vmax[eye] = vmax;
    1.70 +}
    1.71 +
    1.72  struct vr_module *vr_module_null(void)
    1.73  {
    1.74  	static struct vr_module m;
    1.75 @@ -23,6 +83,8 @@
    1.76  	if(!m.init) {
    1.77  		m.name = "null";
    1.78  		m.init = init;
    1.79 +		m.set_eye_texture = set_eye_texture;
    1.80 +		m.present = present;
    1.81  	}
    1.82  	return &m;
    1.83  }