vrchess

diff src/vr/vr_null.c @ 4:e6948e131526

adding a vr wrapper
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 20 Aug 2014 06:33:43 +0300
parents
children 8b7da5ab814e
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/vr/vr_null.c	Wed Aug 20 06:33:43 2014 +0300
     1.3 @@ -0,0 +1,61 @@
     1.4 +#ifdef WIN32
     1.5 +#define WIN32_LEAN_AND_MEAN
     1.6 +#include <windows.h>
     1.7 +#endif
     1.8 +
     1.9 +#ifdef __APPLE__
    1.10 +#include <OpenGL/gl.h>
    1.11 +#else
    1.12 +#include <GL/gl.h>
    1.13 +#endif
    1.14 +
    1.15 +#include "vr_impl.h"
    1.16 +
    1.17 +static int init(void)
    1.18 +{
    1.19 +	return 0;
    1.20 +}
    1.21 +
    1.22 +static void draw(unsigned int fbtex, float u, float maxu, float v, float maxv)
    1.23 +{
    1.24 +	glPushAttrib(GL_ENABLE_BIT | GL_TRANSFORM_BIT);
    1.25 +
    1.26 +	glDisable(GL_LIGHTING);
    1.27 +	glDisable(GL_DEPTH_TEST);
    1.28 +	glDisable(GL_FOG);
    1.29 +	glDisable(GL_CULL_FACE);
    1.30 +
    1.31 +	glMatrixMode(GL_MODELVIEW);
    1.32 +	glLoadIdentity();
    1.33 +	glMatrixMode(GL_PROJECTION);
    1.34 +	glLoadIdentity();
    1.35 +
    1.36 +	glBegin(GL_QUADS);
    1.37 +	glTexCoord2f(u, v);
    1.38 +	glVertex2f(-1, -1);
    1.39 +	glTexCoord2f((u + maxu) / 2, v);
    1.40 +	glVertex2f(1, -1);
    1.41 +	glTexCoord2f((u + maxu) / 2, maxv);
    1.42 +	glVertex2f(1, 1);
    1.43 +	glTexCoord2f(u, maxv);
    1.44 +	glVertex2f(-1, 1);
    1.45 +	glEnd();
    1.46 +
    1.47 +	glPopMatrix();
    1.48 +	glMatrixMode(GL_MODELVIEW);
    1.49 +	glPopMatrix();
    1.50 +
    1.51 +	glPopAttrib();
    1.52 +}
    1.53 +
    1.54 +struct vr_module *vr_module_null(void)
    1.55 +{
    1.56 +	static struct vr_module m;
    1.57 +
    1.58 +	if(!m.init) {
    1.59 +		m.name = "null";
    1.60 +		m.init = init;
    1.61 +		m.draw = draw;
    1.62 +	}
    1.63 +	return &m;
    1.64 +}