]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
this commit adds video mode switching, and preferred mode is saved to config, no...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 26 Sep 2002 01:24:41 +0000 (01:24 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 26 Sep 2002 01:24:41 +0000 (01:24 +0000)
IN_Init and IN_Shutdown code has been merged into VID_InitMode and VID_Shutdown code in each of the video systems
VID_InitCvars renamed to VID_Shared_Init
VID_Open and VID_Close functions added in vid_shared, Host_Init now calls VID_Open
S_Open/Close and CDAudio_Open/Close added (none of these do anything yet)
VID_Open and VID_Close call R_Modules_Start, S_Open, and CDAudio_Open and their corresponding Close functions
VID_Restart_f added (vid_restart command)
vid_hidden now starts true (to avoid any refreshs until video is started)
vid_fullscreen/width/height/bitsperpixel are now saved to config
VID_Open is called after configs are parsed
Render_Init now longer starts/stops modules
IN_MouseEvent in vid_wgl.c no longer clamps pitch (since that's done by IN_PostMove)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2442 d7cf8633-e32d-0410-b094-e92efae38249

18 files changed:
cd_linux.c
cd_null.c
cd_win.c
cdaudio.h
gl_rmain.c
host.c
input.h
snd_alsa_0_5.c
snd_alsa_0_9.c
snd_null.c
snd_oss.c
snd_win.c
sound.h
vid.h
vid_glx.c
vid_null.c
vid_shared.c
vid_wgl.c

index 7ee7918916e3829bb61da0c781d8da5320f42486..eb8ef45f0abf11570930783c31625b0f78feaf12 100644 (file)
@@ -418,3 +418,10 @@ void CDAudio_Shutdown(void)
        cdfile = -1;
 }
 
+void CDAudio_Open(void)
+{
+}
+
+void CDAudio_Close(void)
+{
+}
index 4d6667d3bf7a27d8cd85d26ac15f8fc1447e03db..f9eb413dcaafb866b992a8bb284998f90e588f2b 100644 (file)
--- a/cd_null.c
+++ b/cd_null.c
@@ -56,3 +56,11 @@ void CDAudio_Shutdown(void)
 {
 }
 
+
+void CDAudio_Open(void)
+{
+}
+
+void CDAudio_Close(void)
+{
+}
index d31b72e8a5ad8d3478647931edb481099c999c99..8d9f56841fa1a305412fcd5fd9b7f707986eb24a 100644 (file)
--- a/cd_win.c
+++ b/cd_win.c
@@ -475,3 +475,11 @@ void CDAudio_Shutdown(void)
                Con_DPrintf("CDAudio_Shutdown: MCI_CLOSE failed\n");
 }
 
+
+void CDAudio_Open(void)
+{
+}
+
+void CDAudio_Close(void)
+{
+}
index 09c0d3002a3aa1b71a514837f4f01ba772d05c35..f3191d634aad800842a0d7a9455e0810a10d57d6 100644 (file)
--- a/cdaudio.h
+++ b/cdaudio.h
@@ -19,6 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 
 int CDAudio_Init(void);
+void CDAudio_Open(void);
+void CDAudio_Close(void);
 void CDAudio_Play(qbyte track, qboolean looping);
 void CDAudio_Stop(void);
 void CDAudio_Pause(void);
