conworlds

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