2009-11-04 21:44:48 +00:00
|
|
|
#include "quakedef.h"
|
|
|
|
#include "gl_draw.h"
|
|
|
|
#include "shader.h"
|
2010-11-02 23:17:25 +00:00
|
|
|
#include "renderque.h"
|
2009-11-04 21:44:48 +00:00
|
|
|
|
2011-02-25 04:22:14 +00:00
|
|
|
#include "glquake.h"
|
|
|
|
|
2012-10-10 22:58:51 +00:00
|
|
|
#ifdef D3D9QUAKE
|
2009-11-04 21:44:48 +00:00
|
|
|
#include "winquake.h"
|
|
|
|
|
2011-01-04 02:56:16 +00:00
|
|
|
#if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500)
|
|
|
|
#define HMONITOR_DECLARED
|
|
|
|
DECLARE_HANDLE(HMONITOR);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <d3d9.h>
|
2009-11-04 21:44:48 +00:00
|
|
|
|
|
|
|
//#pragma comment(lib, "../libs/dxsdk9/lib/d3d9.lib")
|
|
|
|
|
|
|
|
|
|
|
|
/*Fixup outdated windows headers*/
|
|
|
|
#ifndef WM_XBUTTONDOWN
|
|
|
|
#define WM_XBUTTONDOWN 0x020B
|
|
|
|
#define WM_XBUTTONUP 0x020C
|
|
|
|
#endif
|
|
|
|
#ifndef MK_XBUTTON1
|
|
|
|
#define MK_XBUTTON1 0x0020
|
|
|
|
#endif
|
|
|
|
#ifndef MK_XBUTTON2
|
|
|
|
#define MK_XBUTTON2 0x0040
|
|
|
|
#endif
|
|
|
|
// copied from DarkPlaces in an attempt to grab more buttons
|
|
|
|
#ifndef MK_XBUTTON3
|
|
|
|
#define MK_XBUTTON3 0x0080
|
|
|
|
#endif
|
|
|
|
#ifndef MK_XBUTTON4
|
|
|
|
#define MK_XBUTTON4 0x0100
|
|
|
|
#endif
|
|
|
|
#ifndef MK_XBUTTON5
|
|
|
|
#define MK_XBUTTON5 0x0200
|
|
|
|
#endif
|
|
|
|
#ifndef MK_XBUTTON6
|
|
|
|
#define MK_XBUTTON6 0x0400
|
|
|
|
#endif
|
|
|
|
#ifndef MK_XBUTTON7
|
|
|
|
#define MK_XBUTTON7 0x0800
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WM_INPUT
|
|
|
|
#define WM_INPUT 255
|
|
|
|
#endif
|
|
|
|
|
2011-05-19 13:34:07 +00:00
|
|
|
//static void D3D9_GetBufferSize(int *width, int *height); //not defined
|
2010-11-06 23:05:29 +00:00
|
|
|
static void resetD3D9(void);
|
2009-11-04 21:44:48 +00:00
|
|
|
static LPDIRECT3D9 pD3D;
|
|
|
|
LPDIRECT3DDEVICE9 pD3DDev9;
|
2010-11-06 23:05:29 +00:00
|
|
|
static D3DPRESENT_PARAMETERS d3dpp;
|
2011-09-03 03:49:43 +00:00
|
|
|
float d3d_trueprojection[16];
|
2009-11-04 21:44:48 +00:00
|
|
|
|
2011-12-23 03:12:29 +00:00
|
|
|
qboolean vid_initializing;
|
2009-11-04 21:44:48 +00:00
|
|
|
|
2010-05-01 22:47:47 +00:00
|
|
|
extern qboolean scr_initialized; // ready to draw
|
|
|
|
extern qboolean scr_drawloading;
|
|
|
|
extern qboolean scr_con_forcedraw;
|
2011-06-16 02:03:57 +00:00
|
|
|
static qboolean d3d_resized;
|
2009-11-04 21:44:48 +00:00
|
|
|
|
|
|
|
cvar_t vid_hardwaregamma;
|
|
|
|
|
|
|
|
|
|
|
|
//sound/error code needs this
|
|
|
|
HWND mainwindow;
|
|
|
|
|
|
|
|
//input code needs these
|
|
|
|
int window_center_x, window_center_y;
|
|
|
|
RECT window_rect;
|
|
|
|
int window_x, window_y;
|
|
|
|
|
|
|
|
|
2013-11-21 23:02:28 +00:00
|
|
|
/*void BuildGammaTable (float g, float c);
|
2009-11-04 21:44:48 +00:00
|
|
|
static void D3D9_VID_GenPaletteTables (unsigned char *palette)
|
|
|
|
{
|
|
|
|
extern unsigned short ramps[3][256];
|
|
|
|
qbyte *pal;
|
|
|
|
unsigned r,g,b;
|
|
|
|
unsigned v;
|
|
|
|
unsigned short i;
|
|
|
|
unsigned *table;
|
|
|
|
extern qbyte gammatable[256];
|
|
|
|
|
|
|
|
if (palette)
|
|
|
|
{
|
|
|
|
extern cvar_t v_contrast;
|
|
|
|
BuildGammaTable(v_gamma.value, v_contrast.value);
|
|
|
|
|
|
|
|
//
|
|
|
|
// 8 8 8 encoding
|
|
|
|
//
|
|
|
|
if (1)//vid_hardwaregamma.value)
|
|
|
|
{
|
|
|
|
// don't built in the gamma table
|
|
|
|
|
|
|
|
pal = palette;
|
|
|
|
table = d_8to24rgbtable;
|
|
|
|
for (i=0 ; i<256 ; i++)
|
|
|
|
{
|
|
|
|
r = pal[0];
|
|
|
|
g = pal[1];
|
|
|
|
b = pal[2];
|
|
|
|
pal += 3;
|
|
|
|
|
|
|
|
// v = (255<<24) + (r<<16) + (g<<8) + (b<<0);
|
|
|
|
// v = (255<<0) + (r<<8) + (g<<16) + (b<<24);
|
|
|
|
v = (255<<24) + (r<<0) + (g<<8) + (b<<16);
|
|
|
|
*table++ = v;
|
|
|
|
}
|
|
|
|
d_8to24rgbtable[255] &= 0xffffff; // 255 is transparent
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//computer has no hardware gamma (poor suckers) increase table accordingly
|
|
|
|
|
|
|
|
pal = palette;
|
|
|
|
table = d_8to24rgbtable;
|
|
|
|
for (i=0 ; i<256 ; i++)
|
|
|
|
{
|
|
|
|
r = gammatable[pal[0]];
|
|
|
|
g = gammatable[pal[1]];
|
|
|
|
b = gammatable[pal[2]];
|
|
|
|
pal += 3;
|
|
|
|
|
|
|
|
// v = (255<<24) + (r<<16) + (g<<8) + (b<<0);
|
|
|
|
// v = (255<<0) + (r<<8) + (g<<16) + (b<<24);
|
|
|
|
v = (255<<24) + (r<<0) + (g<<8) + (b<<16);
|
|
|
|
*table++ = v;
|
|
|
|
}
|
|
|
|
d_8to24rgbtable[255] &= 0xffffff; // 255 is transparent
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LittleLong(1) != 1)
|
|
|
|
{
|
|
|
|
for (i=0 ; i<256 ; i++)
|
|
|
|
d_8to24rgbtable[i] = LittleLong(d_8to24rgbtable[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pD3DDev9)
|
|
|
|
IDirect3DDevice9_SetGammaRamp(pD3DDev9, 0, D3DSGR_NO_CALIBRATION, (D3DGAMMARAMP *)ramps);
|
|
|
|
}
|
2013-11-21 23:02:28 +00:00
|
|
|
*/
|
2009-11-04 21:44:48 +00:00
|
|
|
typedef enum {MS_WINDOWED, MS_FULLSCREEN, MS_FULLDIB, MS_UNINIT} modestate_t;
|
|
|
|
static modestate_t modestate;
|
|
|
|
|
2010-11-06 23:05:29 +00:00
|
|
|
|
|
|
|
static void D3DVID_UpdateWindowStatus (HWND hWnd)
|
|
|
|
{
|
|
|
|
POINT p;
|
|
|
|
RECT nr;
|
|
|
|
int window_width, window_height;
|
|
|
|
GetClientRect(hWnd, &nr);
|
|
|
|
|
|
|
|
//if its bad then we're probably minimised
|
|
|
|
if (nr.right <= nr.left)
|
|
|
|
return;
|
|
|
|
if (nr.bottom <= nr.top)
|
|
|
|
return;
|
|
|
|
|
|
|
|
p.x = 0;
|
|
|
|
p.y = 0;
|
|
|
|
ClientToScreen(hWnd, &p);
|
|
|
|
window_x = p.x;
|
|
|
|
window_y = p.y;
|
|
|
|
window_width = nr.right - nr.left;
|
|
|
|
window_height = nr.bottom - nr.top;
|
|
|
|
// vid.pixelwidth = window_width;
|
|
|
|
// vid.pixelheight = window_height;
|
|
|
|
|
|
|
|
window_rect.left = window_x;
|
|
|
|
window_rect.top = window_y;
|
|
|
|
window_rect.right = window_x + window_width;
|
|
|
|
window_rect.bottom = window_y + window_height;
|
|
|
|
window_center_x = (window_rect.left + window_rect.right) / 2;
|
|
|
|
window_center_y = (window_rect.top + window_rect.bottom) / 2;
|
|
|
|
|
2012-10-14 09:00:49 +00:00
|
|
|
INS_UpdateClipCursor ();
|
2010-11-06 23:05:29 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 21:44:48 +00:00
|
|
|
static qboolean D3D9AppActivate(BOOL fActive, BOOL minimize)
|
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* Function: AppActivate
|
|
|
|
* Parameters: fActive - True if app is activating
|
|
|
|
*
|
|
|
|
* Description: If the application is activating, then swap the system
|
|
|
|
* into SYSPAL_NOSTATIC mode so that our palettes will display
|
|
|
|
* correctly.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
{
|
|
|
|
static BOOL sound_active;
|
|
|
|
|
|
|
|
if (ActiveApp == fActive && Minimized == minimize)
|
|
|
|
return false; //so windows doesn't crash us over and over again.
|
|
|
|
|
|
|
|
ActiveApp = fActive;
|
|
|
|
Minimized = minimize;
|
|
|
|
|
|
|
|
// enable/disable sound on focus gain/loss
|
|
|
|
if (!ActiveApp && sound_active)
|
|
|
|
{
|
|
|
|
S_BlockSound ();
|
|
|
|
sound_active = false;
|
|
|
|
}
|
|
|
|
else if (ActiveApp && !sound_active)
|
|
|
|
{
|
|
|
|
S_UnblockSound ();
|
|
|
|
sound_active = true;
|
|
|
|
}
|
|
|
|
|
2012-10-14 11:20:14 +00:00
|
|
|
INS_UpdateGrabs(modestate != MS_WINDOWED, ActiveApp);
|
2009-11-04 21:44:48 +00:00
|
|
|
|
|
|
|
if (fActive)
|
|
|
|
{
|
|
|
|
Cvar_ForceCallback(&v_gamma);
|
|
|
|
}
|
|
|
|
if (!fActive)
|
|
|
|
{
|
|
|
|
Cvar_ForceCallback(&v_gamma); //wham bam thanks.
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT WINAPI D3D9_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
LONG lRet = 1;
|
|
|
|
int fActive, fMinimized, temp;
|
|
|
|
extern unsigned int uiWheelMessage;
|
|
|
|
|
|
|
|
if ( uMsg == uiWheelMessage )
|
|
|
|
uMsg = WM_MOUSEWHEEL;
|
|
|
|
|
2011-03-12 13:51:40 +00:00
|
|
|
switch (uMsg)
|
|
|
|
{
|
2009-11-04 21:44:48 +00:00
|
|
|
case WM_KILLFOCUS:
|
|
|
|
if (modestate == MS_FULLDIB)
|
|
|
|
ShowWindow(mainwindow, SW_SHOWMINNOACTIVE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_CREATE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_MOVE:
|
2010-11-06 23:05:29 +00:00
|
|
|
D3DVID_UpdateWindowStatus (hWnd);
|
2009-11-04 21:44:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_KEYDOWN:
|
|
|
|
case WM_SYSKEYDOWN:
|
|
|
|
if (!vid_initializing)
|
2015-01-21 18:18:37 +00:00
|
|
|
INS_TranslateKeyEvent (wParam, lParam, true, 0, false);
|
2009-11-04 21:44:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_KEYUP:
|
|
|
|
case WM_SYSKEYUP:
|
|
|
|
if (!vid_initializing)
|
2015-01-21 18:18:37 +00:00
|
|
|
INS_TranslateKeyEvent (wParam, lParam, false, 0, false);
|
2009-11-04 21:44:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_SYSCHAR:
|
|
|
|
// keep Alt-Space from happening
|
|
|
|
break;
|
|
|
|
|
|
|
|
// this is complicated because Win32 seems to pack multiple mouse events into
|
|
|
|
// one update sometimes, so we always check all states and look for events
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
case WM_RBUTTONUP:
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
case WM_MBUTTONUP:
|
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
case WM_XBUTTONDOWN:
|
|
|
|
case WM_XBUTTONUP:
|
|
|
|
temp = 0;
|
|
|
|
|
|
|
|
if (wParam & MK_LBUTTON)
|
|
|
|
temp |= 1;
|
|
|
|
|
|
|
|
if (wParam & MK_RBUTTON)
|
|
|
|
temp |= 2;
|
|
|
|
|
|
|
|
if (wParam & MK_MBUTTON)
|
|
|
|
temp |= 4;
|
|
|
|
|
|
|
|
if (wParam & MK_XBUTTON1)
|
|
|
|
temp |= 8;
|
|
|
|
|
|
|
|
if (wParam & MK_XBUTTON2)
|
|
|
|
temp |= 16;
|
|
|
|
|
|
|
|
if (wParam & MK_XBUTTON3)
|
|
|
|
temp |= 32;
|
|
|
|
|
|
|
|
if (wParam & MK_XBUTTON4)
|
|
|
|
temp |= 64;
|
|
|
|
|
|
|
|
if (wParam & MK_XBUTTON5)
|
|
|
|
temp |= 128;
|
|
|
|
|
|
|
|
if (wParam & MK_XBUTTON6)
|
|
|
|
temp |= 256;
|
|
|
|
|
|
|
|
if (wParam & MK_XBUTTON7)
|
|
|
|
temp |= 512;
|
|
|
|
|
|
|
|
if (!vid_initializing)
|
2012-10-14 11:20:14 +00:00
|
|
|
INS_MouseEvent (temp);
|
2009-11-04 21:44:48 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
// JACK: This is the mouse wheel with the Intellimouse
|
|
|
|
// Its delta is either positive or neg, and we generate the proper
|
|
|
|
// Event.
|
2011-05-15 13:23:13 +00:00
|
|
|
case WM_MOUSEWHEEL:
|
2009-11-04 21:44:48 +00:00
|
|
|
if (!vid_initializing)
|
|
|
|
{
|
|
|
|
if ((short) HIWORD(wParam) > 0)
|
|
|
|
{
|
2010-10-02 02:25:39 +00:00
|
|
|
Key_Event(0, K_MWHEELUP, 0, true);
|
|
|
|
Key_Event(0, K_MWHEELUP, 0, false);
|
2009-11-04 21:44:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-02 02:25:39 +00:00
|
|
|
Key_Event(0, K_MWHEELDOWN, 0, true);
|
|
|
|
Key_Event(0, K_MWHEELDOWN, 0, false);
|
2009-11-04 21:44:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_INPUT:
|
|
|
|
// raw input handling
|
2010-08-23 04:53:20 +00:00
|
|
|
if (!vid_initializing)
|
2012-10-14 11:20:14 +00:00
|
|
|
INS_RawInput_Read((HANDLE)lParam);
|
2009-11-04 21:44:48 +00:00
|
|
|
break;
|
|
|
|
|
2015-08-07 17:49:49 +00:00
|
|
|
case WM_SETCURSOR:
|
|
|
|
//only use a custom cursor if the cursor is inside the client area
|
|
|
|
switch(lParam&0xffff)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case HTCLIENT:
|
|
|
|
if (hCustomCursor) //custom cursor enabled
|
|
|
|
SetCursor(hCustomCursor);
|
|
|
|
else //fallback on an arrow cursor, just so we have something visible at startup or so
|
|
|
|
SetCursor(hArrowCursor);
|
|
|
|
lRet = TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
lRet = DefWindowProcW (hWnd, uMsg, wParam, lParam);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-03-31 02:32:32 +00:00
|
|
|
case WM_GETMINMAXINFO:
|
|
|
|
{
|
|
|
|
RECT windowrect;
|
|
|
|
RECT clientrect;
|
|
|
|
MINMAXINFO *mmi = (MINMAXINFO *) lParam;
|
|
|
|
|
|
|
|
GetWindowRect (hWnd, &windowrect);
|
|
|
|
GetClientRect (hWnd, &clientrect);
|
|
|
|
|
|
|
|
mmi->ptMinTrackSize.x = 320 + ((windowrect.right - windowrect.left) - (clientrect.right - clientrect.left));
|
|
|
|
mmi->ptMinTrackSize.y = 200 + ((windowrect.bottom - windowrect.top) - (clientrect.bottom - clientrect.top));
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case WM_SIZE:
|
2011-06-16 02:03:57 +00:00
|
|
|
d3d_resized = true;
|
2011-03-12 13:51:40 +00:00
|
|
|
break;
|
2009-11-04 21:44:48 +00:00
|
|
|
|
2011-06-16 02:03:57 +00:00
|
|
|
case WM_CLOSE:
|
2009-11-04 21:44:48 +00:00
|
|
|
if (!vid_initializing)
|
|
|
|
if (MessageBox (mainwindow, "Are you sure you want to quit?", "Confirm Exit",
|
|
|
|
MB_YESNO | MB_SETFOREGROUND | MB_ICONQUESTION) == IDYES)
|
|
|
|
{
|
2011-12-23 03:12:29 +00:00
|
|
|
Cbuf_AddText("\nquit\n", RESTRICT_LOCAL);
|
2009-11-04 21:44:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_ACTIVATE:
|
|
|
|
fActive = LOWORD(wParam);
|
|
|
|
fMinimized = (BOOL) HIWORD(wParam);
|
|
|
|
if (!D3D9AppActivate(!(fActive == WA_INACTIVE), fMinimized))
|
|
|
|
break;//so, urm, tell me microsoft, what changed?
|
|
|
|
if (modestate == MS_FULLDIB)
|
|
|
|
ShowWindow(mainwindow, SW_SHOWNORMAL);
|
|
|
|
|
|
|
|
// fix the leftover Alt from any Alt-Tab or the like that switched us away
|
|
|
|
// ClearAllStates ();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
{
|
|
|
|
// if (dibwindow)
|
|
|
|
// DestroyWindow (dibwindow);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MM_MCINOTIFY:
|
|
|
|
lRet = CDAudio_MessageHandler (hWnd, uMsg, wParam, lParam);
|
|
|
|
break;
|
2011-05-15 13:23:13 +00:00
|
|
|
|
2009-11-04 21:44:48 +00:00
|
|
|
default:
|
|
|
|
/* pass all unhandled messages to DefWindowProc */
|
|
|
|
lRet = DefWindowProc (hWnd, uMsg, wParam, lParam);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return 1 if handled message, 0 if not */
|
|
|
|
return lRet;
|
|
|
|
}
|
|
|
|
|
2014-03-30 08:55:06 +00:00
|
|
|
static void D3D9_VID_SwapBuffers(void)
|
|
|
|
{
|
|
|
|
IDirect3DDevice9_Present(pD3DDev9, NULL, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:44:48 +00:00
|
|
|
static void resetD3D9(void)
|
|
|
|
{
|
2010-11-06 23:05:29 +00:00
|
|
|
HRESULT res;
|
|
|
|
res = IDirect3DDevice9_Reset(pD3DDev9, &d3dpp);
|
|
|
|
if (FAILED(res))
|
2011-06-16 02:03:57 +00:00
|
|
|
{
|
|
|
|
Con_Printf("IDirect3DDevice9_Reset failed (%u)\n", res&0xffff);
|
2010-11-06 23:05:29 +00:00
|
|
|
return;
|
2011-06-16 02:03:57 +00:00
|
|
|
}
|
2009-11-04 21:44:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*clear the screen to black as soon as we start up, so there's no lingering framebuffer state*/
|
|
|
|
IDirect3DDevice9_BeginScene(pD3DDev9);
|
2009-11-04 23:20:50 +00:00
|
|
|
IDirect3DDevice9_Clear(pD3DDev9, 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
|
2009-11-04 21:44:48 +00:00
|
|
|
IDirect3DDevice9_EndScene(pD3DDev9);
|
|
|
|
IDirect3DDevice9_Present(pD3DDev9, NULL, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-05-15 13:23:13 +00:00
|
|
|
|
|
|
|
|
2009-11-04 21:44:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
//IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRENDERSTATE_DITHERENABLE, FALSE);
|
|
|
|
//IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRENDERSTATE_SPECULARENABLE, FALSE);
|
|
|
|
//IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRENDERSTATE_TEXTUREPERSPECTIVE, TRUE);
|
|
|
|
IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRS_LIGHTING, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if (WINVER < 0x500) && !defined(__GNUC__)
|
|
|
|
typedef struct tagMONITORINFO
|
|
|
|
{
|
|
|
|
DWORD cbSize;
|
|
|
|
RECT rcMonitor;
|
|
|
|
RECT rcWork;
|
|
|
|
DWORD dwFlags;
|
|
|
|
} MONITORINFO, *LPMONITORINFO;
|
|
|
|
#endif
|
|
|
|
|
2010-11-10 03:32:47 +00:00
|
|
|
static qboolean initD3D9Device(HWND hWnd, rendererstate_t *info, unsigned int devno, unsigned int devtype)
|
2009-11-04 21:44:48 +00:00
|
|
|
{
|
|
|
|
int err;
|
2009-11-04 23:20:50 +00:00
|
|
|
RECT rect;
|
2009-11-04 21:44:48 +00:00
|
|
|
D3DADAPTER_IDENTIFIER9 inf;
|
2010-11-06 23:05:29 +00:00
|
|
|
D3DCAPS9 caps;
|
|
|
|
unsigned int cflags;
|
2009-11-04 21:44:48 +00:00
|
|
|
|
2010-11-10 03:32:47 +00:00
|
|
|
memset(&inf, 0, sizeof(inf));
|
|
|
|
if (FAILED(IDirect3D9_GetAdapterIdentifier(pD3D, devno, 0, &inf)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (FAILED(IDirect3D9_GetDeviceCaps(pD3D, devno, devtype, &caps)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
memset(&d3dpp, 0, sizeof(d3dpp)); // clear out the struct for use
|
|
|
|
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // discard old frames
|
|
|
|
d3dpp.hDeviceWindow = hWnd; // set the window to be used by Direct3D
|
|
|
|
d3dpp.BackBufferWidth = info->width;
|
|
|
|
d3dpp.BackBufferHeight = info->height;
|
|
|
|
d3dpp.MultiSampleType = info->multisample;
|
2011-06-17 01:54:54 +00:00
|
|
|
d3dpp.BackBufferCount = 1 + info->triplebuffer;
|
2010-11-10 03:32:47 +00:00
|
|
|
d3dpp.FullScreen_RefreshRateInHz = info->fullscreen?info->rate:0; //don't pass a rate if not fullscreen, d3d doesn't like it.
|
|
|
|
d3dpp.Windowed = !info->fullscreen;
|
|
|
|
|
|
|
|
d3dpp.EnableAutoDepthStencil = true;
|
2012-01-01 02:26:42 +00:00
|
|
|
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;//D3DFMT_D16;
|
2010-11-10 03:32:47 +00:00
|
|
|
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
|
|
|
|
if (info->fullscreen)
|
|
|
|
{
|
|
|
|
if (info->bpp == 16)
|
|
|
|
d3dpp.BackBufferFormat = D3DFMT_R5G6B5;
|
|
|
|
else
|
|
|
|
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(info->wait)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_TWO;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_THREE;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_FOUR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
cflags = D3DCREATE_FPU_PRESERVE;
|
|
|
|
if ((caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) && (caps.DevCaps & D3DDEVCAPS_PUREDEVICE))
|
|
|
|
cflags |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
|
|
|
|
else
|
|
|
|
cflags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
|
|
|
|
//cflags |= D3DCREATE_DISABLE_DRIVER_MANAGEMENT;
|
|
|
|
|
|
|
|
pD3DDev9 = NULL;
|
|
|
|
// create a device class using this information and information from the d3dpp stuct
|
2011-05-15 13:23:13 +00:00
|
|
|
err = IDirect3D9_CreateDevice(pD3D,
|
2010-11-10 03:32:47 +00:00
|
|
|
devno,
|
|
|
|
devtype,
|
|
|
|
hWnd,
|
|
|
|
cflags,
|
|
|
|
&d3dpp,
|
|
|
|
&pD3DDev9);
|
|
|
|
|
|
|
|
if (pD3DDev9)
|
|
|
|
{
|
|
|
|
HMONITOR hm;
|
|
|
|
MONITORINFO mi;
|
|
|
|
char *s;
|
|
|
|
for (s = inf.Description + strlen(inf.Description)-1; s >= inf.Description && *s <= ' '; s--)
|
|
|
|
*s = 0;
|
2011-06-19 12:54:10 +00:00
|
|
|
Con_Printf("D3D9 Driver: %s\n", inf.Description);
|
2010-11-10 03:32:47 +00:00
|
|
|
|
|
|
|
vid.numpages = d3dpp.BackBufferCount;
|
|
|
|
|
|
|
|
if (d3dpp.Windowed) //fullscreen we get positioned automagically.
|
|
|
|
{ //windowed, we get positioned at 0,0... which is often going to be on the wrong screen
|
|
|
|
//the user can figure it out from here
|
|
|
|
static HANDLE huser32;
|
|
|
|
BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR hMonitor, LPMONITORINFO lpmi);
|
|
|
|
if (!huser32)
|
|
|
|
huser32 = LoadLibrary("user32.dll");
|
|
|
|
if (!huser32)
|
|
|
|
return false;
|
|
|
|
pGetMonitorInfoA = (void*)GetProcAddress(huser32, "GetMonitorInfoA");
|
|
|
|
if (!pGetMonitorInfoA)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
hm = IDirect3D9_GetAdapterMonitor(pD3D, devno);
|
|
|
|
memset(&mi, 0, sizeof(mi));
|
|
|
|
mi.cbSize = sizeof(mi);
|
|
|
|
pGetMonitorInfoA(hm, &mi);
|
2012-09-30 05:52:03 +00:00
|
|
|
rect.left = mi.rcWork.left + ((mi.rcWork.right - mi.rcWork.left) - info->width) / 2;
|
|
|
|
rect.top = mi.rcWork.top + ((mi.rcWork.bottom - mi.rcWork.top) - info->height) / 2;
|
|
|
|
rect.right = rect.left+d3dpp.BackBufferWidth;
|
|
|
|
rect.bottom = rect.top+d3dpp.BackBufferHeight;
|
2010-11-10 03:32:47 +00:00
|
|
|
AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, FALSE, 0);
|
2012-09-30 05:52:03 +00:00
|
|
|
MoveWindow(d3dpp.hDeviceWindow, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, false);
|
2010-11-10 03:32:47 +00:00
|
|
|
}
|
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
|
|
|
D3D9Shader_Init();
|
2010-11-10 03:32:47 +00:00
|
|
|
return true; //successful
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char *s;
|
|
|
|
switch(err)
|
|
|
|
{
|
|
|
|
default: s = "Unkown error"; break;
|
|
|
|
case D3DERR_DEVICELOST: s = "Device lost"; break;
|
|
|
|
case D3DERR_INVALIDCALL: s = "Invalid call"; break;
|
|
|
|
case D3DERR_NOTAVAILABLE: s = "Not available"; break;
|
|
|
|
case D3DERR_OUTOFVIDEOMEMORY: s = "Out of video memory"; break;
|
|
|
|
}
|
|
|
|
Con_Printf("IDirect3D9_CreateDevice failed: %s.\n", s);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void initD3D9(HWND hWnd, rendererstate_t *info)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int numadaptors;
|
|
|
|
int err;
|
|
|
|
D3DADAPTER_IDENTIFIER9 inf;
|
|
|
|
|
2009-11-04 21:44:48 +00:00
|
|
|
static HMODULE d3d9dll;
|
|
|
|
LPDIRECT3D9 (WINAPI *pDirect3DCreate9) (int version);
|
|
|
|
|
|
|
|
if (!d3d9dll)
|
|
|
|
d3d9dll = LoadLibrary("d3d9.dll");
|
|
|
|
if (!d3d9dll)
|
|
|
|
{
|
2015-06-04 06:15:14 +00:00
|
|
|
Con_Printf(CON_ERROR "Direct3d 9 does not appear to be installed\n");
|
2009-11-04 21:44:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
pDirect3DCreate9 = (void*)GetProcAddress(d3d9dll, "Direct3DCreate9");
|
|
|
|
if (!pDirect3DCreate9)
|
|
|
|
{
|
2015-06-04 06:15:14 +00:00
|
|
|
Con_Printf(CON_ERROR "Direct3d 9 does not appear to be installed properly\n");
|
2009-11-04 21:44:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pD3D = pDirect3DCreate9(D3D_SDK_VERSION); // create the Direct3D interface
|
|
|
|
if (!pD3D)
|
|
|
|
return;
|
|
|
|
|
|
|
|
numadaptors = IDirect3D9_GetAdapterCount(pD3D);
|
|
|
|
for (i = 0; i < numadaptors; i++)
|
2011-03-12 13:51:40 +00:00
|
|
|
{ //NVIDIA's debug app requires that we use a specific device
|
2009-11-04 21:44:48 +00:00
|
|
|
memset(&inf, 0, sizeof(inf));
|
|
|
|
err = IDirect3D9_GetAdapterIdentifier(pD3D, i, 0, &inf);
|
2010-11-10 03:32:47 +00:00
|
|
|
if (strstr(inf.Description, "PerfHUD"))
|
|
|
|
if (initD3D9Device(hWnd, info, i, D3DDEVTYPE_REF))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (i = 0; i < numadaptors; i++)
|
|
|
|
{ //try each adaptor in turn until we get one that actually works
|
|
|
|
if (initD3D9Device(hWnd, info, i, D3DDEVTYPE_HAL))
|
|
|
|
return;
|
2009-11-04 21:44:48 +00:00
|
|
|
}
|
2011-08-16 04:12:15 +00:00
|
|
|
for (i = 0; i < numadaptors; i++)
|
|
|
|
{ //try each adaptor in turn until we get one that actually works
|
|
|
|
if (initD3D9Device(hWnd, info, i, D3DDEVTYPE_SW))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (i = 0; i < numadaptors; i++)
|
|
|
|
{ //try each adaptor in turn until we get one that actually works
|
|
|
|
if (initD3D9Device(hWnd, info, i, D3DDEVTYPE_REF))
|
|
|
|
return;
|
|
|
|
}
|
2009-11-04 21:44:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static qboolean D3D9_VID_Init(rendererstate_t *info, unsigned char *palette)
|
|
|
|
{
|
|
|
|
DWORD width = info->width;
|
|
|
|
DWORD height = info->height;
|
2011-05-19 13:34:07 +00:00
|
|
|
//DWORD bpp = info->bpp;
|
|
|
|
//DWORD zbpp = 16;
|
|
|
|
//DWORD flags = 0;
|
2009-11-04 23:20:50 +00:00
|
|
|
DWORD wstyle;
|
|
|
|
RECT rect;
|
2009-11-04 21:44:48 +00:00
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
extern cvar_t vid_conwidth;
|
2011-05-19 13:34:07 +00:00
|
|
|
//extern cvar_t vid_conheight;
|
2009-11-04 21:44:48 +00:00
|
|
|
|
|
|
|
//DDGAMMARAMP gammaramp;
|
|
|
|
//int i;
|
|
|
|
|
|
|
|
char *CLASSNAME = "FTED3D9QUAKE";
|
|
|
|
WNDCLASS wc = {
|
|
|
|
0,
|
|
|
|
&D3D9_WindowProc,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
CLASSNAME
|
|
|
|
};
|
|
|
|
|
2015-08-07 17:49:49 +00:00
|
|
|
wc.hCursor = hArrowCursor = LoadCursor (NULL,IDC_ARROW);
|
2010-11-06 23:05:29 +00:00
|
|
|
|
2009-11-04 21:44:48 +00:00
|
|
|
vid_initializing = true;
|
|
|
|
|
|
|
|
RegisterClass(&wc);
|
|
|
|
|
|
|
|
if (info->fullscreen)
|
2009-11-04 23:20:50 +00:00
|
|
|
wstyle = 0;
|
2009-11-04 21:44:48 +00:00
|
|
|
else
|
2009-11-04 23:20:50 +00:00
|
|
|
wstyle = WS_OVERLAPPEDWINDOW;
|
2011-05-15 13:23:13 +00:00
|
|
|
|
2012-09-30 05:52:03 +00:00
|
|
|
rect.left = (GetSystemMetrics(SM_CXSCREEN) - info->width) / 2;
|
|
|
|
rect.top = (GetSystemMetrics(SM_CYSCREEN) - info->height) / 2;
|
|
|
|
rect.right = rect.left+info->width;
|
|
|
|
rect.bottom = rect.top+info->height;
|
2009-11-04 23:20:50 +00:00
|
|
|
AdjustWindowRectEx(&rect, wstyle, FALSE, 0);
|
2012-09-30 05:52:03 +00:00
|
|
|
mainwindow = CreateWindow(CLASSNAME, "Direct3D9", wstyle, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, NULL, NULL, NULL, NULL);
|
2009-11-04 23:20:50 +00:00
|
|
|
|
2009-11-04 21:44:48 +00:00
|
|
|
// Try as specified.
|
|
|
|
|
|
|
|
initD3D9(mainwindow, info);
|
|
|
|
if (!pD3DDev9)
|
2011-08-16 04:12:15 +00:00
|
|
|
{
|
2012-09-30 05:52:03 +00:00
|
|
|
Con_Printf("No suitable D3D9 device found\n");
|
2009-11-04 21:44:48 +00:00
|
|
|
return false;
|
2011-08-16 04:12:15 +00:00
|
|
|
}
|
2009-11-04 21:44:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-05-15 13:23:13 +00:00
|
|
|
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
|
|
|
{
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
2009-11-04 21:44:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ShowWindow(mainwindow, SW_NORMAL);
|
|
|
|
|
2015-08-04 15:16:24 +00:00
|
|
|
IDirect3DDevice9_Clear(pD3DDev9, 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
|
2009-11-04 21:44:48 +00:00
|
|
|
IDirect3DDevice9_BeginScene(pD3DDev9);
|
|
|
|
IDirect3DDevice9_EndScene(pD3DDev9);
|
|
|
|
IDirect3DDevice9_Present(pD3DDev9, NULL, NULL, NULL, NULL);
|
|
|
|
|
2015-08-04 15:16:24 +00:00
|
|
|
D3D9_Set2D();
|
|
|
|
|
2009-11-04 21:44:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
// pD3DX->lpVtbl->GetBufferSize((void*)pD3DX, &width, &height);
|
|
|
|
vid.pixelwidth = width;
|
|
|
|
vid.pixelheight = height;
|
|
|
|
|
2010-10-02 02:25:39 +00:00
|
|
|
vid.width = width;
|
|
|
|
vid.height = height;
|
2009-11-04 21:44:48 +00:00
|
|
|
|
|
|
|
vid_initializing = false;
|
|
|
|
|
|
|
|
IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRS_LIGHTING, FALSE);
|
|
|
|
|
|
|
|
GetWindowRect(mainwindow, &window_rect);
|
|
|
|
|
|
|
|
|
2013-11-21 23:02:28 +00:00
|
|
|
// D3D9_VID_GenPaletteTables(palette);
|
2009-11-04 21:44:48 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
extern qboolean mouseactive;
|
|
|
|
mouseactive = false;
|
|
|
|
}
|
|
|
|
|
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
|
|
|
// D3D9BE_Reset(false);
|
|
|
|
|
2015-08-07 17:49:49 +00:00
|
|
|
//FIXME: old hardware is not guarenteed to support hardware cursors.
|
|
|
|
//this should not be a problem on dx9+ hardware, but might on earlier stuff.
|
|
|
|
rf->VID_CreateCursor = WIN_CreateCursor;
|
|
|
|
rf->VID_DestroyCursor = WIN_DestroyCursor;
|
|
|
|
rf->VID_SetCursor = WIN_SetCursor;
|
|
|
|
|
2009-11-04 21:44:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void (D3D9_VID_DeInit) (void)
|
|
|
|
{
|
2015-03-03 00:14:43 +00:00
|
|
|
Image_Shutdown();
|
|
|
|
|
2009-11-04 21:44:48 +00:00
|
|
|
/*final shutdown, kill the video stuff*/
|
|
|
|
if (pD3DDev9)
|
|
|
|
{
|
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
|
|
|
D3D9BE_Reset(true);
|
|
|
|
|
2011-06-19 12:54:10 +00:00
|
|
|
/*try and knock it back into windowed mode to avoid d3d bugs*/
|
|
|
|
d3dpp.Windowed = true;
|
|
|
|
IDirect3DDevice9_Reset(pD3DDev9, &d3dpp);
|
|
|
|
|
2009-11-04 21:44:48 +00:00
|
|
|
IDirect3DDevice9_Release(pD3DDev9);
|
|
|
|
pD3DDev9 = NULL;
|
|
|
|
}
|
|
|
|
if (pD3D)
|
|
|
|
{
|
|
|
|
IDirect3D9_Release(pD3D);
|
|
|
|
pD3D = NULL;
|
|
|
|
}
|
|
|
|
if (mainwindow)
|
|
|
|
{
|
|
|
|
DestroyWindow(mainwindow);
|
|
|
|
mainwindow = NULL;
|
|
|
|
}
|
2012-05-09 15:30:53 +00:00
|
|
|
|
2015-04-14 23:12:17 +00:00
|
|
|
// Cvar_Unhook(&v_gamma);
|
|
|
|
// Cvar_Unhook(&v_contrast);
|
|
|
|
// Cvar_Unhook(&v_brightness);
|
2009-11-04 21:44:48 +00:00
|
|
|
}
|
|
|
|
|
2013-05-11 14:02:55 +00:00
|
|
|
qboolean D3D9_VID_ApplyGammaRamps (unsigned short *ramps)
|
2009-11-04 21:44:48 +00:00
|
|
|
{
|
2013-05-11 14:02:55 +00:00
|
|
|
if (d3dpp.Windowed)
|
|
|
|
return false;
|
|
|
|
if (pD3DDev9 && ramps)
|
|
|
|
IDirect3DDevice9_SetGammaRamp(pD3DDev9, 0, D3DSGR_NO_CALIBRATION, (D3DGAMMARAMP *)ramps);
|
|
|
|
return true;
|
2009-11-04 21:44:48 +00:00
|
|
|
}
|
2015-08-14 02:46:38 +00:00
|
|
|
static char *(D3D9_VID_GetRGBInfo) (int *truevidwidth, int *truevidheight, enum uploadfmt *fmt)
|
2009-11-04 21:44:48 +00:00
|
|
|
{
|
2011-04-25 13:48:30 +00:00
|
|
|
IDirect3DSurface9 *backbuf, *surf;
|
2011-03-31 23:05:19 +00:00
|
|
|
D3DLOCKED_RECT rect;
|
2011-04-25 13:48:30 +00:00
|
|
|
D3DSURFACE_DESC desc;
|
2011-03-31 23:05:19 +00:00
|
|
|
int i, j, c;
|
2011-04-25 13:48:30 +00:00
|
|
|
qbyte *ret = NULL;
|
2011-03-31 23:05:19 +00:00
|
|
|
qbyte *p;
|
|
|
|
|
2011-04-25 13:48:30 +00:00
|
|
|
/*DON'T read the front buffer.
|
|
|
|
this function can be used by the quakeworld remote screenshot 'snap' feature,
|
|
|
|
so DO NOT read the frontbuffer because it can show other information than just quake to third parties*/
|
|
|
|
|
|
|
|
if (!FAILED(IDirect3DDevice9_GetRenderTarget(pD3DDev9, 0, &backbuf)))
|
2011-03-31 23:05:19 +00:00
|
|
|
{
|
2011-04-25 13:48:30 +00:00
|
|
|
if (!FAILED(IDirect3DSurface9_GetDesc(backbuf, &desc)))
|
|
|
|
if (desc.Format == D3DFMT_X8R8G8B8 || desc.Format == D3DFMT_A8R8G8B8)
|
2011-05-15 13:23:13 +00:00
|
|
|
if (!FAILED(IDirect3DDevice9_CreateOffscreenPlainSurface(pD3DDev9,
|
2011-04-25 13:48:30 +00:00
|
|
|
desc.Width, desc.Height, desc.Format,
|
|
|
|
D3DPOOL_SYSTEMMEM, &surf, NULL))
|
|
|
|
)
|
2011-03-31 23:05:19 +00:00
|
|
|
{
|
|
|
|
|
2011-04-25 13:48:30 +00:00
|
|
|
if (!FAILED(IDirect3DDevice9_GetRenderTargetData(pD3DDev9, backbuf, surf)))
|
|
|
|
if (!FAILED(IDirect3DSurface9_LockRect(surf, &rect, NULL, D3DLOCK_NO_DIRTY_UPDATE|D3DLOCK_READONLY|D3DLOCK_NOSYSLOCK)))
|
|
|
|
{
|
2015-08-14 02:46:38 +00:00
|
|
|
ret = BZ_Malloc(desc.Width*desc.Height*3);
|
2011-04-25 13:48:30 +00:00
|
|
|
if (ret)
|
|
|
|
{
|
2015-08-14 02:46:38 +00:00
|
|
|
*fmt = TF_RGB24;
|
|
|
|
|
2011-04-25 13:48:30 +00:00
|
|
|
// read surface rect and convert 32 bgra to 24 rgb and flip
|
2015-08-14 02:46:38 +00:00
|
|
|
c = desc.Width*desc.Height*3;
|
2011-04-25 13:48:30 +00:00
|
|
|
p = (qbyte *)rect.pBits;
|
|
|
|
|
2015-08-14 02:46:38 +00:00
|
|
|
for (i=c-(3*desc.Width); i>=0; i-=(3*desc.Width))
|
2011-04-25 13:48:30 +00:00
|
|
|
{
|
|
|
|
for (j=0; j<desc.Width; j++)
|
|
|
|
{
|
|
|
|
ret[i+j*3+0] = p[j*4+2];
|
|
|
|
ret[i+j*3+1] = p[j*4+1];
|
|
|
|
ret[i+j*3+2] = p[j*4+0];
|
|
|
|
}
|
|
|
|
p += rect.Pitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
*truevidwidth = desc.Width;
|
|
|
|
*truevidheight = desc.Height;
|
|
|
|
}
|
2011-03-31 23:05:19 +00:00
|
|
|
|
2011-04-25 13:48:30 +00:00
|
|
|
IDirect3DSurface9_UnlockRect(surf);
|
|
|
|
}
|
|
|
|
IDirect3DSurface9_Release(surf);
|
|
|
|
}
|
|
|
|
IDirect3DSurface9_Release(backbuf);
|
|
|
|
}
|
2011-05-15 13:23:13 +00:00
|
|
|
|
2011-03-31 23:05:19 +00:00
|
|
|
return ret;
|
2009-11-04 21:44:48 +00:00
|
|
|
}
|
|
|
|
static void (D3D9_VID_SetWindowCaption) (char *msg)
|
|
|
|
{
|
|
|
|
SetWindowText(mainwindow, msg);
|
|
|
|
}
|
|
|
|
|
2010-05-01 22:47:47 +00:00
|
|
|
void D3D9_Set2D (void)
|
2009-11-04 21:44:48 +00:00
|
|
|
{
|
|
|
|
float m[16];
|
|
|
|
D3DVIEWPORT9 vport;
|
|
|
|
// IDirect3DDevice9_EndScene(pD3DDev9);
|
|
|
|
|
2011-07-31 11:18:49 +00:00
|
|
|
Matrix4x4_CM_OrthographicD3D(m, 0 + (0.5*vid.width/vid.pixelwidth), vid.width + (0.5*vid.width/vid.pixelwidth), 0 + (0.5*vid.height/vid.pixelheight), vid.height + (0.5*vid.height/vid.pixelheight), 0, 100);
|
2009-11-04 21:44:48 +00:00
|
|
|
IDirect3DDevice9_SetTransform(pD3DDev9, D3DTS_PROJECTION, (D3DMATRIX*)m);
|
|
|
|
|
2011-07-31 11:18:49 +00:00
|
|
|
Matrix4x4_Identity(m);
|
2009-11-04 21:44:48 +00:00
|
|
|
IDirect3DDevice9_SetTransform(pD3DDev9, D3DTS_WORLD, (D3DMATRIX*)m);
|
|
|
|
|
2011-07-31 11:18:49 +00:00
|
|
|
Matrix4x4_Identity(m);
|
2009-11-04 21:44:48 +00:00
|
|
|
IDirect3DDevice9_SetTransform(pD3DDev9, D3DTS_VIEW, (D3DMATRIX*)m);
|
|
|
|
|
|
|
|
vport.X = 0;
|
|
|
|
vport.Y = 0;
|
2009-11-07 13:29:15 +00:00
|
|
|
vport.Width = vid.pixelwidth;
|
|
|
|
vport.Height = vid.pixelheight;
|
2009-11-04 21:44:48 +00:00
|
|
|
vport.MinZ = 0;
|
|
|
|
vport.MaxZ = 1;
|
|
|
|
IDirect3DDevice9_SetViewport(pD3DDev9, &vport);
|
2015-03-03 00:14:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
vid.fbvwidth = vid.width;
|
|
|
|
vid.fbvheight = vid.height;
|
|
|
|
vid.fbpwidth = vid.pixelwidth;
|
|
|
|
vid.fbpheight = vid.pixelheight;
|
2015-08-11 09:14:33 +00:00
|
|
|
|
|
|
|
r_refdef.pxrect.x = 0;
|
|
|
|
r_refdef.pxrect.y = 0;
|
|
|
|
r_refdef.pxrect.width = vid.fbpwidth;
|
|
|
|
r_refdef.pxrect.height = vid.fbpheight;
|
2009-11-04 21:44:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int d3d9error(int i)
|
|
|
|
{
|
|
|
|
if (FAILED(i))// != D3D_OK)
|
2011-05-19 13:34:07 +00:00
|
|
|
Con_Printf("D3D error: %i\n", i);
|
2009-11-04 21:44:48 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void (D3D9_SCR_UpdateScreen) (void)
|
|
|
|
{
|
2011-05-19 13:34:07 +00:00
|
|
|
//extern int keydown[];
|
|
|
|
//extern cvar_t vid_conheight;
|
2009-11-04 21:44:48 +00:00
|
|
|
int uimenu;
|
|
|
|
#ifdef TEXTEDITOR
|
2011-05-19 13:34:07 +00:00
|
|
|
//extern qboolean editormodal;
|
2009-11-04 21:44:48 +00:00
|
|
|
#endif
|
2010-05-01 22:47:47 +00:00
|
|
|
qboolean nohud, noworld;
|
2009-11-04 21:44:48 +00:00
|
|
|
RSpeedMark();
|
|
|
|
|
2011-06-16 02:03:57 +00:00
|
|
|
if (d3d_resized && d3dpp.Windowed)
|
|
|
|
{
|
|
|
|
extern cvar_t vid_conautoscale, vid_conwidth;
|
|
|
|
d3d_resized = false;
|
|
|
|
|
|
|
|
// force width/height to be updated
|
|
|
|
//vid.pixelwidth = window_rect.right - window_rect.left;
|
|
|
|
//vid.pixelheight = window_rect.bottom - window_rect.top;
|
|
|
|
D3DVID_UpdateWindowStatus(mainwindow);
|
|
|
|
|
2012-09-30 05:52:03 +00:00
|
|
|
D3D9BE_Reset(true);
|
2011-06-16 02:03:57 +00:00
|
|
|
vid.pixelwidth = d3dpp.BackBufferWidth = window_rect.right - window_rect.left;
|
|
|
|
vid.pixelheight = d3dpp.BackBufferHeight = window_rect.bottom - window_rect.top;
|
|
|
|
resetD3D9();
|
2012-09-30 05:52:03 +00:00
|
|
|
D3D9BE_Reset(false);
|
2011-06-16 02:03:57 +00:00
|
|
|
|
|
|
|
Cvar_ForceCallback(&vid_conautoscale);
|
|
|
|
Cvar_ForceCallback(&vid_conwidth);
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:44:48 +00:00
|
|
|
switch (IDirect3DDevice9_TestCooperativeLevel(pD3DDev9))
|
|
|
|
{
|
|
|
|
case D3DERR_DEVICELOST:
|
2011-06-16 02:03:57 +00:00
|
|
|
//the user has task switched away from us or something, don't draw anything until they switch back to us
|
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
|
|
|
D3D9BE_Reset(true);
|
2009-11-04 21:44:48 +00:00
|
|
|
return;
|
|
|
|
case D3DERR_DEVICENOTRESET:
|
2012-09-30 05:52:03 +00:00
|
|
|
D3D9BE_Reset(true);
|
2009-11-04 21:44:48 +00:00
|
|
|
resetD3D9();
|
|
|
|
if (FAILED(IDirect3DDevice9_TestCooperativeLevel(pD3DDev9)))
|
2010-11-06 23:05:29 +00:00
|
|
|
{
|
|
|
|
Con_Printf("Device lost, restarting video\n");
|
|
|
|
Cmd_ExecuteString("vid_restart", RESTRICT_LOCAL);
|
|
|
|
return;
|
|
|
|
}
|
2009-11-04 21:44:48 +00:00
|
|
|
|
2013-05-11 14:02:55 +00:00
|
|
|
Cvar_ForceCallback(&v_gamma);
|
2009-11-04 21:44:48 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
|
|
|
D3D9BE_Reset(false);
|
|
|
|
|
2015-07-31 13:23:32 +00:00
|
|
|
if (r_clear.ival)
|
|
|
|
{
|
|
|
|
d3d9error(IDirect3DDevice9_Clear(pD3DDev9, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB((r_clear.ival&1)?255:0,(r_clear.ival&2)?255:0,(r_clear.ival&4)?255:0), 1, 0));
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:44:48 +00:00
|
|
|
if (scr_disabled_for_loading)
|
|
|
|
{
|
|
|
|
extern float scr_disabled_time;
|
2013-10-08 16:13:18 +00:00
|
|
|
if (Sys_DoubleTime() - scr_disabled_time > 60 || Key_Dest_Has(~kdm_game))
|
2009-11-04 21:44:48 +00:00
|
|
|
{
|
|
|
|
scr_disabled_for_loading = false;
|
|
|
|
}
|
|
|
|
else
|
2011-05-15 13:23:13 +00:00
|
|
|
{
|
2009-11-04 21:44:48 +00:00
|
|
|
IDirect3DDevice9_BeginScene(pD3DDev9);
|
|
|
|
scr_drawloading = true;
|
2014-03-30 08:55:06 +00:00
|
|
|
SCR_DrawLoading (true);
|
2009-11-04 21:44:48 +00:00
|
|
|
scr_drawloading = false;
|
|
|
|
IDirect3DDevice9_EndScene(pD3DDev9);
|
|
|
|
IDirect3DDevice9_Present(pD3DDev9, NULL, NULL, NULL, NULL);
|
|
|
|
RSpeedEnd(RSPEED_TOTALREFRESH);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!scr_initialized || !con_initialized)
|
|
|
|
{
|
|
|
|
RSpeedEnd(RSPEED_TOTALREFRESH);
|
|
|
|
return; // not initialized yet
|
|
|
|
}
|
|
|
|
|
2010-11-22 02:03:28 +00:00
|
|
|
Shader_DoReload();
|
2009-11-04 21:44:48 +00:00
|
|
|
|
|
|
|
#ifdef VM_UI
|
|
|
|
uimenu = UI_MenuState();
|
|
|
|
#else
|
|
|
|
uimenu = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
d3d9error(IDirect3DDevice9_BeginScene(pD3DDev9));
|
|
|
|
/*
|
|
|
|
#ifdef TEXTEDITOR
|
|
|
|
if (editormodal)
|
|
|
|
{
|
|
|
|
Editor_Draw();
|
2011-12-23 03:12:29 +00:00
|
|
|
V_UpdatePalette (false);
|
2009-11-04 21:44:48 +00:00
|
|
|
Media_RecordFrame();
|
2010-05-01 22:47:47 +00:00
|
|
|
R2D_BrightenScreen();
|
2009-11-04 21:44:48 +00:00
|
|
|
|
|
|
|
if (key_dest == key_console)
|
|
|
|
Con_DrawConsole(vid_conheight.value/2, false);
|
2011-05-15 13:23:13 +00:00
|
|
|
GL_EndRendering ();
|
2009-11-04 21:44:48 +00:00
|
|
|
GL_DoSwap();
|
|
|
|
RSpeedEnd(RSPEED_TOTALREFRESH);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
*/
|
|
|
|
if (Media_ShowFilm())
|
|
|
|
{
|
|
|
|
M_Draw(0);
|
2011-12-23 03:12:29 +00:00
|
|
|
// V_UpdatePalette (false);
|
2009-11-04 21:44:48 +00:00
|
|
|
Media_RecordFrame();
|
2010-05-01 22:47:47 +00:00
|
|
|
// R2D_BrightenScreen();
|
2009-11-04 21:44:48 +00:00
|
|
|
IDirect3DDevice9_EndScene(pD3DDev9);
|
|
|
|
IDirect3DDevice9_Present(pD3DDev9, NULL, NULL, NULL, NULL);
|
|
|
|
RSpeedEnd(RSPEED_TOTALREFRESH);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// do 3D refresh drawing, and then update the screen
|
|
|
|
//
|
|
|
|
SCR_SetUpToDrawConsole ();
|
|
|
|
|
2010-05-01 22:47:47 +00:00
|
|
|
noworld = false;
|
2009-11-04 21:44:48 +00:00
|
|
|
nohud = false;
|
|
|
|
|
2015-08-04 15:16:24 +00:00
|
|
|
D3D9_Set2D();
|
|
|
|
|
2009-11-04 21:44:48 +00:00
|
|
|
#ifdef VM_CG
|
|
|
|
if (CG_Refresh())
|
|
|
|
nohud = true;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
#ifdef CSQC_DAT
|
2013-08-27 13:18:09 +00:00
|
|
|
if (CSQC_DrawView())
|
2009-11-04 21:44:48 +00:00
|
|
|
nohud = true;
|
|
|
|
else
|
|
|
|
#endif
|
2010-05-01 22:47:47 +00:00
|
|
|
if (uimenu != 1)
|
2009-11-04 21:44:48 +00:00
|
|
|
{
|
2010-05-01 22:47:47 +00:00
|
|
|
if (r_worldentity.model && cls.state == ca_active)
|
|
|
|
V_RenderView ();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
noworld = true;
|
|
|
|
}
|
2009-11-04 21:44:48 +00:00
|
|
|
}
|
|
|
|
|
2010-05-01 22:47:47 +00:00
|
|
|
R2D_BrightenScreen();
|
2009-11-04 21:44:48 +00:00
|
|
|
|
2010-05-01 22:47:47 +00:00
|
|
|
scr_con_forcedraw = false;
|
|
|
|
if (noworld)
|
|
|
|
{
|
|
|
|
if (scr_con_current != vid.height)
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_ConsoleBackground(0, vid.height, true);
|
2010-05-01 22:47:47 +00:00
|
|
|
else
|
|
|
|
scr_con_forcedraw = true;
|
|
|
|
|
|
|
|
nohud = true;
|
|
|
|
}
|
2009-11-04 21:44:48 +00:00
|
|
|
|
|
|
|
SCR_DrawTwoDimensional(uimenu, nohud);
|
|
|
|
|
2011-12-23 03:12:29 +00:00
|
|
|
V_UpdatePalette (false);
|
2009-11-04 21:44:48 +00:00
|
|
|
Media_RecordFrame();
|
|
|
|
|
|
|
|
RSpeedEnd(RSPEED_TOTALREFRESH);
|
|
|
|
RSpeedShow();
|
|
|
|
|
2015-07-30 16:26:15 +00:00
|
|
|
if (R2D_Flush)
|
|
|
|
R2D_Flush();
|
2009-11-04 21:44:48 +00:00
|
|
|
|
|
|
|
d3d9error(IDirect3DDevice9_EndScene(pD3DDev9));
|
|
|
|
d3d9error(IDirect3DDevice9_Present(pD3DDev9, NULL, NULL, NULL, NULL));
|
|
|
|
|
|
|
|
window_center_x = (window_rect.left + window_rect.right)/2;
|
|
|
|
window_center_y = (window_rect.top + window_rect.bottom)/2;
|
|
|
|
|
|
|
|
|
2012-10-14 11:20:14 +00:00
|
|
|
INS_UpdateGrabs(modestate != MS_WINDOWED, ActiveApp);
|
2009-11-04 21:44:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void (D3D9_Draw_Init) (void)
|
|
|
|
{
|
|
|
|
R2D_Init();
|
|
|
|
}
|
2012-05-09 15:30:53 +00:00
|
|
|
static void (D3D9_Draw_Shutdown) (void)
|
2009-11-04 21:44:48 +00:00
|
|
|
{
|
2012-07-05 19:42:36 +00:00
|
|
|
R2D_Shutdown();
|
2015-01-21 18:18:37 +00:00
|
|
|
Image_Shutdown();
|
2009-11-04 21:44:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void (D3D9_R_Init) (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static void (D3D9_R_DeInit) (void)
|
|
|
|
{
|
2014-09-17 03:23:03 +00:00
|
|
|
R_GAliasFlushSkinCache(true);
|
2009-11-07 13:29:15 +00:00
|
|
|
Surf_DeInit();
|
2011-10-27 16:16:29 +00:00
|
|
|
Shader_Shutdown();
|
2009-11-07 13:29:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-30 08:55:06 +00:00
|
|
|
static void D3D9_SetupViewPortProjection(void)
|
2009-11-07 13:29:15 +00:00
|
|
|
{
|
|
|
|
extern cvar_t gl_mindist;
|
|
|
|
float screenaspect;
|
|
|
|
int x, x2, y2, y, w, h;
|
|
|
|
|
|
|
|
float fov_x, fov_y;
|
|
|
|
|
|
|
|
D3DVIEWPORT9 vport;
|
|
|
|
|
|
|
|
AngleVectors (r_refdef.viewangles, vpn, vright, vup);
|
|
|
|
VectorCopy (r_refdef.vieworg, r_origin);
|
|
|
|
|
|
|
|
//
|
|
|
|
// set up viewpoint
|
|
|
|
//
|
|
|
|
x = r_refdef.vrect.x * vid.pixelwidth/(int)vid.width;
|
|
|
|
x2 = (r_refdef.vrect.x + r_refdef.vrect.width) * vid.pixelwidth/(int)vid.width;
|
|
|
|
y = (r_refdef.vrect.y) * vid.pixelheight/(int)vid.height;
|
|
|
|
y2 = ((int)(r_refdef.vrect.y + r_refdef.vrect.height)) * vid.pixelheight/(int)vid.height;
|
|
|
|
|
|
|
|
// fudge around because of frac screen scale
|
|
|
|
if (x > 0)
|
|
|
|
x--;
|
|
|
|
if (x2 < vid.pixelwidth)
|
|
|
|
x2++;
|
|
|
|
if (y < 0)
|
|
|
|
y--;
|
|
|
|
if (y2 < vid.pixelheight)
|
|
|
|
y2++;
|
|
|
|
|
|
|
|
w = x2 - x;
|
|
|
|
h = y2 - y;
|
|
|
|
|
|
|
|
vport.X = x;
|
|
|
|
vport.Y = y;
|
|
|
|
vport.Width = w;
|
|
|
|
vport.Height = h;
|
|
|
|
vport.MinZ = 0;
|
|
|
|
vport.MaxZ = 1;
|
|
|
|
IDirect3DDevice9_SetViewport(pD3DDev9, &vport);
|
|
|
|
|
|
|
|
fov_x = r_refdef.fov_x;//+sin(cl.time)*5;
|
|
|
|
fov_y = r_refdef.fov_y;//-sin(cl.time+1)*5;
|
|
|
|
|
2015-08-11 09:14:33 +00:00
|
|
|
if ((r_refdef.flags & RDF_UNDERWATER) && !(r_refdef.flags & RDF_WATERWARP))
|
2009-11-07 13:29:15 +00:00
|
|
|
{
|
|
|
|
fov_x *= 1 + (((sin(cl.time * 4.7) + 1) * 0.015) * r_waterwarp.value);
|
|
|
|
fov_y *= 1 + (((sin(cl.time * 3.0) + 1) * 0.015) * r_waterwarp.value);
|
|
|
|
}
|
|
|
|
|
|
|
|
screenaspect = (float)r_refdef.vrect.width/r_refdef.vrect.height;
|
|
|
|
|
2010-11-11 18:22:49 +00:00
|
|
|
/*view matrix*/
|
2011-07-31 11:18:49 +00:00
|
|
|
Matrix4x4_CM_ModelViewMatrixFromAxis(r_refdef.m_view, vpn, vright, vup, r_refdef.vieworg);
|
2010-11-11 18:22:49 +00:00
|
|
|
d3d9error(IDirect3DDevice9_SetTransform(pD3DDev9, D3DTS_VIEW, (D3DMATRIX*)r_refdef.m_view));
|
2009-11-07 13:29:15 +00:00
|
|
|
|
2010-11-11 18:22:49 +00:00
|
|
|
/*d3d projection matricies scale depth to 0 to 1*/
|
2011-09-03 03:49:43 +00:00
|
|
|
Matrix4x4_CM_Projection_Inf(d3d_trueprojection, fov_x, fov_y, gl_mindist.value/2);
|
|
|
|
d3d9error(IDirect3DDevice9_SetTransform(pD3DDev9, D3DTS_PROJECTION, (D3DMATRIX*)d3d_trueprojection));
|
2010-11-11 18:22:49 +00:00
|
|
|
/*ogl projection matricies scale depth to -1 to 1, and I would rather my code used consistant culling*/
|
2011-07-31 11:18:49 +00:00
|
|
|
Matrix4x4_CM_Projection_Inf(r_refdef.m_projection, fov_x, fov_y, gl_mindist.value);
|
2009-11-04 21:44:48 +00:00
|
|
|
}
|
2009-11-04 23:20:50 +00:00
|
|
|
|
2009-11-04 21:44:48 +00:00
|
|
|
static void (D3D9_R_RenderView) (void)
|
|
|
|
{
|
2014-03-30 08:55:06 +00:00
|
|
|
Surf_SetupFrame();
|
|
|
|
|
2015-08-11 09:14:33 +00:00
|
|
|
//check if we can do underwater warp
|
|
|
|
if (cls.protocol != CP_QUAKE2) //quake2 tells us directly
|
|
|
|
{
|
|
|
|
if (r_viewcontents & FTECONTENTS_FLUID)
|
|
|
|
r_refdef.flags |= RDF_UNDERWATER;
|
|
|
|
else
|
|
|
|
r_refdef.flags &= ~RDF_UNDERWATER;
|
|
|
|
}
|
|
|
|
if (r_refdef.flags & RDF_UNDERWATER)
|
|
|
|
{
|
|
|
|
extern cvar_t r_projection;
|
|
|
|
if (!r_waterwarp.value || r_projection.ival)
|
|
|
|
r_refdef.flags &= ~RDF_UNDERWATER; //no warp at all
|
|
|
|
// else if (r_waterwarp.value > 0 && scenepp_waterwarp)
|
|
|
|
// r_refdef.flags |= RDF_WATERWARP; //try fullscreen warp instead if we can
|
|
|
|
}
|
|
|
|
|
2014-03-30 08:55:06 +00:00
|
|
|
D3D9_SetupViewPortProjection();
|
|
|
|
|
2015-07-31 13:23:32 +00:00
|
|
|
// if (r_clear.ival && !(r_refdef.flags & RDF_NOWORLDMODEL))
|
|
|
|
// d3d9error(IDirect3DDevice9_Clear(pD3DDev9, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255,0,0), 1, 0));
|
|
|
|
// else
|
2010-11-11 18:22:49 +00:00
|
|
|
d3d9error(IDirect3DDevice9_Clear(pD3DDev9, 0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1, 0));
|
2014-03-30 08:55:06 +00:00
|
|
|
|
2010-10-02 02:25:39 +00:00
|
|
|
R_SetFrustum (r_refdef.m_projection, r_refdef.m_view);
|
2010-11-10 03:32:47 +00:00
|
|
|
RQ_BeginFrame();
|
2014-03-31 17:06:41 +00:00
|
|
|
if (!(r_refdef.flags & RDF_NOWORLDMODEL))
|
2010-11-10 03:32:47 +00:00
|
|
|
{
|
|
|
|
if (cl.worldmodel)
|
|
|
|
P_DrawParticles ();
|
|
|
|
}
|
2011-12-23 03:12:29 +00:00
|
|
|
Surf_DrawWorld();
|
2010-11-02 23:17:25 +00:00
|
|
|
RQ_RenderBatchClear();
|
2012-09-30 05:52:03 +00:00
|
|
|
|
|
|
|
D3D9_Set2D ();
|
2009-11-04 21:44:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void (D3D9_R_NewMap) (void);
|
|
|
|
void (D3D9_R_PreNewMap) (void);
|
|
|
|
|
|
|
|
void (D3D9_R_PushDlights) (void);
|
|
|
|
void (D3D9_R_AddStain) (vec3_t org, float red, float green, float blue, float radius);
|
|
|
|
void (D3D9_R_LessenStains) (void);
|
|
|
|
|
|
|
|
qboolean (D3D9_VID_Init) (rendererstate_t *info, unsigned char *palette);
|
|
|
|
void (D3D9_VID_DeInit) (void);
|
|
|
|
void (D3D9_VID_SetPalette) (unsigned char *palette);
|
|
|
|
void (D3D9_VID_ShiftPalette) (unsigned char *palette);
|
|
|
|
void (D3D9_VID_SetWindowCaption) (char *msg);
|
|
|
|
|
|
|
|
void (D3D9_SCR_UpdateScreen) (void);
|
|
|
|
|
2014-02-07 14:57:07 +00:00
|
|
|
void D3D9BE_RenderToTextureUpdate2d(qboolean destchanged)
|
|
|
|
{
|
|
|
|
}
|
2009-11-04 21:44:48 +00:00
|
|
|
|
2012-09-30 05:52:03 +00:00
|
|
|
rendererinfo_t d3d9rendererinfo =
|
2009-11-04 21:44:48 +00:00
|
|
|
{
|
2012-09-30 05:52:03 +00:00
|
|
|
"Direct3D9",
|
2009-11-04 21:44:48 +00:00
|
|
|
{
|
2012-09-30 05:52:03 +00:00
|
|
|
"D3D9",
|
2009-11-04 21:44:48 +00:00
|
|
|
"D3D",
|
|
|
|
"Direct3d",
|
|
|
|
"DirectX",
|
|
|
|
},
|
2012-09-30 05:52:03 +00:00
|
|
|
QR_DIRECT3D9,
|
2009-11-04 21:44:48 +00:00
|
|
|
|
|
|
|
D3D9_Draw_Init,
|
2012-05-09 15:30:53 +00:00
|
|
|
D3D9_Draw_Shutdown,
|
2009-11-04 21:44:48 +00:00
|
|
|
|
2014-10-05 20:04:11 +00:00
|
|
|
D3D9_UpdateFiltering,
|
|
|
|
D3D9_LoadTextureMips,
|
2010-11-02 23:17:25 +00:00
|
|
|
D3D9_DestroyTexture,
|
|
|
|
|
2009-11-04 23:20:50 +00:00
|
|
|
D3D9_R_Init,
|
2009-11-04 21:44:48 +00:00
|
|
|
D3D9_R_DeInit,
|
|
|
|
D3D9_R_RenderView,
|
|
|
|
|
|
|
|
D3D9_VID_Init,
|
|
|
|
D3D9_VID_DeInit,
|
2014-03-30 08:55:06 +00:00
|
|
|
D3D9_VID_SwapBuffers,
|
2013-05-11 14:02:55 +00:00
|
|
|
D3D9_VID_ApplyGammaRamps,
|
2014-09-02 02:44:43 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2009-11-04 21:44:48 +00:00
|
|
|
D3D9_VID_SetWindowCaption,
|
2014-03-30 08:55:06 +00:00
|
|
|
D3D9_VID_GetRGBInfo,
|
2009-11-04 21:44:48 +00:00
|
|
|
|
|
|
|
D3D9_SCR_UpdateScreen,
|
|
|
|
|
2012-09-30 05:52:03 +00:00
|
|
|
D3D9BE_SelectMode,
|
|
|
|
D3D9BE_DrawMesh_List,
|
|
|
|
D3D9BE_DrawMesh_Single,
|
|
|
|
D3D9BE_SubmitBatch,
|
|
|
|
D3D9BE_GetTempBatch,
|
|
|
|
D3D9BE_DrawWorld,
|
|
|
|
D3D9BE_Init,
|
|
|
|
D3D9BE_GenBrushModelVBO,
|
|
|
|
D3D9BE_ClearVBO,
|
|
|
|
D3D9BE_UploadAllLightmaps,
|
|
|
|
D3D9BE_SelectEntity,
|
|
|
|
D3D9BE_SelectDLight,
|
2013-06-23 02:17:02 +00:00
|
|
|
D3D9BE_Scissor,
|
2012-09-30 05:52:03 +00:00
|
|
|
D3D9BE_LightCullModel,
|
2011-01-23 03:44:49 +00:00
|
|
|
|
2013-04-06 03:36:00 +00:00
|
|
|
D3D9BE_VBO_Begin,
|
|
|
|
D3D9BE_VBO_Data,
|
|
|
|
D3D9BE_VBO_Finish,
|
|
|
|
D3D9BE_VBO_Destroy,
|
|
|
|
|
2014-02-07 14:57:07 +00:00
|
|
|
D3D9BE_RenderToTextureUpdate2d,
|
|
|
|
|
2009-11-04 21:44:48 +00:00
|
|
|
"no more"
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|