conworlds

view src/vr/vr_null.c @ 20:782ff06817fb

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