]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Added vid_vsync cvar and also to put it in the video options menu.
authortomaz <tomaz@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 11 Sep 2004 22:02:20 +0000 (22:02 +0000)
committertomaz <tomaz@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 11 Sep 2004 22:02:20 +0000 (22:02 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4485 d7cf8633-e32d-0410-b094-e92efae38249

menu.c
vid.h
vid_shared.c
vid_wgl.c

diff --git a/menu.c b/menu.c
index 3c3c5e5437d1fc41443b434db8e386963c5710ae..c4de8c306ff3358bc4d72693211ec7b14957109a 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -2365,10 +2365,10 @@ void M_Keys_Key (int k, char ascii)
 //=============================================================================
 /* VIDEO MENU */
 
-#define VIDEO_ITEMS 4
+#define VIDEO_ITEMS 5
 
 int video_cursor = 0;
-int video_cursor_table[] = {56, 68, 80, 100};
+int video_cursor_table[] = {56, 68, 80, 100, 120};
 // note: if modes are added to the beginning of this list, update the
 // video_resolution = x; in M_Menu_Video_f below
 unsigned short video_resolutions[][2] = {{320,240}, {400,300}, {512,384}, {640,480}, {800,600}, {1024,768}, {1152,864}, {1280,960}, {1280,1024}, {1600,1200}, {1792,1344}, {1920,1440}, {2048,1536}, {0,0}};
@@ -2435,6 +2435,10 @@ void M_Video_Draw (void)
        // "Apply" button
        M_Print(220, video_cursor_table[3], "Apply");
 
+       // Vertical Sync
+       M_Print(16, video_cursor_table[4], "         Vertical Sync");
+       M_DrawCheckbox(220, video_cursor_table[4], vid_vsync.integer);
+
        // Cursor
        M_DrawCharacter(200, video_cursor_table[video_cursor], 12+((int)(realtime*4)&1));
 }
@@ -2469,6 +2473,10 @@ void M_Menu_Video_AdjustSliders (int dir)
                case 2:
                        Cvar_SetValueQuick (&vid_fullscreen, !vid_fullscreen.integer);
                        break;
+
+               case 4:
+                       Cvar_SetValueQuick (&vid_vsync, !vid_vsync.integer);
+                       break;
        }
 }
 
diff --git a/vid.h b/vid.h
index 5325f9d363df8dce21c469133490d31f3a535d42..3ab176142c232e05b26a80042fd361fa41167e17 100644 (file)
--- a/vid.h
+++ b/vid.h
@@ -50,6 +50,7 @@ extern cvar_t vid_fullscreen;
 extern cvar_t vid_width;
 extern cvar_t vid_height;
 extern cvar_t vid_bitsperpixel;
+extern cvar_t vid_vsync;
 extern cvar_t vid_mouse;
 
 extern cvar_t gl_combine;
index 8851e21da2978228498af2c60197de5b7c2c7b4b..93262be97bfbedb3fa4777dc9e270164215c58d3 100644 (file)
@@ -71,6 +71,7 @@ cvar_t vid_width = {CVAR_SAVE, "vid_width", "640"};
 cvar_t vid_height = {CVAR_SAVE, "vid_height", "480"};
 cvar_t vid_bitsperpixel = {CVAR_SAVE, "vid_bitsperpixel", "32"};
 
+cvar_t vid_vsync = {CVAR_SAVE, "vid_vsync", "1"};
 cvar_t vid_mouse = {CVAR_SAVE, "vid_mouse", "1"};
 cvar_t gl_combine = {CVAR_SAVE, "gl_combine", "1"};
 cvar_t gl_finish = {0, "gl_finish", "0"};
@@ -971,6 +972,7 @@ void VID_Shared_Init(void)
        Cvar_RegisterVariable(&vid_width);
        Cvar_RegisterVariable(&vid_height);
        Cvar_RegisterVariable(&vid_bitsperpixel);
+       Cvar_RegisterVariable(&vid_vsync);
        Cvar_RegisterVariable(&vid_mouse);
        Cvar_RegisterVariable(&gl_combine);
        Cvar_RegisterVariable(&gl_finish);
index ffdc689db51a025614b6531481fb188e0fee28b1..afa865cffb96037d45e11cb2eeeb1b3aeb8c9990 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -305,6 +305,15 @@ void VID_Finish (void)
 {
        HDC hdc;
        int vid_usemouse;
+       static int      old_vsync       = -1;
+
+       if (old_vsync != vid_vsync.integer)
+       {
+               old_vsync = bound(0, vid_vsync.integer, 1);
+               Cvar_SetValueQuick(&vid_vsync, old_vsync);
+               qwglSwapIntervalEXT (old_vsync);
+       }
+
        if (r_render.integer && !scr_skipupdate)
        {
                if (r_speeds.integer || gl_finish.integer)