*/
// vid_wgl.c -- NT GL vid component
+#ifdef _MSC_VER
#pragma comment(lib, "comctl32.lib")
+#endif
#ifdef SUPPORTDIRECTX
// Include DX libs
+#ifdef _MSC_VER
#pragma comment(lib, "dinput8.lib")
#pragma comment(lib, "dxguid.lib")
+#endif
#ifndef DIRECTINPUT_VERSION
# define DIRECTINPUT_VERSION 0x0500 /* Version 5.0 */
#endif
#ifdef SUPPORTD3D
#include <d3d9.h>
-#pragma comment(lib, "d3d9.lib")
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)"};
//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
#ifdef SUPPORTD3D
if (vid_d3d9dev)
{
- DWORD d;
+ HRESULT hr;
if (vid_begunscene)
{
IDirect3DDevice9_EndScene(vid_d3d9dev);
}
if (vid_reallyhidden)
return;
- d = IDirect3DDevice9_TestCooperativeLevel(vid_d3d9dev);
- switch(d)
+ if (!vid_d3ddevicelost)
{
- case D3DERR_DEVICELOST:
- vid_d3ddevicelost = true;
- vid_hidden = true;
- Sleep(100);
- break;
- case D3DERR_DEVICENOTRESET:
- vid_d3ddevicelost = false;
- vid_hidden = vid_reallyhidden;
- R_Modules_DeviceLost();
- IDirect3DDevice9_Reset(vid_d3d9dev, &vid_d3dpresentparameters);
- R_Modules_DeviceRestored();
- break;
- case D3D_OK:
vid_hidden = vid_reallyhidden;
- IDirect3DDevice9_Present(vid_d3d9dev, NULL, NULL, NULL, NULL);
- break;
+ hr = IDirect3DDevice9_Present(vid_d3d9dev, NULL, NULL, NULL, NULL);
+ if (hr == D3DERR_DEVICELOST)
+ {
+ vid_d3ddevicelost = true;
+ vid_hidden = true;
+ Sleep(100);
+ }
+ }
+ else
+ {
+ hr = IDirect3DDevice9_TestCooperativeLevel(vid_d3d9dev);
+ switch(hr)
+ {
+ case D3DERR_DEVICELOST:
+ vid_d3ddevicelost = true;
+ vid_hidden = true;
+ Sleep(100);
+ break;
+ case D3DERR_DEVICENOTRESET:
+ vid_d3ddevicelost = false;
+ vid_hidden = vid_reallyhidden;
+ R_Modules_DeviceLost();
+ IDirect3DDevice9_Reset(vid_d3d9dev, &vid_d3dpresentparameters);
+ R_Modules_DeviceRestored();
+ break;
+ case D3D_OK:
+ vid_hidden = vid_reallyhidden;
+ IDirect3DDevice9_Present(vid_d3d9dev, NULL, NULL, NULL, NULL);
+ break;
+ }
}
if (!vid_begunscene && !vid_hidden)
{
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;
}
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;
}
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;
}
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;
}
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);
CHECKGLERROR
- vid.forcevbo = true;
+ vid.forcevbo = false;
vid.support.arb_depth_texture = true;
vid.support.arb_draw_buffers = vid_d3d9caps.NumSimultaneousRTs > 1;
vid.support.arb_occlusion_query = true; // can't find a cap for this
/* 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