#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)"};
//cvar_t vid_dx11 = {CVAR_SAVE, "vid_dx11", "1", "use Microsoft Direct3D11(r) for rendering"};
D3DPRESENT_PARAMETERS vid_d3dpresentparameters;
-#endif
-extern HINSTANCE global_hInstance;
+// 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;
-static HINSTANCE gldll;
-
-#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)
{
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