Fixed up some stuff so it actually compiles now. Also corrected pixel offsets on d3d chars so fonts are like in GL. Removed the unneeded gl_ppl file.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3403 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2009-11-04 23:20:50 +00:00
parent 260713ec34
commit f6b3416ce7
11 changed files with 66 additions and 5714 deletions

View file

@ -6,8 +6,11 @@
refdef_t r_refdef; refdef_t r_refdef;
vec3_t r_origin, vpn, vright, vup; vec3_t r_origin, vpn, vright, vup;
entity_t r_worldentity; entity_t r_worldentity;
entity_t *currententity; entity_t *currententity; //nnggh
model_t *currentmodel; //fixme: remove? or fix.
int sh_shadowframe; //index for msurf->shadowframe int sh_shadowframe; //index for msurf->shadowframe
int r_framecount;
struct texture_s *r_notexture_mip;
void R_InitParticleTexture (void); void R_InitParticleTexture (void);

View file

@ -63,6 +63,8 @@ FTE_DEPRECATED unsigned conheight;
unsigned pixelwidth; unsigned pixelwidth;
unsigned pixelheight; unsigned pixelheight;
float pixeloffset; //Add this to the 1:1 vertex coord to place quads and stuff in the right places.
} viddef_t; } viddef_t;
extern viddef_t vid; // global video state extern viddef_t vid; // global video state

View file

