]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added vid_stereobuffer cvar based on patch from syschuck on the alientrap forums
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 18 Oct 2006 03:52:49 +0000 (03:52 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 18 Oct 2006 03:52:49 +0000 (03:52 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6604 d7cf8633-e32d-0410-b094-e92efae38249

cl_screen.c
glquake.h
todo
vid.h
vid_agl.c
vid_glx.c
vid_null.c
vid_sdl.c
vid_shared.c
vid_wgl.c

index 24421a2880a5afc509744d2eb902eb823ac6aa99..c01168507eb5803efd58c39a79da772fcd1f58f9 100644 (file)
@@ -1642,7 +1642,18 @@ void SCR_UpdateLoadingScreen (void)
        texcoord2f[2] = 1;texcoord2f[3] = 0;
        texcoord2f[4] = 1;texcoord2f[5] = 1;
        texcoord2f[6] = 0;texcoord2f[7] = 1;
-       R_Mesh_Draw(0, 4, 2, polygonelements);
+       if (vid.stereobuffer)
+       {
+               qglDrawBuffer(GL_BACK_LEFT);
+               R_Mesh_Draw(0, 4, 2, polygonelements);
+               qglDrawBuffer(GL_BACK_RIGHT);
+               R_Mesh_Draw(0, 4, 2, polygonelements);
+       }
+       else
+       {
+               qglDrawBuffer(GL_BACK);
+               R_Mesh_Draw(0, 4, 2, polygonelements);
+       }
        R_Mesh_Finish();
        // refresh
        VID_Finish(false);
@@ -1732,7 +1743,7 @@ void CL_UpdateScreen(void)
        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 (vid.stereobuffer || 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];
@@ -1749,6 +1760,9 @@ void CL_UpdateScreen(void)
                        r_view.colormask[2] = 0;
                }
 
+               if (vid.stereobuffer)
+                       qglDrawBuffer(GL_BACK_RIGHT);
+
                SCR_DrawScreen();
 
                r_view.matrix.m[0][3] = originalmatrix.m[0][3] + r_stereo_separation.value * 0.5f * r_view.matrix.m[0][1];
@@ -1765,12 +1779,18 @@ void CL_UpdateScreen(void)
                        r_view.colormask[2] = r_stereo_redcyan.integer || r_stereo_redblue.integer;
                }
 
+               if (vid.stereobuffer)
+                       qglDrawBuffer(GL_BACK_LEFT);
+
                SCR_DrawScreen();
 
                r_view.matrix = originalmatrix;
        }
        else
+       {
+               qglDrawBuffer(GL_BACK);
                SCR_DrawScreen();
+       }
 
        SCR_CaptureVideo();
 
index af5d77a2cf9bc51307de18a286b2c5e44e779b7c..02a955eb66d7d723dda0ef4171cfb0c44b130ab9 100644 (file)
--- a/glquake.h
+++ b/glquake.h
@@ -170,8 +170,20 @@ extern int gl_max_anisotropy;
 #define GL_TEXTURE_COORD_ARRAY                 0x8078
 //#define GL_EDGE_FLAG_ARRAY                   0x8079
 
+#define GL_NONE                                        0
+#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_FRONT_AND_BACK              0x0408
+#define GL_AUX0                                        0x0409
+#define GL_AUX1                                        0x040A
+#define GL_AUX2                                        0x040B
+#define GL_AUX3                                        0x040C
 
 #define GL_VENDOR                              0x1F00
 #define GL_RENDERER                            0x1F01
diff --git a/todo b/todo
index 9ef75303224073f679983c0364757ea38270ad60..0aea8ffb0392f7908f0866ea631e2fd94344c4fc 100644 (file)
--- a/todo
+++ b/todo
 0 bug darkplaces loader: occasional crash due to memory corruption when doing "deathmatch 1;map start" during demo loop (Willis)
 0 bug darkplaces loader: q3bsp deluxemap detection can fail on some files, thinking they have deluxemaps even though they don't? (jimmmy)
 0 bug darkplaces loader: q3bsp lightgrid loading seems to be ignoring the "gridsize" key of worldspawn, but how?
