libgoatvr

annotate 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
rev   line source
nuclear@0 1 #ifdef WIN32
nuclear@0 2 #define WIN32_LEAN_AND_MEAN
nuclear@0 3 #include <windows.h>
nuclear@0 4 #endif
nuclear@0 5 #ifdef __APPLE__
nuclear@0 6 #include <OpenGL/gl.h>
nuclear@0 7 #else
nuclear@0 8 #include <GL/gl.h>
nuclear@0 9 #endif
nuclear@0 10 #include "vr_impl.h"
nuclear@0 11
nuclear@0 12 static unsigned int eye_tex[2];
nuclear@0 13 static float tex_umin[2], tex_umax[2];
nuclear@0 14 static float tex_vmin[2], tex_vmax[2];
nuclear@0 15
nuclear@0 16 static int init(void)
nuclear@0 17 {
nuclear@0 18 return 0;
nuclear@0 19 }
nuclear@0 20
nuclear@0 21 static int present(void)
nuclear@0 22 {
nuclear@0 23 int i;
nuclear@0 24
nuclear@0 25 glPushAttrib(GL_ENABLE_BIT | GL_TRANSFORM_BIT);
nuclear@0 26
nuclear@0 27 glDisable(GL_LIGHTING);
nuclear@0 28 glDisable(GL_DEPTH_TEST);
nuclear@0 29 glDisable(GL_FOG);
nuclear@0 30 glDisable(GL_CULL_FACE);
nuclear@0 31
nuclear@0 32 glEnable(GL_TEXTURE_2D);
nuclear@0 33
nuclear@0 34 glMatrixMode(GL_MODELVIEW);
nuclear@0 35 glLoadIdentity();
nuclear@0 36 glMatrixMode(GL_PROJECTION);
nuclear@0 37 glLoadIdentity();
nuclear@0 38
nuclear@0 39 for(i=0; i<2; i++) {
nuclear@0 40 float x0 = i == 0 ? -1 : 0;
nuclear@0 41 float x1 = i == 0 ? 0 : 1;
nuclear@0 42
nuclear@0 43 glBindTexture(GL_TEXTURE_2D, eye_tex[i]);
nuclear@0 44
nuclear@0 45 glBegin(GL_QUADS);
nuclear@0 46 glTexCoord2f(tex_umin[i], tex_vmin[i]);
nuclear@0 47 glVertex2f(x0, -1);
nuclear@0 48 glTexCoord2f(tex_umax[i], tex_vmin[i]);
nuclear@0 49 glVertex2f(x1, -1);
nuclear@0 50 glTexCoord2f(tex_umax[i], tex_vmax[i]);
nuclear@0 51 glVertex2f(x1, 1);
nuclear@0 52 glTexCoord2f(tex_umin[i], tex_vmax[i]);
nuclear@0 53 glVertex2f(x0, 1);
nuclear@0 54 glEnd();
nuclear@0 55 }
nuclear@0 56
nuclear@0 57 glPopMatrix();
nuclear@0 58 glMatrixMode(GL_MODELVIEW);
nuclear@0 59 glPopMatrix();
nuclear@0 60
nuclear@0 61 glPopAttrib();
nuclear@0 62 return 0;
nuclear@0 63 }
nuclear@0 64
nuclear@0 65 static void set_eye_texture(int eye, unsigned int tex, float umin, float vmin, float umax, float vmax)
nuclear@0 66 {
nuclear@0 67 eye_tex[eye] = tex;
nuclear@0 68 tex_umin[eye] = umin;
nuclear@0 69 tex_umax[eye] = umax;
nuclear@0 70 tex_vmin[eye] = vmin;
nuclear@0 71 tex_vmax[eye] = vmax;
nuclear@0 72 }
nuclear@0 73
nuclear@0 74 struct vr_module *vr_module_null(void)
nuclear@0 75 {
nuclear@0 76 static struct vr_module m;
nuclear@0 77
nuclear@0 78 if(!m.init) {
nuclear@0 79 m.name = "null";
nuclear@0 80 m.init = init;
nuclear@0 81 m.set_eye_texture = set_eye_texture;
nuclear@0 82 m.present = present;
nuclear@0 83 }
nuclear@0 84 return &m;
nuclear@0 85 }