index 5552b0cb0140034245e448b2e14ef2e81c61b5d0..e17054dd774580a7dc0d6831d6d4efc308bc5ec5 100644 (file)
@@ -293,7 +293,6 @@ extern void Sbar_Init(void);
 
 void Render_Init(void)
 {
-       R_Modules_Shutdown();
        R_Textures_Init();
        Mod_RenderInit();
        gl_backend_init();
@@ -309,7 +308,6 @@ void Render_Init(void)
        R_Explosion_Init();
        ui_init();
        Sbar_Init();
-       R_Modules_Start();
 }
 
 /*
diff --git a/host.c b/host.c
index 42dca46c48112363dcabc8124e198c1125fa47e0..55aa68689643ba31d70ee1446be235d2517afd5b 100644 (file)
--- a/host.c
+++ b/host.c
@@ -881,42 +881,29 @@ void Host_Init (void)
 
        if (cls.state != ca_dedicated)
        {
-               VID_InitCvars();
-
                Gamma_Init();
-
                Palette_Init();
-
-#ifndef _WIN32 // on non win32, mouse comes before video for security reasons
-               IN_Init ();
-#endif
+               VID_Shared_Init();
                VID_Init();
-               if (!VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer))
-               {
-                       if (vid_fullscreen.integer)
-                       {
-                               if (!VID_Mode(true, 640, 480, 16))
-                                       if (!VID_Mode(false, 640, 480, 16))
-                                               Sys_Error("Video modes failed\n");
-                       }
-                       else
-                               Sys_Error("Requested windowed video mode failed\n");
-               }
 
                Render_Init();
                S_Init ();
                CDAudio_Init ();
                CL_Init ();
-#ifdef _WIN32 // on non win32, mouse comes before video for security reasons
-               IN_Init ();
-#endif
        }
 
        Cbuf_InsertText ("exec quake.rc\n");
+       Cbuf_Execute ();
+       Cbuf_Execute ();
+       Cbuf_Execute ();
+       Cbuf_Execute ();
 
        host_initialized = true;
        
-       Sys_Printf ("========Quake Initialized=========\n");    
+       Con_Printf ("========Quake Initialized=========\n");    
+
+       if (cls.state != ca_dedicated)
+               VID_Open();
 }
 
 
@@ -944,7 +931,6 @@ void Host_Shutdown(void)
        CDAudio_Shutdown ();
        NET_Shutdown ();
        S_Shutdown();
-       IN_Shutdown ();
 
        if (cls.state != ca_dedicated)
        {
diff --git a/input.h b/input.h
index 9bff65e8c92558e435ed16906ef56bc0fb57acf6..30f76ef56fe80ae01fb03aa15bfc1137b7d38909 100644 (file)
--- a/input.h
+++ b/input.h
@@ -25,10 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 extern cvar_t in_pitch_min;
 extern cvar_t in_pitch_max;
 
-void IN_Init (void);
-
-void IN_Shutdown (void);
-
 void IN_Commands (void);
 // oportunity for devices to stick commands on the script buffer
 
index 1522429fada8844fbcb362703fbbadd012dfe257..082fbe5033d1a633bcd84f47aa30084b069294d3 100644 (file)
@@ -341,3 +341,11 @@ void *S_LockBuffer(void)
 void S_UnlockBuffer(void)
 {
 }
+
+void S_Open(void)
+{
+}
+
+void S_Close(void)
+{
+}
index 0e05ef88c2ea0bb0447ae9d8945641bd6c57d169..3d4129dd847a418ab25be5398653b610fcd738b6 100644 (file)
@@ -314,3 +314,11 @@ void S_UnlockBuffer(void)
 {
 }
 
+
+void S_Open(void)
+{
+}
+
+void S_Close(void)
+{
+}
index 546b0e8af5a54db42d8f9ee1149ac064ce9bd098..e699ac565313fec746773e8e85a0ae1bb1f1cec2 100755 (executable)
@@ -123,3 +123,12 @@ int S_RawSamples_SampleRate(void)
 {
        return 0;
 }
+
+
+void S_Open(void)
+{
+}
+
+void S_Close(void)
+{
+}
index 14fe64efbdfba7a39e2e1e33283724b0e0627c97..c939d7441904c588197b08c8365001bcd025ffc7 100644 (file)
--- a/snd_oss.c
+++ b/snd_oss.c
@@ -277,3 +277,12 @@ void *S_LockBuffer(void)
 void S_UnlockBuffer(void)
 {
 }
+
+
+void S_Open(void)
+{
+}
+
+void S_Close(void)
+{
+}
index 2fed37be8279b8dda4ac6dcdf30e56f7e9a7f2ae..ef6703658f01c0590b20b27cf4af701691dd6af1 100644 (file)
--- a/snd_win.c
+++ b/snd_win.c
@@ -766,9 +766,16 @@ void *S_LockBuffer(void)
                return shm->buffer;
 }
 
-void S_UnlockBuffer()
+void S_UnlockBuffer(void)
 {
        if (pDSBuf)
                pDSBuf->lpVtbl->Unlock(pDSBuf, dsound_pbuf, dsound_dwSize, dsound_pbuf2, dsound_dwSize2);
 }
 
+void S_Open(void)
+{
+}
+
+void S_Close(void)
+{
+}
diff --git a/sound.h b/sound.h
index e20714bffb593cf61d065a258e3a9f329b6b55ab..684102eece285082e775d662d857da8e09af6d3e 100644 (file)
--- a/sound.h
+++ b/sound.h
@@ -90,6 +90,8 @@ typedef struct
 void S_Init (void);
 void S_Startup (void);
 void S_Shutdown (void);
+void S_Open (void);
+void S_Close (void);
 void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol,  float attenuation);
 void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation);
 void S_StopSound (int entnum, int entchannel);
diff --git a/vid.h b/vid.h
index 6c23c88b1490b9d2210238eccccc36a56c88134d..0b83a0276defdb9a3256fb26bf351e424562525b 100644 (file)
--- a/vid.h
+++ b/vid.h
@@ -94,7 +94,7 @@ void GL_CloseLibrary(void);
 void *GL_GetProcAddress(const char *name);
 int GL_CheckExtension(const char *name, const gl_extensionfunctionlist_t *funcs, const char *disableparm, int silent);
 
-void VID_InitCvars(void);
+void VID_Shared_Init(void);
 
 void GL_Init (void);
 
@@ -119,5 +119,10 @@ void VID_GetWindowSize (int *x, int *y, int *width, int *height);
 
 void VID_Finish (void);
 
+void VID_Restart_f(void);
+
+void VID_Open (void);
+void VID_Close (void);
+
 #endif
 
index 706cb5fda9f8d34269efefaa1fdb30b6fd7f1d8c..0ebdedac986f410536099a376e8430e59a63ab5f 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -474,6 +474,7 @@ void VID_Shutdown(void)
        if (!ctx || !vidx11_display)
                return;
 
+       vid_hidden = true;
        if (vidx11_display)
        {
                uninstall_grabs();
@@ -639,6 +640,8 @@ void VID_Init(void)
        Cvar_RegisterVariable (&vid_dga);
        Cvar_RegisterVariable (&vid_dga_mouseaccel);
        InitSig(); // trap evil signals
+       if (COM_CheckParm ("-nomouse") || COM_CheckParm("-safe"))
+               mouse_avail = false;
 }
 
 int VID_InitMode(int fullscreen, int width, int height, int bpp)
@@ -842,16 +845,6 @@ void Sys_SendKeyEvents(void)
        HandleEvents();
 }
 
-void IN_Init(void)
-{
-       if (COM_CheckParm ("-nomouse") || COM_CheckParm("-safe"))
-               mouse_avail = false;
-}
-
-void IN_Shutdown(void)
-{
-}
-
 /*
 ===========
 IN_Commands
index 20e824846cd241e0ddbbc893ec60ce0c56bee0b2..5505ea67910d511d4cd6fcfc2976e3594096b620 100644 (file)
@@ -96,14 +96,6 @@ void IN_Commands(void)
 {
 }
 
-void IN_Init(void)
-{
-}
-
-void IN_Shutdown(void)
-{
-}
-
 void IN_Move(usercmd_t *cmd)
 {
 }
index 5cc2ed07b24577e7828eeb23ad5cb0177cf1fb9a..6fb1f5c0fb764477dceccd332d2eade503e406e6 100644 (file)
@@ -18,15 +18,15 @@ int gl_supportslockarrays = false;
 int gl_videosyncavailable = false;
 
 // LordHavoc: if window is hidden, don't update screen
-int vid_hidden = false;
+int vid_hidden = true;
 // LordHavoc: if window is not the active window, don't hog as much CPU time,
 // let go of the mouse, turn off sound, and restore system gamma ramps...
 int vid_activewindow = true;
 
-cvar_t vid_fullscreen = {0, "vid_fullscreen", "1"};
-cvar_t vid_width = {0, "vid_width", "640"};
-cvar_t vid_height = {0, "vid_height", "480"};
-cvar_t vid_bitsperpixel = {0, "vid_bitsperpixel", "16"};
+cvar_t vid_fullscreen = {CVAR_SAVE, "vid_fullscreen", "1"};
+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", "16"};
 
 cvar_t vid_mouse = {CVAR_SAVE, "vid_mouse", "1"};
 cvar_t gl_combine = {0, "gl_combine", "1"};
@@ -393,7 +393,7 @@ void IN_Mouse(usercmd_t *cmd, float mx, float my)
        }
 }
 
-void VID_InitCvars(void)
+void VID_Shared_Init(void)
 {
        int i;
 
@@ -407,6 +407,7 @@ void VID_InitCvars(void)
        Cvar_RegisterVariable(&in_pitch_max);
        Cvar_RegisterVariable(&m_filter);
        Cmd_AddCommand("force_centerview", Force_CenterView_f);
+       Cmd_AddCommand("vid_restart", VID_Restart_f);
 
 // interpret command-line parameters
        if ((i = COM_CheckParm("-window")) != 0)
@@ -421,6 +422,10 @@ void VID_InitCvars(void)
                Cvar_SetQuick(&vid_bitsperpixel, com_argv[i+1]);
 }
 
+int current_vid_fullscreen;
+int current_vid_width;
+int current_vid_height;
+int current_vid_bitsperpixel;
 extern int VID_InitMode (int fullscreen, int width, int height, int bpp);
 int VID_Mode(int fullscreen, int width, int height, int bpp)
 {
@@ -429,7 +434,65 @@ int VID_Mode(int fullscreen, int width, int height, int bpp)
        else
                Con_Printf("Video: %dx%d windowed\n", width, height);
        if (VID_InitMode(fullscreen, width, height, bpp))
+       {
+               current_vid_fullscreen = fullscreen;
+               current_vid_width = width;
+               current_vid_height = height;
+               current_vid_bitsperpixel = bpp;
                return true;
+       }
        else
                return false;
 }
+
+static void VID_OpenSystems(void)
+{
+       R_Modules_Start();
+       S_Open();
+       CDAudio_Open();
+}
+
+static void VID_CloseSystems(void)
+{
+       CDAudio_Close();
+       S_Close();
+       R_Modules_Shutdown();
+}
+
+void VID_Restart_f(void)
+{
+       Con_Printf("VID_Restart: changing from %s %dx%dx%dbpp, to %s %dx%dx%dbpp.\n",
+               current_vid_fullscreen ? "fullscreen" : "window", current_vid_width, current_vid_height, current_vid_bitsperpixel, 
+               vid_fullscreen.integer ? "fullscreen" : "window", vid_width.integer, vid_height.integer, vid_bitsperpixel.integer);
+       VID_Close();
+       if (!VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer))
+       {
+               Con_Printf("Video mode change failed\n");
+               if (!VID_Mode(current_vid_fullscreen, current_vid_width, current_vid_height, current_vid_bitsperpixel))
+                       Sys_Error("Unable to restore to last working video mode\n");
+       }
+       VID_OpenSystems();
+}
+
+void VID_Open(void)
+{
+       Con_Printf("Starting video system\n");
+       if (!VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer))
+       {
+               if (vid_fullscreen.integer)
+               {
+                       if (!VID_Mode(true, 640, 480, 16))
+                               if (!VID_Mode(false, 640, 480, 16))
+                                       Sys_Error("Video modes failed\n");
+               }
+               else
+                       Sys_Error("Windowed video failed\n");
+       }
+       VID_OpenSystems();
+}
+
+void VID_Close(void)
+{
+       VID_CloseSystems();
+       VID_Shutdown();
+}
index 571b5ad72d97d21f13d80ecd985d4e2991f18f8e..d93961282c6fe749d44755d8504b64fdafd5a723 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -645,6 +645,30 @@ void VID_Init(void)
 
        if (!RegisterClass (&wc))
                Sys_Error("Couldn't register window class\n");
+
+       uiWheelMessage = RegisterWindowMessage ( "MSWHEEL_ROLLMSG" );
+
+       // joystick variables
+       Cvar_RegisterVariable (&in_joystick);
+       Cvar_RegisterVariable (&joy_name);
+       Cvar_RegisterVariable (&joy_advanced);
+       Cvar_RegisterVariable (&joy_advaxisx);
+       Cvar_RegisterVariable (&joy_advaxisy);
+       Cvar_RegisterVariable (&joy_advaxisz);
+       Cvar_RegisterVariable (&joy_advaxisr);
+       Cvar_RegisterVariable (&joy_advaxisu);
+       Cvar_RegisterVariable (&joy_advaxisv);
+       Cvar_RegisterVariable (&joy_forwardthreshold);
+       Cvar_RegisterVariable (&joy_sidethreshold);
+       Cvar_RegisterVariable (&joy_pitchthreshold);
+       Cvar_RegisterVariable (&joy_yawthreshold);
+       Cvar_RegisterVariable (&joy_forwardsensitivity);
+       Cvar_RegisterVariable (&joy_sidesensitivity);
+       Cvar_RegisterVariable (&joy_pitchsensitivity);
+       Cvar_RegisterVariable (&joy_yawsensitivity);
+       Cvar_RegisterVariable (&joy_wwhack1);
+       Cvar_RegisterVariable (&joy_wwhack2);
+       Cmd_AddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f);
 }
 
 int VID_InitMode (int fullscreen, int width, int height, int bpp)
@@ -878,6 +902,10 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp)
        //vid_menukeyfn = VID_MenuKey;
        vid_hidden = false;
        vid_initialized = true;
+       
+       IN_StartupMouse ();
+       IN_StartupJoystick ();
+       
        return true;
 }
 
@@ -889,8 +917,21 @@ void VID_Shutdown (void)
        if (vid_initialized)
        {
                vid_initialized = false;
+               
+               IN_DeactivateMouse ();
+               IN_ShowMouse ();
+
+               if (g_pMouse)
+                       IDirectInputDevice_Release(g_pMouse);
+               g_pMouse = NULL;
+               
+               if (g_pdi)
+                       IDirectInput_Release(g_pdi);
+               g_pdi = NULL;
+
                if (qwglGetCurrentContext)
                        hRC = qwglGetCurrentContext();
+               
                if (qwglGetCurrentDC)
                        hDC = qwglGetCurrentDC();
 
@@ -1313,66 +1354,6 @@ void IN_StartupMouse (void)
 }
 
 
-/*
-===========
-IN_Init
-===========
-*/
-void IN_Init (void)
-{
-       // joystick variables
-       Cvar_RegisterVariable (&in_joystick);
-       Cvar_RegisterVariable (&joy_name);
-       Cvar_RegisterVariable (&joy_advanced);
-       Cvar_RegisterVariable (&joy_advaxisx);
-       Cvar_RegisterVariable (&joy_advaxisy);
-       Cvar_RegisterVariable (&joy_advaxisz);
-       Cvar_RegisterVariable (&joy_advaxisr);
-       Cvar_RegisterVariable (&joy_advaxisu);
-       Cvar_RegisterVariable (&joy_advaxisv);
-       Cvar_RegisterVariable (&joy_forwardthreshold);
-       Cvar_RegisterVariable (&joy_sidethreshold);
-       Cvar_RegisterVariable (&joy_pitchthreshold);
-       Cvar_RegisterVariable (&joy_yawthreshold);
-       Cvar_RegisterVariable (&joy_forwardsensitivity);
-       Cvar_RegisterVariable (&joy_sidesensitivity);
-       Cvar_RegisterVariable (&joy_pitchsensitivity);
-       Cvar_RegisterVariable (&joy_yawsensitivity);
-       Cvar_RegisterVariable (&joy_wwhack1);
-       Cvar_RegisterVariable (&joy_wwhack2);
-
-       Cmd_AddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f);
-
-       uiWheelMessage = RegisterWindowMessage ( "MSWHEEL_ROLLMSG" );
-
-       IN_StartupMouse ();
-       IN_StartupJoystick ();
-}
-
-/*
-===========
-IN_Shutdown
-===========
-*/
-void IN_Shutdown (void)
-{
-       IN_DeactivateMouse ();
-       IN_ShowMouse ();
-
-    if (g_pMouse)
-       {
-               IDirectInputDevice_Release(g_pMouse);
-               g_pMouse = NULL;
-       }
-
-    if (g_pdi)
-       {
-               IDirectInput_Release(g_pdi);
-               g_pdi = NULL;
-       }
-}
-
-
 /*
 ===========
 IN_MouseEvent
@@ -1529,8 +1510,6 @@ void IN_Move (usercmd_t *cmd)
                IN_MouseMove (cmd);
                IN_JoyMove (cmd);
        }
-
-       cl.viewangles[PITCH] = bound (in_pitch_min.value, cl.viewangles[PITCH], in_pitch_max.value);
 }