@ -1198,17 +1198,17 @@ void Matrix4_OrthographicD3D(float *proj, float xmin, float xmax, float ymax, fl
proj[0] = 2/(xmax-xmin); proj[0] = 2/(xmax-xmin);
proj[4] = 0; proj[4] = 0;
proj[8] = 0; proj[8] = 0;
proj[12] = (xmax+xmin)/(xmax-xmin); proj[12] = (xmax+xmin)/(xmin-xmax);
proj[1] = 0; proj[1] = 0;
proj[5] = 2/(ymax-ymin); proj[5] = 2/(ymax-ymin);
proj[9] = 0; proj[9] = 0;
proj[13] = (ymax+ymin)/(ymax-ymin); proj[13] = (ymax+ymin)/(ymin-ymax);
proj[2] = 0; proj[2] = 0;
proj[6] = 0; proj[6] = 0;
proj[10] = -2/(zfar-znear); proj[10] = 1/(znear-zfar);
proj[14] = (zfar+znear)/(zfar-znear); proj[14] = znear/(znear-zfar);
proj[3] = 0; proj[3] = 0;
proj[7] = 0; proj[7] = 0;

View file

@ -1,4 +1,5 @@
#include "quakedef.h" #include "quakedef.h"
#ifdef D3DQUAKE
#include "shader.h" #include "shader.h"
#include <d3d9.h> #include <d3d9.h>
@ -156,4 +157,5 @@ void BE_SelectMode(backendmode_t mode, unsigned int flags)
void BE_ClearVBO(vbo_t *vbo) void BE_ClearVBO(vbo_t *vbo)
{ {
} }
#endif

View file

@ -1,5 +1,5 @@
#include "quakedef.h" #include "quakedef.h"
#ifdef D3DQUAKE
#include <d3d9.h> #include <d3d9.h>
LPDIRECT3DDEVICE9 pD3DDev9; LPDIRECT3DDEVICE9 pD3DDev9;
@ -284,3 +284,4 @@ texid_t D3D_FindTexture (char *identifier)
{ {
return r_nulltex; return r_nulltex;
} }
#endif

View file

@ -70,28 +70,6 @@ RECT window_rect;
int window_x, window_y; int window_x, window_y;
/*
struct texture_s *r_notexture_mip;
int r_framecount;
mleaf_t *r_viewleaf;
#define MAX_MOD_KNOWN 1024
int mod_numknown;
model_t mod_known[MAX_MOD_KNOWN];
model_t *loadmodel;
model_t *currentmodel;
char loadname[32];
qbyte *mod_base;
model_t *lightmodel;
int relitsurface;
mpic_t *draw_disc; // also used on sbar
int d3d9width, d3d9height;
*/
void BuildGammaTable (float g, float c); void BuildGammaTable (float g, float c);
static void D3D9_VID_GenPaletteTables (unsigned char *palette) static void D3D9_VID_GenPaletteTables (unsigned char *palette)
{ {
@ -333,10 +311,10 @@ static LRESULT WINAPI D3D9_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
case WM_SIZE: case WM_SIZE:
if (!vid_initializing) if (!vid_initializing)
{ {
GetWindowRect(mainwindow, &window_rect); GetClientRect(mainwindow, &window_rect);
// force width/height to be updated // force width/height to be updated
// glwidth = window_rect.right - window_rect.left; vid.pixelwidth = window_rect.right - window_rect.left;
// glheight = window_rect.bottom - window_rect.top; vid.pixelheight = window_rect.bottom - window_rect.top;
// Cvar_ForceCallback(&vid_conautoscale); // Cvar_ForceCallback(&vid_conautoscale);
// Cvar_ForceCallback(&vid_conwidth); // Cvar_ForceCallback(&vid_conwidth);
} }
@ -400,7 +378,7 @@ static void resetD3D9(void)
/*clear the screen to black as soon as we start up, so there's no lingering framebuffer state*/ /*clear the screen to black as soon as we start up, so there's no lingering framebuffer state*/
IDirect3DDevice9_BeginScene(pD3DDev9); IDirect3DDevice9_BeginScene(pD3DDev9);
IDirect3DDevice9_Clear(pD3DDev9, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); IDirect3DDevice9_Clear(pD3DDev9, 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
IDirect3DDevice9_EndScene(pD3DDev9); IDirect3DDevice9_EndScene(pD3DDev9);
IDirect3DDevice9_Present(pD3DDev9, NULL, NULL, NULL, NULL); IDirect3DDevice9_Present(pD3DDev9, NULL, NULL, NULL, NULL);
@ -431,6 +409,7 @@ static void initD3D9(HWND hWnd, rendererstate_t *info)
int i; int i;
int numadaptors; int numadaptors;
int err; int err;
RECT rect;
D3DADAPTER_IDENTIFIER9 inf; D3DADAPTER_IDENTIFIER9 inf;
extern cvar_t _vid_wait_override; extern cvar_t _vid_wait_override;
@ -509,6 +488,8 @@ static void initD3D9(HWND hWnd, rendererstate_t *info)
*s = 0; *s = 0;
Con_Printf("D3D9: Using device %s\n", inf.Description); Con_Printf("D3D9: Using device %s\n", inf.Description);
vid.numpages = d3dpp.BackBufferCount;
if (d3dpp.Windowed) //fullscreen we get positioned automagically. 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 { //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 //the user can figure it out from here
@ -526,7 +507,11 @@ static void initD3D9(HWND hWnd, rendererstate_t *info)
memset(&mi, 0, sizeof(mi)); memset(&mi, 0, sizeof(mi));
mi.cbSize = sizeof(mi); mi.cbSize = sizeof(mi);
pGetMonitorInfoA(hm, &mi); pGetMonitorInfoA(hm, &mi);
MoveWindow(d3dpp.hDeviceWindow, mi.rcWork.left, mi.rcWork.top, d3dpp.BackBufferWidth, d3dpp.BackBufferHeight, false); rect.left = rect.top = 0;
rect.right = d3dpp.BackBufferWidth;
rect.bottom = d3dpp.BackBufferHeight;
AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, FALSE, 0);
MoveWindow(d3dpp.hDeviceWindow, mi.rcWork.left, mi.rcWork.top, rect.right-rect.left, rect.bottom-rect.top, false);
} }
return; //successful return; //successful
} }
@ -546,6 +531,8 @@ static qboolean D3D9_VID_Init(rendererstate_t *info, unsigned char *palette)
DWORD bpp = info->bpp; DWORD bpp = info->bpp;
DWORD zbpp = 16; DWORD zbpp = 16;
DWORD flags = 0; DWORD flags = 0;
DWORD wstyle;
RECT rect;
MSG msg; MSG msg;
extern cvar_t vid_conwidth; extern cvar_t vid_conwidth;
@ -573,13 +560,16 @@ static qboolean D3D9_VID_Init(rendererstate_t *info, unsigned char *palette)
RegisterClass(&wc); RegisterClass(&wc);
if (info->fullscreen) if (info->fullscreen)
mainwindow = CreateWindow(CLASSNAME, "Direct3D", 0, 0, 0, width, height, NULL, NULL, NULL, NULL); wstyle = 0;
else else
mainwindow = CreateWindow(CLASSNAME, "Direct3D", WS_OVERLAPPEDWINDOW, 0, 0, width, height, NULL, NULL, NULL, NULL); wstyle = WS_OVERLAPPEDWINDOW;
/*
width = vid_conwidth.value; rect.left = rect.top = 0;
height = vid_conheight.value; rect.right = info->width;
*/ rect.bottom = info->height;
AdjustWindowRectEx(&rect, wstyle, FALSE, 0);
mainwindow = CreateWindow(CLASSNAME, "Direct3D", wstyle, 0, 0, rect.right-rect.left, rect.bottom-rect.top, NULL, NULL, NULL, NULL);
// Try as specified. // Try as specified.
initD3D9(mainwindow, info); initD3D9(mainwindow, info);
@ -608,6 +598,7 @@ static qboolean D3D9_VID_Init(rendererstate_t *info, unsigned char *palette)
// pD3DX->lpVtbl->GetBufferSize((void*)pD3DX, &width, &height); // pD3DX->lpVtbl->GetBufferSize((void*)pD3DX, &width, &height);
vid.pixelwidth = width; vid.pixelwidth = width;
vid.pixelheight = height; vid.pixelheight = height;
vid.pixeloffset = -0.5;
vid.recalc_refdef = true; vid.recalc_refdef = true;
vid.width = vid.conwidth = width; vid.width = vid.conwidth = width;
@ -627,7 +618,7 @@ static qboolean D3D9_VID_Init(rendererstate_t *info, unsigned char *palette)
resetD3D9(); resetD3D9();
/*
IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRS_ALPHAFUNC, D3DCMP_GREATER ); IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRS_ALPHAFUNC, D3DCMP_GREATER );
@ -645,7 +636,7 @@ resetD3D9();
IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRS_ZFUNC, D3DCMP_LESSEQUAL); IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
*/
GetWindowRect(mainwindow, &window_rect); GetWindowRect(mainwindow, &window_rect);
@ -778,7 +769,6 @@ static void D3D9_Set2D (void)
// IDirect3DDevice9_EndScene(pD3DDev9); // IDirect3DDevice9_EndScene(pD3DDev9);
Matrix4_OrthographicD3D(m, 0, vid.width, 0, vid.height, -100, 100); Matrix4_OrthographicD3D(m, 0, vid.width, 0, vid.height, -100, 100);
d3dx_ortho(m);
IDirect3DDevice9_SetTransform(pD3DDev9, D3DTS_PROJECTION, (D3DMATRIX*)m); IDirect3DDevice9_SetTransform(pD3DDev9, D3DTS_PROJECTION, (D3DMATRIX*)m);
Matrix4_Identity(m); Matrix4_Identity(m);
@ -1138,9 +1128,7 @@ static void (D3D9_R_Init) (void)
static void (D3D9_R_DeInit) (void) static void (D3D9_R_DeInit) (void)
{ {
} }
static void (D3D9_R_ReInit) (void)
{
}
static void (D3D9_R_RenderView) (void) static void (D3D9_R_RenderView) (void)
{ {
d3d9error(IDirect3DDevice9_Clear(pD3DDev9, 0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1, 0)); d3d9error(IDirect3DDevice9_Clear(pD3DDev9, 0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1, 0));
@ -1184,29 +1172,28 @@ rendererinfo_t d3drendererinfo =
}, },
QR_DIRECT3D, QR_DIRECT3D,
R_SafePicFromWad, R2D_SafePicFromWad,
R_SafeCachePic, R2D_SafeCachePic,
D3D9_Draw_Init, D3D9_Draw_Init,
D3D9_Draw_ReInit, D3D9_Draw_ReInit,
D3D9_Draw_Crosshair, D3D9_Draw_Crosshair,
R_ScalePic, R2D_ScalePic,
R_SubPic, R2D_SubPic,
D3D9_Draw_TransPicTranslate, D3D9_Draw_TransPicTranslate,
R_ConsoleBackground, R2D_ConsoleBackground,
R_EditorBackground, R2D_EditorBackground,
R_TileClear, R2D_TileClear,
D3D9_Draw_Fill, D3D9_Draw_Fill,
D3D9_Draw_FillRGB, D3D9_Draw_FillRGB,
D3D9_Draw_FadeScreen, D3D9_Draw_FadeScreen,
D3D9_Draw_BeginDisc, D3D9_Draw_BeginDisc,
D3D9_Draw_EndDisc, D3D9_Draw_EndDisc,
R_Image, R2D_Image,
R_ImageColours, R2D_ImageColours,
R2D_Init, D3D9_R_Init,
D3D9_R_DeInit, D3D9_R_DeInit,
D3D9_R_ReInit,
D3D9_R_RenderView, D3D9_R_RenderView,
D3D9_R_NewMap, D3D9_R_NewMap,

