I was looking through the Nexuis code and saw that the engine has a
lot of options for stereo viewing (red/blue, side-by-side) but no
active (quadbuffer) stereo for LCD shutter glasses and the like.
These patches add that capability. It work very well on my
QuadroFX card giving crystal clear eye poping 3D.
The modifications are pretty small thanks to all the previous stereo work.
It's controlled by two new command line options;
nexuis-glx -stereogl +r_stereo_active 1
or
nexuis-sdl -stereogl -r_stereo_active 1
Nice game engine. Have Fun.
Chuck Sites
vid_glx.c
- Code: Select all
--- darkplaces/vid_glx.c 2006-08-31 10:16:54.000000000 -0400
+++ darkplaces_stereo/vid_glx.c 2006-09-24 12:53:17.717450740 -0400
@@ -87,6 +87,7 @@
static qboolean vid_usingmouse = false;
static qboolean vid_usingvsync = false;
static qboolean vid_usevsync = false;
+static qboolean vid_stereogl = false;
static qboolean vid_x11_hardwaregammasupported = false;
static int vid_x11_gammarampsize = 0;
static float mouse_x, mouse_y;
@@ -610,6 +611,8 @@
// COMMANDLINEOPTION: Input: -nomouse disables mouse support (see also vid_mouse cvar)
if (COM_CheckParm ("-nomouse") || COM_CheckParm("-safe"))
mouse_avail = false;
+ if (COM_CheckParm ("-stereogl"))
+ vid_stereogl = true;
}
void VID_BuildGLXAttrib(int *attrib, int stencil)
@@ -620,6 +623,11 @@
*attrib++ = GLX_BLUE_SIZE;*attrib++ = 1;
*attrib++ = GLX_DOUBLEBUFFER;
*attrib++ = GLX_DEPTH_SIZE;*attrib++ = 1;
+ if (vid_stereogl) {
+ // Humm why the *attrib++ = 1; above?
+ *attrib++ = GLX_STEREO;
+ }
+
// if stencil is enabled, ask for alpha too
if (stencil)
{
vid_sdl.c
- Code: Select all
--- darkplaces/vid_sdl.c 2006-08-31 10:16:54.000000000 -0400
+++ darkplaces_stereo/vid_sdl.c 2006-09-24 12:49:23.807755679 -0400
@@ -52,6 +52,7 @@
static qboolean vid_usingmouse;
static qboolean vid_isfullscreen;
+static qboolean vid_stereogl=false;
static int vid_numjoysticks = 0;
#define MAX_JOYSTICKS 8
static SDL_Joystick *vid_joysticks[MAX_JOYSTICKS];
@@ -530,6 +531,9 @@
SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 1);
SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 16);
}
+ if (COM_CheckParm("-stereogl"))
+ SDL_GL_SetAttribute (SDL_GL_STEREO, 1);
+
screen = SDL_SetVideoMode(width, height, bpp, flags);
if (screen == NULL)
glquake.h
- Code: Select all
--- darkplaces/glquake.h 2006-08-10 16:33:44.000000000 -0400
+++ darkplaces_stereo/glquake.h 2006-09-24 12:59:24.064576006 -0400
@@ -170,8 +170,14 @@
#define GL_TEXTURE_COORD_ARRAY 0x8078
//#define GL_EDGE_FLAG_ARRAY 0x8079
+#define GL_FRONT_LEFT 0x0400
+#define GL_FRONT_RIGHT 0x0401
+#define GL_BACK_LEFT 0x0402
+#define GL_BACK_RIGHT 0x0403
#define GL_FRONT 0x0404
#define GL_BACK 0x0405
+#define GL_LEFT 0x0406
+#define GL_RIGHT 0x0407
#define GL_VENDOR 0x1F00
#define GL_RENDERER 0x1F01
cl_screen.c
- Code: Select all
--- darkplaces/cl_screen.c 2006-09-05 21:23:50.000000000 -0400
+++ darkplaces_stereo/cl_screen.c 2006-09-24 14:23:27.386635358 -0400
@@ -37,6 +37,7 @@
cvar_t r_stereo_redblue = {0, "r_stereo_redblue", "0", "red/blue anaglyph stereo glasses (note: most of these glasses are actually red/cyan, try that one too)"};
cvar_t r_stereo_redcyan = {0, "r_stereo_redcyan", "0", "red/cyan anaglyph stereo glasses, the kind given away at drive-in movies like Creature From The Black Lagoon In 3D"};
cvar_t r_stereo_redgreen = {0, "r_stereo_redgreen", "0", "red/green anaglyph stereo glasses (for those who don't mind yellow)"};
+cvar_t r_stereo_active = {0, "r_stereo_active", "0", "Active stereo (for lcd-shutter glasses and quadro cards)"};
cvar_t scr_zoomwindow = {CVAR_SAVE, "scr_zoomwindow", "0", "displays a zoomed in overlay window"};
cvar_t scr_zoomwindow_viewsizex = {CVAR_SAVE, "scr_zoomwindow_viewsizex", "20", "horizontal viewsize of zoom window"};
cvar_t scr_zoomwindow_viewsizey = {CVAR_SAVE, "scr_zoomwindow_viewsizey", "20", "vertical viewsize of zoom window"};
@@ -607,6 +608,7 @@
Cvar_RegisterVariable(&r_stereo_redblue);
Cvar_RegisterVariable(&r_stereo_redcyan);
Cvar_RegisterVariable(&r_stereo_redgreen);
+ Cvar_RegisterVariable(&r_stereo_active);
Cvar_RegisterVariable(&scr_zoomwindow);
Cvar_RegisterVariable(&scr_zoomwindow_viewsizex);
Cvar_RegisterVariable(&scr_zoomwindow_viewsizey);
@@ -1493,7 +1495,7 @@
if (r_timereport_active)
R_TimeReport("clear");
- if (r_stereo_redblue.integer || r_stereo_redgreen.integer || r_stereo_redcyan.integer || r_stereo_sidebyside.integer)
+ if (r_stereo_active.integer || r_stereo_redblue.integer || r_stereo_redgreen.integer || r_stereo_redcyan.integer || r_stereo_sidebyside.integer)
{
matrix4x4_t originalmatrix = r_view.matrix;
r_view.matrix.m[0][3] = originalmatrix.m[0][3] + r_stereo_separation.value * -0.5f * r_view.matrix.m[0][1];
@@ -1510,6 +1512,9 @@
r_view.colormask[2] = 0;
}
+ if (r_stereo_active.integer)
+ qglDrawBuffer(GL_BACK_LEFT);
+
SCR_DrawScreen();
r_view.matrix.m[0][3] = originalmatrix.m[0][3] + r_stereo_separation.value * 0.5f * r_view.matrix.m[0][1];
@@ -1526,6 +1531,9 @@
r_view.colormask[2] = r_stereo_redcyan.integer || r_stereo_redblue.integer;
}
+ if (r_stereo_active.integer)
+ qglDrawBuffer(GL_BACK_RIGHT);
+
SCR_DrawScreen();
r_view.matrix = originalmatrix;