]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_wgl.c
changed VID_InitMode to take a viddef_mode_t structure which contains
[xonotic/darkplaces.git] / vid_wgl.c
index b9b26732e281ce16cfc6290369586af880d47b21..1b6a27a1ef6624baac3a9d5b0acb1d4b1c7a37f2 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -17,10 +17,16 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 */
-// gl_vidnt.c -- NT GL vid component
+// vid_wgl.c -- NT GL vid component
 
-// we don't need a very new dinput
-#define DIRECTINPUT_VERSION 0x0300
+#ifdef SUPPORTDIRECTX
+// Include DX libs
+#pragma comment(lib, "dinput8.lib")
+#pragma comment(lib, "dxguid.lib")
+#ifndef DIRECTINPUT_VERSION
+#      define DIRECTINPUT_VERSION 0x0500  /* Version 5.0 */
+#endif
+#endif
 
 #include "quakedef.h"
 #include <windows.h>
@@ -251,7 +257,7 @@ void VID_Finish (void)
                qwglSwapIntervalEXT (vid_usevsync);
        }
 
-       if (r_render.integer && !vid_hidden)
+       if (!vid_hidden)
        {
                CHECKGLERROR
                if (r_speeds.integer == 2 || gl_finish.integer)
@@ -389,8 +395,8 @@ void AppActivate(BOOL fActive, BOOL minimize)
 {
        static qboolean sound_active = false;  // initially blocked by Sys_InitConsole()
 
-       vid_activewindow = fActive;
-       vid_hidden = minimize;
+       vid_activewindow = fActive != FALSE;
+       vid_hidden = minimize != FALSE;
 
        // enable/disable sound on focus gain/loss
        if ((!vid_hidden && vid_activewindow) || !snd_mutewhenidle.integer)
@@ -781,7 +787,7 @@ void VID_Init(void)
        IN_Init();
 }
 
-int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshrate, int stereobuffer, int samples)
+qboolean VID_InitMode(viddef_mode_t *mode)
 {
        int i;
        HDC hdc;
@@ -821,6 +827,13 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
        float *af;
        int attribs[128];
        float attribsf[16];
+       int bpp = mode->bitsperpixel;
+       int width = mode->width;
+       int height = mode->height;
+       int refreshrate = (int)floor(mode->refreshrate+0.5);
+       int stereobuffer = mode->stereobuffer;
+       int samples = mode->samples;
+       int fullscreen = mode->fullscreen;
 
        if (vid_initialized)
                Sys_Error("VID_InitMode called when video is already initialised");
@@ -922,8 +935,8 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
                        foundmode = true;
                        gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
                        gdevmode.dmBitsPerPel = bpp;
-                       gdevmode.dmPelsWidth = *width;
-                       gdevmode.dmPelsHeight = *height;
+                       gdevmode.dmPelsWidth = width;
+                       gdevmode.dmPelsHeight = height;
                        gdevmode.dmSize = sizeof (gdevmode);
                        if(refreshrate)
                        {
@@ -956,13 +969,13 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
                                                Con_Printf("wrong bpp\n");
                                        continue;
                                }
-                               if(thismode.dmPelsWidth != (DWORD)*width)
+                               if(thismode.dmPelsWidth != (DWORD)width)
                                {
                                        if(developer.integer >= 100)
                                                Con_Printf("wrong width\n");
                                        continue;
                                }
-                               if(thismode.dmPelsHeight != (DWORD)*height)
+                               if(thismode.dmPelsHeight != (DWORD)height)
                                {
                                        if(developer.integer >= 100)
                                                Con_Printf("wrong height\n");
@@ -1014,13 +1027,13 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
                if (!foundmode)
                {
                        VID_Shutdown();
-                       Con_Printf("Unable to find the requested mode %dx%dx%dbpp\n", *width, *height, bpp);
+                       Con_Printf("Unable to find the requested mode %dx%dx%dbpp\n", width, height, bpp);
                        return false;
                }
                else if(ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
                {
                        VID_Shutdown();
-                       Con_Printf("Unable to change to requested mode %dx%dx%dbpp\n", *width, *height, bpp);
+                       Con_Printf("Unable to change to requested mode %dx%dx%dbpp\n", width, height, bpp);
                        return false;
                }
 
@@ -1053,8 +1066,8 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
 
        rect.top = 0;
        rect.left = 0;
-       rect.right = *width;
-       rect.bottom = *height;
+       rect.right = width;
+       rect.bottom = height;
        AdjustWindowRectEx(&rect, WindowStyle, false, 0);
 
        if (fullscreen)
@@ -1209,8 +1222,6 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
        // fix the leftover Alt from any Alt-Tab or the like that switched us away
        ClearAllStates ();
 
-       gl_videosyncavailable = false;
-
 // COMMANDLINEOPTION: Windows WGL: -novideosync disables WGL_EXT_swap_control
        gl_videosyncavailable = GL_CheckExtension("WGL_EXT_swap_control", wglswapintervalfuncs, "-novideosync", false);
 
@@ -1229,8 +1240,8 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
 
        if (gl_videosyncavailable)
        {
-               vid_usevsync = vid_vsync.integer;
-               vid_usingvsync = vid_vsync.integer;
+               vid_usevsync = vid_vsync.integer != 0;
+               vid_usingvsync = vid_vsync.integer != 0;
                qwglSwapIntervalEXT (vid_usevsync);
        }
 
@@ -1302,7 +1313,7 @@ void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecurso
                                        newmouseparms[0] = 0; // threshold to double movement (only if accel level is >= 1)
                                        newmouseparms[1] = 0; // threshold to quadruple movement (only if accel level is >= 2)
                                        newmouseparms[2] = 0; // maximum level of acceleration (0 = off)
-                                       restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0);
+                                       restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0) != FALSE;
                                }
                                else
                                        restore_spi = false;
@@ -1378,7 +1389,7 @@ static qboolean IN_InitDInput (void)
 
        if (!pDirectInputCreate)
        {
-               pDirectInputCreate = (void *)GetProcAddress(hInstDI,"DirectInputCreateA");
+               pDirectInputCreate = (HRESULT (__stdcall *)(HINSTANCE,DWORD,LPDIRECTINPUT *,LPUNKNOWN))GetProcAddress(hInstDI,"DirectInputCreateA");
 
                if (!pDirectInputCreate)
                {
@@ -1396,7 +1407,11 @@ static qboolean IN_InitDInput (void)
        }
 
 // obtain an interface to the system mouse device.
+#ifdef __cplusplus
+       hr = IDirectInput_CreateDevice(g_pdi, GUID_SysMouse, &g_pMouse, NULL);
+#else
        hr = IDirectInput_CreateDevice(g_pdi, &GUID_SysMouse, &g_pMouse, NULL);
+#endif
 
        if (FAILED(hr))
        {
@@ -1652,7 +1667,7 @@ static void IN_StartupJoystick (void)
 
        // save the joystick's number of buttons and POV status
        joy_numbuttons = jc.wNumButtons;
-       joy_haspov = jc.wCaps & JOYCAPS_HASPOV;
+       joy_haspov = (jc.wCaps & JOYCAPS_HASPOV) != 0;
 
        // old button and POV states default to no buttons pressed
        joy_oldbuttonstate = joy_oldpovstate = 0;