+0 bug darkplaces physics: GAME_TAOV: Vigil's movement isn't working properly, the qc uses MOVETYPE_STEP and clears FL_ONGROUND every frame and moves using velocity, this is causing a landing sound every frame and causing the player to slide down minor slopes very quickly, this did not occur in Quake, and seems that it must be related to a velocity_z check or FL_ONGROUND check in the MOVETYPE_STEP physics code (RenegadeC, xaGe)
 0 bug darkplaces physics: in Prydon Gate the func_door2 entities are stuck in eachother, causing a continuous spew of warnings and causing one of them to be teleported slightly upward which looks bad (FrikaC)
 0 bug darkplaces readme: commandline options are slightly out of date, update them (Baker)
+0 bug darkplaces readme: it would be a very good idea to add documentation of sv_gameplayfix_* cvars in the readme as a means to run broken mods (xaGe)
 0 bug darkplaces renderer: GL13 path has broken handling of unlit surfaces in Nexuiz toxic.bsp - the small red light surfaces are black in GL13 path (m0rfar)
 0 bug darkplaces renderer: modify r_showtris_polygonoffset to push back all filled geometry, not lines, because polygonoffset will not affect GL_LINES at all
 0 bug darkplaces renderer: monsters teleporting in really slow down rendering, perhaps the teleport light is casting huge shadows?  new information suggests it is the particles. (romi, lcatlnx)
diff --git a/vid.h b/vid.h
index 9d5ca1372176a729e937ae049c7f4f692f8e5781..ac1820211b1f90f85c33403cbde3c761d5c2041c 100644 (file)
--- a/vid.h
+++ b/vid.h
@@ -32,6 +32,7 @@ typedef struct viddef_s
        int bitsperpixel;
        int fullscreen;
        int refreshrate;
+       int stereobuffer;
 } viddef_t;
 
 // global video state
@@ -117,7 +118,7 @@ int VID_SetMode (int modenum);
 // sets the mode; only used by the Quake engine for resetting to mode 0 (the
 // base mode) on memory allocation failures
 
-int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate);
+int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer);
 // allocates and opens an appropriate OpenGL context (and its window)
 
 
index 32834c520e988e8bd14d3537151be860ce4a3bbf..de1775c235d5a0b53ff9fe86a5fc75fb0dc411b8 100644 (file)
--- a/vid_agl.c
+++ b/vid_agl.c
@@ -360,7 +360,7 @@ static void VID_ProcessPendingAsyncEvents (void)
                Sys_Quit();
 }
 
-static void VID_BuildAGLAttrib(GLint *attrib, qboolean stencil, qboolean fullscreen)
+static void VID_BuildAGLAttrib(GLint *attrib, qboolean stencil, qboolean fullscreen, qboolean stereobuffer)
 {
        *attrib++ = AGL_RGBA;
        *attrib++ = AGL_RED_SIZE;*attrib++ = 1;
@@ -377,10 +377,12 @@ static void VID_BuildAGLAttrib(GLint *attrib, qboolean stencil, qboolean fullscr
        }
        if (fullscreen)
                *attrib++ = AGL_FULLSCREEN;
+       if (stereobuffer)
+               *attrib++ = AGL_STEREO;
        *attrib++ = AGL_NONE;
 }
 
-int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate)
+int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer)
 {
     const EventTypeSpec winEvents[] =
        {
@@ -445,7 +447,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
                                                           GetEventTypeCount(winEvents), winEvents, window, NULL);
 
        // Create the desired attribute list
-       VID_BuildAGLAttrib(attributes, bpp == 32, fullscreen);
+       VID_BuildAGLAttrib(attributes, bpp == 32, fullscreen, stereobuffer);
 
        if (!fullscreen)
        {
index 463d3854f12f5e61ac1202a22a3e7aa3a3702d20..de1ac666dc29f00015a58f0553f11f7d28e0f4e8 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -612,7 +612,7 @@ void VID_Init(void)
                mouse_avail = false;
 }
 
-void VID_BuildGLXAttrib(int *attrib, int stencil)
+void VID_BuildGLXAttrib(int *attrib, qboolean stencil, qboolean stereobuffer)
 {
        *attrib++ = GLX_RGBA;
        *attrib++ = GLX_RED_SIZE;*attrib++ = 1;
@@ -626,10 +626,12 @@ void VID_BuildGLXAttrib(int *attrib, int stencil)
                *attrib++ = GLX_STENCIL_SIZE;*attrib++ = 8;
                *attrib++ = GLX_ALPHA_SIZE;*attrib++ = 1;
        }
+       if (stereobuffer)
+               *attrib++ = GLX_STEREO;
        *attrib++ = None;
 }
 
