]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_wgl.c
disable USE_WSPIAPI_H by default, since it only works with -DSUPPORTIPV6
[xonotic/darkplaces.git] / vid_wgl.c
index 53153e02d5ee267c094db0dccaf842f32f11ec6e..832ceb05466ee099989d552b5f7c216044251257 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -48,9 +48,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #ifdef SUPPORTD3D
 #include <d3d9.h>
-#ifdef _MSC_VER
-#pragma comment(lib, "d3d9.lib")
-#endif
 
 cvar_t vid_dx9 = {CVAR_SAVE, "vid_dx9", "0", "use Microsoft Direct3D9(r) for rendering"};
 cvar_t vid_dx9_hal = {CVAR_SAVE, "vid_dx9_hal", "1", "enables hardware rendering (1), otherwise software reference rasterizer (0 - very slow), note that 0 is necessary when using NVPerfHUD (which renders in hardware but requires this option to enable it)"};
@@ -60,19 +57,19 @@ cvar_t vid_dx9_triplebuffer = {CVAR_SAVE, "vid_dx9_triplebuffer", "0", "enables
 //cvar_t vid_dx11 = {CVAR_SAVE, "vid_dx11", "1", "use Microsoft Direct3D11(r) for rendering"};
 
 D3DPRESENT_PARAMETERS vid_d3dpresentparameters;
-#endif
-
-extern HINSTANCE global_hInstance;
 
-static HINSTANCE gldll;
+// we declare this in vid_shared.c because it is required by dedicated server and all clients when SUPPORTD3D is defined
+extern LPDIRECT3DDEVICE9 vid_d3d9dev;
 
-#ifdef SUPPORTD3D
 LPDIRECT3D9 vid_d3d9;
-LPDIRECT3DDEVICE9 vid_d3d9dev;
 D3DCAPS9 vid_d3d9caps;
 qboolean vid_d3ddevicelost;
 #endif
 
+extern HINSTANCE global_hInstance;
+
+static HINSTANCE gldll;
+
 #ifndef WM_MOUSEWHEEL
 #define WM_MOUSEWHEEL                   0x020A
 #endif
@@ -1208,7 +1205,7 @@ qboolean VID_InitModeGL(viddef_mode_t *mode)
                mainwindow = CreateWindowEx (ExWindowStyle, "DarkPlacesWindowClass", gamename, WindowStyle, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, global_hInstance, NULL);
                if (!mainwindow)
                {
-                       Con_Printf("CreateWindowEx(%d, %s, %s, %d, %d, %d, %d, %d, %p, %p, %p, %p) failed\n", (int)ExWindowStyle, "DarkPlacesWindowClass", gamename, (int)WindowStyle, (int)(rect.left), (int)(rect.top), (int)(rect.right - rect.left), (int)(rect.bottom - rect.top), NULL, NULL, global_hInstance, NULL);
+                       Con_Printf("CreateWindowEx(%d, %s, %s, %d, %d, %d, %d, %d, %p, %p, %p, %p) failed\n", (int)ExWindowStyle, "DarkPlacesWindowClass", gamename, (int)WindowStyle, (int)(rect.left), (int)(rect.top), (int)(rect.right - rect.left), (int)(rect.bottom - rect.top), (void *)NULL, (void *)NULL, (void *)global_hInstance, (void *)NULL);
                        VID_Shutdown();
                        return false;
                }
@@ -1221,14 +1218,14 @@ qboolean VID_InitModeGL(viddef_mode_t *mode)
                if (!pixelformat)
                {
                        VID_Shutdown();
-                       Con_Printf("ChoosePixelFormat(%p, %p) failed\n", baseDC, &pfd);
+                       Con_Printf("ChoosePixelFormat(%p, %p) failed\n", (void *)baseDC, (void *)&pfd);
                        return false;
                }
 
                if (SetPixelFormat(baseDC, pixelformat, &pfd) == false)
                {
                        VID_Shutdown();
-                       Con_Printf("SetPixelFormat(%p, %d, %p) failed\n", baseDC, pixelformat, &pfd);
+                       Con_Printf("SetPixelFormat(%p, %d, %p) failed\n", (void *)baseDC, pixelformat, (void *)&pfd);
                        return false;
                }
 
@@ -1249,7 +1246,7 @@ qboolean VID_InitModeGL(viddef_mode_t *mode)
                if (!qwglMakeCurrent(baseDC, baseRC))
                {
                        VID_Shutdown();
-                       Con_Printf("wglMakeCurrent(%p, %p) failed\n", baseDC, baseRC);
+                       Con_Printf("wglMakeCurrent(%p, %p) failed\n", (void *)baseDC, (void *)baseRC);
                        return false;
                }
 
@@ -1430,7 +1427,7 @@ qboolean VID_InitModeDX(viddef_mode_t *mode, int version)
        mainwindow = CreateWindowEx (ExWindowStyle, "DarkPlacesWindowClass", gamename, WindowStyle, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, global_hInstance, NULL);
        if (!mainwindow)
        {
-               Con_Printf("CreateWindowEx(%d, %s, %s, %d, %d, %d, %d, %d, %p, %p, %p, %p) failed\n", (int)ExWindowStyle, "DarkPlacesWindowClass", gamename, (int)WindowStyle, (int)(rect.left), (int)(rect.top), (int)(rect.right - rect.left), (int)(rect.bottom - rect.top), NULL, NULL, global_hInstance, NULL);
+               Con_Printf("CreateWindowEx(%d, %s, %s, %d, %d, %d, %d, %d, %p, %p, %p, %p) failed\n", (int)ExWindowStyle, "DarkPlacesWindowClass", gamename, (int)WindowStyle, (int)(rect.left), (int)(rect.top), (int)(rect.right - rect.left), (int)(rect.bottom - rect.top), (void *)NULL, (void *)NULL, global_hInstance, (void *)NULL);
                VID_Shutdown();
                return false;
        }
@@ -1513,10 +1510,10 @@ qboolean VID_InitModeDX(viddef_mode_t *mode, int version)
 
        Con_Printf("D3D9 adapter info:\n");
        Con_Printf("Description: %s\n", d3d9adapteridentifier.Description);
-       Con_Printf("DeviceId: %x\n", d3d9adapteridentifier.DeviceId);
-       Con_Printf("DeviceName: %x\n", d3d9adapteridentifier.DeviceName);
+       Con_Printf("DeviceId: %x\n", (unsigned int)d3d9adapteridentifier.DeviceId);
+       Con_Printf("DeviceName: %p\n", d3d9adapteridentifier.DeviceName);
        Con_Printf("Driver: %s\n", d3d9adapteridentifier.Driver);
-       Con_Printf("DriverVersion: %x\n", d3d9adapteridentifier.DriverVersion);
+       Con_Printf("DriverVersion: %08x%08x\n", (unsigned int)d3d9adapteridentifier.DriverVersion.u.HighPart, (unsigned int)d3d9adapteridentifier.DriverVersion.u.LowPart);
        Con_DPrintf("GL_EXTENSIONS: %s\n", gl_extensions);
        Con_DPrintf("%s_EXTENSIONS: %s\n", gl_platform, gl_platformextensions);
 
@@ -1904,57 +1901,31 @@ static void IN_MouseMove (void)
 
                        /* Look at the element to see what happened */
 
-                       switch (od.dwOfs)
+                       if ((int)od.dwOfs == DIMOFS_X)
+                               in_mouse_x += (LONG) od.dwData;
+                       if ((int)od.dwOfs == DIMOFS_Y)
+                               in_mouse_y += (LONG) od.dwData;
+                       if ((int)od.dwOfs == DIMOFS_Z)
                        {
-                               case DIMOFS_X:
-                                       in_mouse_x += (LONG) od.dwData;
-                                       break;
-
-                               case DIMOFS_Y:
-                                       in_mouse_y += (LONG) od.dwData;
-                                       break;
-
-                               case DIMOFS_Z:
-                                       if((LONG) od.dwData < 0)
-                                       {
-                                               Key_Event (K_MWHEELDOWN, 0, true);
-                                               Key_Event (K_MWHEELDOWN, 0, false);
-                                       }
-                                       else if((LONG) od.dwData > 0)
-                                       {
-                                               Key_Event (K_MWHEELUP, 0, true);
-                                               Key_Event (K_MWHEELUP, 0, false);
-                                       }
-                                       break;
-
-                               case DIMOFS_BUTTON0:
-                                       if (od.dwData & 0x80)
-                                               mstate_di |= 1;
-                                       else
-                                               mstate_di &= ~1;
-                                       break;
-
-                               case DIMOFS_BUTTON1:
-                                       if (od.dwData & 0x80)
-                                               mstate_di |= (1<<1);
-                                       else
-                                               mstate_di &= ~(1<<1);
-                                       break;
-
-                               case DIMOFS_BUTTON2:
-                                       if (od.dwData & 0x80)
-                                               mstate_di |= (1<<2);
-                                       else
-                                               mstate_di &= ~(1<<2);
-                                       break;
-
-                               case DIMOFS_BUTTON3:
-                                       if (od.dwData & 0x80)
-                                               mstate_di |= (1<<3);
-                                       else
-                                               mstate_di &= ~(1<<3);
-                                       break;
+                               if((LONG)od.dwData < 0)
+                               {
+                                       Key_Event(K_MWHEELDOWN, 0, true);
+                                       Key_Event(K_MWHEELDOWN, 0, false);
+                               }
+                               else if((LONG)od.dwData > 0)
+                               {
+                                       Key_Event(K_MWHEELUP, 0, true);
+                                       Key_Event(K_MWHEELUP, 0, false);
+                               }
                        }
+                       if ((int)od.dwOfs == DIMOFS_BUTTON0)
+                               mstate_di = (mstate_di & ~1) | ((od.dwData & 0x80) >> 7);
+                       if ((int)od.dwOfs == DIMOFS_BUTTON1)
+                               mstate_di = (mstate_di & ~2) | ((od.dwData & 0x80) >> 6);
+                       if ((int)od.dwOfs == DIMOFS_BUTTON2)
+                               mstate_di = (mstate_di & ~4) | ((od.dwData & 0x80) >> 5);
+                       if ((int)od.dwOfs == DIMOFS_BUTTON3)
+                               mstate_di = (mstate_di & ~8) | ((od.dwData & 0x80) >> 4);
                }
 
                // perform button actions