View file

@ -29369,44 +29369,16 @@
Name="d3d" Name="d3d"
> >
<File <File
RelativePath="..\d3dm\d3d_backend.c" RelativePath="..\d3d\d3d_backend.c"
>
<FileConfiguration
Name="GLDebug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\d3dm\d3d_image.c"
>
<FileConfiguration
Name="GLDebug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\d3dm\d3d_sucks.c"
> >
</File> </File>
<File <File
RelativePath="..\d3dm\vid_d3d.c" RelativePath="..\d3d\d3d_image.c"
>
</File>
<File
RelativePath="..\d3d\vid_d3d.c"
> >
<FileConfiguration
Name="GLDebug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File> </File>
</Filter> </Filter>
</Filter> </Filter>

View file

@ -1033,8 +1033,8 @@ int Font_DrawChar(int px, int py, unsigned int charcode)
if (c->texplane >= DEFAULTPLANE) if (c->texplane >= DEFAULTPLANE)
{ {
sx = ((px+c->left)*(int)vid.width) / (float)vid.pixelwidth; sx = ((px+vid.pixeloffset+c->left)*(int)vid.width) / (float)vid.pixelwidth;
sy = ((py+c->top)*(int)vid.height) / (float)vid.pixelheight; sy = ((py+vid.pixeloffset+c->top)*(int)vid.height) / (float)vid.pixelheight;
sw = ((curfont->charheight)*vid.width) / (float)vid.pixelwidth; sw = ((curfont->charheight)*vid.width) / (float)vid.pixelwidth;
sh = ((curfont->charheight)*vid.height) / (float)vid.pixelheight; sh = ((curfont->charheight)*vid.height) / (float)vid.pixelheight;
@ -1045,10 +1045,10 @@ int Font_DrawChar(int px, int py, unsigned int charcode)
} }
else else
{ {
sx = ((px+c->left)*(int)vid.width) / (float)vid.pixelwidth; sx = ((px-0.5+c->left)*(int)vid.width) / (float)vid.pixelwidth;
sy = ((py+c->top)*(int)vid.height) / (float)vid.pixelheight; sy = ((py-0.5+c->top)*(int)vid.height) / (float)vid.pixelheight;
sw = ((c->bmw)*vid.width) / (float)vid.pixelwidth; sw = ((c->bmw+1)*vid.width) / (float)vid.pixelwidth;
sh = ((c->bmh)*vid.height) / (float)vid.pixelheight; sh = ((c->bmh+1)*vid.height) / (float)vid.pixelheight;
v = Font_BeginChar(fontplanes.texnum[c->texplane]); v = Font_BeginChar(fontplanes.texnum[c->texplane]);
} }

File diff suppressed because it is too large Load diff

View file

@ -46,7 +46,7 @@ entity_t r_worldentity;
vec3_t modelorg, r_entorigin; vec3_t modelorg, r_entorigin;
int r_visframecount; // bumped when going to a new PVS int r_visframecount; // bumped when going to a new PVS
int r_framecount; // used for dlight push checking extern int r_framecount; // used for dlight push checking
float r_wateralphaval; //allowed or not... float r_wateralphaval; //allowed or not...

View file

@ -501,6 +501,7 @@ qboolean VID_SetWindowedMode (rendererstate_t *info)
vid.conwidth = info->width; vid.conwidth = info->width;
vid.width = vid.conwidth; vid.width = vid.conwidth;
vid.height = vid.conheight; vid.height = vid.conheight;
vid.pixeloffset = 0;
vid.numpages = 2; vid.numpages = 2;