-int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate)
+int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer)
 {
        int i;
        int attrib[32];
@@ -687,7 +689,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
                return false;
        }
 
-       VID_BuildGLXAttrib(attrib, bpp == 32);
+       VID_BuildGLXAttrib(attrib, bpp == 32, stereobuffer);
        visinfo = qglXChooseVisual(vidx11_display, vidx11_screen, attrib);
        if (!visinfo)
        {
index 9accd0a6da7fc04ab6af45692746541f061efed1..e70e745704632641dd016fd0559226db1bdebb82 100644 (file)
@@ -70,7 +70,7 @@ void VID_Init(void)
        InitSig(); // trap evil signals
 }
 
-int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate)
+int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer)
 {
        return false;
 }
index acd41272a32913c82f653b5efd4d03553f129c22..8a917822555cd9d84433739569da5f4d6369cb56 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -470,7 +470,7 @@ static void VID_OutputVersion()
                                        version->major, version->minor, version->patch );
 }
 
-int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate)
+int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer)
 {
        int i;
        int flags = SDL_OPENGL;
@@ -530,6 +530,8 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
                SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 1);
                SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 16);
        }
+       if (stereobuffer)
+               SDL_GL_SetAttribute (SDL_GL_STEREO, 1);
 
        screen = SDL_SetVideoMode(width, height, bpp, flags);
        if (screen == NULL)
index 6a9292ec2e5cc1d815471030305a587f59d16b64..8bd1851e23c86a725d200fe65314838db28f44ea 100644 (file)
@@ -71,6 +71,7 @@ cvar_t vid_width = {CVAR_SAVE, "vid_width", "640", "resolution"};
 cvar_t vid_height = {CVAR_SAVE, "vid_height", "480", "resolution"};
 cvar_t vid_bitsperpixel = {CVAR_SAVE, "vid_bitsperpixel", "32", "how many bits per pixel to render at (32 or 16, 32 is recommended)"};
 cvar_t vid_refreshrate = {CVAR_SAVE, "vid_refreshrate", "60", "refresh rate to use, in hz (higher values flicker less, if supported by your monitor)"};
+cvar_t vid_stereobuffer = {CVAR_SAVE, "vid_stereobuffer", "0", "enables 'quad-buffered' stereo rendering for stereo shutterglasses, HMD (head mounted display) devices, or polarized stereo LCDs, if supported by your drivers"};
 
 cvar_t vid_vsync = {CVAR_SAVE, "vid_vsync", "0", "sync to vertical blank, prevents 'tearing' (seeing part of one frame and part of another on the screen at the same time), automatically disabled when doing timedemo benchmarks"};
 cvar_t vid_mouse = {CVAR_SAVE, "vid_mouse", "1", "whether to use the mouse in windowed mode (fullscreen always does)"};
@@ -885,6 +886,7 @@ void VID_Shared_Init(void)
        Cvar_RegisterVariable(&vid_height);
        Cvar_RegisterVariable(&vid_bitsperpixel);
        Cvar_RegisterVariable(&vid_refreshrate);
+       Cvar_RegisterVariable(&vid_stereobuffer);
        Cvar_RegisterVariable(&vid_vsync);
        Cvar_RegisterVariable(&vid_mouse);
        Cvar_RegisterVariable(&vid_minwidth);
@@ -897,21 +899,23 @@ void VID_Shared_Init(void)
                Cvar_Set("gl_combine", "0");
 }
 
