libgoatvr

diff src/vr_null.c @ 0:ded3d0a74e19

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