conworlds

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