-int VID_Mode(int fullscreen, int width, int height, int bpp, int refreshrate)
+int VID_Mode(int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer)
 {
-       Con_Printf("Video: %s %dx%dx%dx%dhz\n", fullscreen ? "fullscreen" : "window", width, height, bpp, refreshrate);
-       if (VID_InitMode(fullscreen, width, height, bpp, refreshrate))
+       Con_Printf("Video: %s %dx%dx%dx%dhz%s\n", fullscreen ? "fullscreen" : "window", width, height, bpp, refreshrate, stereobuffer ? " stereo" : "");
+       if (VID_InitMode(fullscreen, width, height, bpp, refreshrate, stereobuffer))
        {
                vid.fullscreen = fullscreen;
                vid.width = width;
                vid.height = height;
                vid.bitsperpixel = bpp;
                vid.refreshrate = refreshrate;
+               vid.stereobuffer = stereobuffer;
                Cvar_SetValueQuick(&vid_fullscreen, fullscreen);
                Cvar_SetValueQuick(&vid_width, width);
                Cvar_SetValueQuick(&vid_height, height);
                Cvar_SetValueQuick(&vid_bitsperpixel, bpp);
                Cvar_SetValueQuick(&vid_refreshrate, refreshrate);
+               Cvar_SetValueQuick(&vid_stereobuffer, stereobuffer);
                return true;
        }
        else
@@ -943,10 +947,10 @@ void VID_Restart_f(void)
                vid_fullscreen.integer ? "fullscreen" : "window", vid_width.integer, vid_height.integer, vid_bitsperpixel.integer);
        VID_CloseSystems();
        VID_Shutdown();
-       if (!VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_refreshrate.integer))
+       if (!VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_refreshrate.integer, vid_stereobuffer.integer))
        {
                Con_Print("Video mode change failed\n");
-               if (!VID_Mode(vid.fullscreen, vid.width, vid.height, vid.bitsperpixel, vid.refreshrate))
+               if (!VID_Mode(vid.fullscreen, vid.width, vid.height, vid.bitsperpixel, vid.refreshrate, vid.stereobuffer))
                        Sys_Error("Unable to restore to last working video mode");
        }
        VID_OpenSystems();
@@ -988,17 +992,19 @@ void VID_Start(void)
        }
 
        Con_Print("Starting video system\n");
-       success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_refreshrate.integer);
+       success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_refreshrate.integer, vid_stereobuffer.integer);
        if (!success)
        {
                Con_Print("Desired video mode fail, trying fallbacks...\n");
-               success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, 60);
+               success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, 60, vid_stereobuffer.integer);
+               if (!success && vid_stereobuffer.integer)
+                       success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_refreshrate.integer, false);
                if (!success && vid_bitsperpixel.integer > 16)
-                       success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, 16, 60);
+                       success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, 16, 60, false);
                if (!success && (vid_width.integer > 640 || vid_height.integer > 480))
-                       success = VID_Mode(vid_fullscreen.integer, 640, 480, 16, 60);
+                       success = VID_Mode(vid_fullscreen.integer, 640, 480, 16, 60, false);
                if (!success && vid_fullscreen.integer)
-                       success = VID_Mode(false, 640, 480, 16, 60);
+                       success = VID_Mode(false, 640, 480, 16, 60, false);
                if (!success)
                        Sys_Error("Video modes failed");
        }
index 38c4d868ce1acb0e2f42b75a017c4eecd77c7a4d..6c58989553ea21bb69c1709b48b24612e9ae5cfc 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -728,7 +728,7 @@ void VID_Init(void)
        IN_Init();
 }
 
-int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrate)
+int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer)
 {
        int i;
        HDC hdc;
@@ -776,6 +776,9 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat
                pfd.cAlphaBits = 0;
        }
 
+       if (stereobuffer)
+               pfd.dwFlags |= PFD_STEREO;
+
        gldrivername = "opengl32.dll";
 // COMMANDLINEOPTION: Windows WGL: -gl_driver <drivername> selects a GL driver library, default is opengl32.dll, useful only for 3dfxogl.dll or 3dfxvgl.dll, if you don't know what this is for, you don't need it
        i = COM_CheckParm("-gl_driver");