1
0
Fork 0
forked from fte/fteqw

fog control, vaugely similar to fitzquake, but runs slower. does at least work properly with rtlights.

fixed menutint.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3761 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2011-03-31 02:32:32 +00:00
parent a0f3482093
commit 6a4976300e
17 changed files with 287 additions and 292 deletions

View file

@ -1042,6 +1042,11 @@ void CL_ClearState (void)
// wipe the entire cl structure // wipe the entire cl structure
memset (&cl, 0, sizeof(cl)); memset (&cl, 0, sizeof(cl));
cl.fog_density = 0;
cl.fog_colour[0] = 0.3;
cl.fog_colour[1] = 0.3;
cl.fog_colour[2] = 0.3;
SZ_Clear (&cls.netchan.message); SZ_Clear (&cls.netchan.message);
r_worldentity.model = NULL; r_worldentity.model = NULL;
@ -2887,6 +2892,24 @@ void CL_FTP_f(void)
#endif #endif
*/ */
void CL_Fog_f(void)
{
if (Cmd_Argc() <= 1)
{
Con_Printf("Current fog %f (r:%f g:%f b:%f)\n", cl.fog_density, cl.fog_colour[0], cl.fog_colour[1], cl.fog_colour[2]);
}
else
{
cl.fog_density = atof(Cmd_Argv(1));
if (Cmd_Argc() > 5)
{
cl.fog_colour[0] = atof(Cmd_Argv(2));
cl.fog_colour[1] = atof(Cmd_Argv(3));
cl.fog_colour[2] = atof(Cmd_Argv(4));
}
}
}
void CL_Skygroup_f(void); void CL_Skygroup_f(void);
void SCR_ShowPic_Script_f(void); void SCR_ShowPic_Script_f(void);
/* /*
@ -3141,6 +3164,7 @@ void CL_Init (void)
Cmd_AddCommand ("topten", NULL); Cmd_AddCommand ("topten", NULL);
Cmd_AddCommand ("fog", CL_Fog_f);
Cmd_AddCommand ("kill", NULL); Cmd_AddCommand ("kill", NULL);
Cmd_AddCommand ("pause", NULL); Cmd_AddCommand ("pause", NULL);
Cmd_AddCommand ("say", CL_Say_f); Cmd_AddCommand ("say", CL_Say_f);

View file

@ -5944,10 +5944,10 @@ void CLNQ_ParseServerMessage (void)
Cmd_ExecuteString("bf", RESTRICT_RCON); Cmd_ExecuteString("bf", RESTRICT_RCON);
break; break;
case svcfitz_fog: case svcfitz_fog:
/*density =*/ MSG_ReadByte(); cl.fog_density = MSG_ReadByte();
/*red =*/ MSG_ReadByte(); cl.fog_colour[0] = MSG_ReadByte()/255.0f;
/*green =*/ MSG_ReadByte(); cl.fog_colour[1] = MSG_ReadByte()/255.0f;
/*blue =*/ MSG_ReadByte(); cl.fog_colour[2] = MSG_ReadByte()/255.0f;
/*time =*/ MSG_ReadShort(); /*time =*/ MSG_ReadShort();
break; break;
case svcfitz_spawnbaseline2: case svcfitz_spawnbaseline2:

View file

@ -590,6 +590,9 @@ typedef struct
float skyrotate; float skyrotate;
vec3_t skyaxis; vec3_t skyaxis;
float fog_density;
vec3_t fog_colour;
char levelname[40]; // for display on solo scoreboard char levelname[40]; // for display on solo scoreboard
int playernum[MAX_SPLITS]; int playernum[MAX_SPLITS];
qboolean nolocalplayer[MAX_SPLITS]; qboolean nolocalplayer[MAX_SPLITS];

View file

@ -88,9 +88,20 @@ void R2D_Init(void)
missing_texture = R_LoadTexture8("no_texture", 16, 16, (unsigned char*)r_notexture_mip + r_notexture_mip->offsets[0], IF_NOALPHA|IF_NOGAMMA, 0); missing_texture = R_LoadTexture8("no_texture", 16, 16, (unsigned char*)r_notexture_mip + r_notexture_mip->offsets[0], IF_NOALPHA|IF_NOGAMMA, 0);
draw_backtile = R2D_SafePicFromWad ("backtile"); draw_backtile = R_RegisterShader("gfx/backtile.lmp",
if (!draw_backtile) "{\n"
draw_backtile = R2D_SafeCachePic ("gfx/menu/backtile.lmp"); #ifdef USE_EGL
"program default2d\n"
#endif
"nomipmaps\n"
"{\n"
"map $diffuse\n"
"}\n"
"}\n");
if (!TEXVALID(draw_backtile->defaulttextures.base))
draw_backtile->defaulttextures.base = R_LoadHiResTexture("gfx/backtile", NULL, IF_NOPICMIP|IF_NOMIPMAP);
if (!TEXVALID(draw_backtile->defaulttextures.base))
draw_backtile->defaulttextures.base = R_LoadHiResTexture("gfx/menu/backtile", NULL, IF_NOPICMIP|IF_NOMIPMAP);
shader_draw_fill = R_RegisterShader("fill_opaque", shader_draw_fill = R_RegisterShader("fill_opaque",
"{\n" "{\n"
@ -136,13 +147,17 @@ void R2D_Init(void)
"{\n" "{\n"
"#ifdef VERTEX_SHADER\n" "#ifdef VERTEX_SHADER\n"
"\ "\
uniform mat4 m_view;\
uniform mat4 m_projection;\
attribute vec3 v_position;\
attribute vec2 v_texcoord;\
varying vec2 texcoord;\ varying vec2 texcoord;\
uniform vec3 rendertexturescale;\ uniform vec3 rendertexturescale;\
void main(void)\ void main(void)\
{\ {\
texcoord.x = gl_MultiTexCoord0.x*rendertexturescale.x;\ texcoord.x = v_texcoord.x*rendertexturescale.x;\
texcoord.y = (1-gl_MultiTexCoord0.y)*rendertexturescale.y;\ texcoord.y = (1.0-v_texcoord.y)*rendertexturescale.y;\
gl_Position = ftransform();\ gl_Position = m_projection * m_view * vec4(v_position, 1.0);\
}\ }\
\n" \n"
"#endif\n" "#endif\n"
@ -150,13 +165,13 @@ void R2D_Init(void)
"\ "\
varying vec2 texcoord;\ varying vec2 texcoord;\
uniform vec3 colorparam;\ uniform vec3 colorparam;\
uniform sampler2D source;\ uniform sampler2D s_t0;\
uniform int invert;\ uniform int invert;\
const vec3 lumfactors = vec3(0.299, 0.587, 0.114);\ const vec3 lumfactors = vec3(0.299, 0.587, 0.114);\
const vec3 invertvec = vec3(1.0, 1.0, 1.0);\ const vec3 invertvec = vec3(1.0, 1.0, 1.0);\
void main(void)\ void main(void)\
{\ {\
vec3 texcolor = texture2D(source, texcoord).rgb;\ vec3 texcolor = texture2D(s_t0, texcoord).rgb;\
float luminance = dot(lumfactors, texcolor);\ float luminance = dot(lumfactors, texcolor);\
texcolor = vec3(luminance, luminance, luminance);\ texcolor = vec3(luminance, luminance, luminance);\
texcolor *= colorparam;\ texcolor *= colorparam;\
@ -167,7 +182,6 @@ void R2D_Init(void)
"}\n" "}\n"
"param cvari r_menutint_inverse invert\n" "param cvari r_menutint_inverse invert\n"
"param cvar3f r_menutint colorparam\n" "param cvar3f r_menutint colorparam\n"
"param texture 0 source\n"
"param rendertexturescale rendertexturescale\n" "param rendertexturescale rendertexturescale\n"
"{\n" "{\n"
@ -402,7 +416,7 @@ void R2D_TileClear (int x, int y, int w, int h)
draw_mesh_st[3][0] = newsl; draw_mesh_st[3][0] = newsl;
draw_mesh_st[3][1] = newth; draw_mesh_st[3][1] = newth;
BE_DrawMesh_Single(draw_backtile, &draw_mesh, NULL, NULL); BE_DrawMesh_Single(draw_backtile, &draw_mesh, NULL, &draw_backtile->defaulttextures);
} }
void R2D_Conback_Callback(struct cvar_s *var, char *oldvalue) void R2D_Conback_Callback(struct cvar_s *var, char *oldvalue)

View file

@ -144,6 +144,10 @@ typedef struct
float m_projection[16]; float m_projection[16];
float m_view[16]; float m_view[16];
vec3_t gfog_rgb;
float gfog_alpha;
float gfog_density;
vrect_t pxrect; /*vrect, but in pixels rather than virtual coords*/ vrect_t pxrect; /*vrect, but in pixels rather than virtual coords*/
qboolean externalview; /*draw external models and not viewmodels*/ qboolean externalview; /*draw external models and not viewmodels*/
qboolean recurse; /*in a mirror/portal/half way through drawing something else*/ qboolean recurse; /*in a mirror/portal/half way through drawing something else*/

View file

@ -197,7 +197,7 @@ extern cvar_t r_drawentities;
extern cvar_t r_drawviewmodel; extern cvar_t r_drawviewmodel;
extern cvar_t r_drawworld; extern cvar_t r_drawworld;
extern cvar_t r_fullbright; extern cvar_t r_fullbright;
cvar_t r_mirroralpha = SCVARF("r_mirroralpha","1", CVAR_CHEAT); cvar_t r_mirroralpha = SCVARF("r_mirroralpha","1", CVAR_CHEAT|CVAR_SHADERSYSTEM);
extern cvar_t r_netgraph; extern cvar_t r_netgraph;
extern cvar_t r_norefresh; extern cvar_t r_norefresh;
extern cvar_t r_novis; extern cvar_t r_novis;
@ -349,7 +349,6 @@ void GLRenderer_Init(void)
Cvar_Register (&vid_desktopgamma, GLRENDEREROPTIONS); Cvar_Register (&vid_desktopgamma, GLRENDEREROPTIONS);
//renderer //renderer
Cvar_Register (&r_mirroralpha, GLRENDEREROPTIONS);
Cvar_Register (&r_norefresh, GLRENDEREROPTIONS); Cvar_Register (&r_norefresh, GLRENDEREROPTIONS);
Cvar_Register (&gl_affinemodels, GLRENDEREROPTIONS); Cvar_Register (&gl_affinemodels, GLRENDEREROPTIONS);
@ -525,6 +524,7 @@ void Renderer_Init(void)
Cvar_Register (&vid_desktopsettings, VIDCOMMANDGROUP); Cvar_Register (&vid_desktopsettings, VIDCOMMANDGROUP);
Cvar_Register (&r_mirroralpha, GLRENDEREROPTIONS);
Cvar_Register (&r_skyboxname, GRAPHICALNICETIES); Cvar_Register (&r_skyboxname, GRAPHICALNICETIES);
Cbuf_AddText("alias sky r_skybox\n", RESTRICT_LOCAL); /*alternative name for users*/ Cbuf_AddText("alias sky r_skybox\n", RESTRICT_LOCAL); /*alternative name for users*/

View file

@ -953,6 +953,11 @@ void V_CalcRefdef (int pnum)
return; return;
#endif #endif
r_refdef.gfog_density = cl.fog_density;
r_refdef.gfog_alpha = cl.fog_density?1:0;//cl.fog_alpha;
VectorCopy(cl.fog_colour, r_refdef.gfog_rgb);
// view is the weapon model (only visible from inside body) // view is the weapon model (only visible from inside body)
view = &cl.viewent[pnum]; view = &cl.viewent[pnum];

View file

@ -631,6 +631,19 @@ void Mod_ParseInfoFromEntityLump(model_t *wmodel, char *data, char *mapname) //a
{ {
Q_strncpyz(cl.skyname, com_token, sizeof(cl.skyname)); Q_strncpyz(cl.skyname, com_token, sizeof(cl.skyname));
} }
else if (!strcmp("fog", key))
{
char *s;
Q_strncpyz(key, com_token, sizeof(key));
s = COM_Parse(key);
cl.fog_density = atof(com_token);
s = COM_Parse(s);
cl.fog_colour[0] = atof(com_token);
s = COM_Parse(s);
cl.fog_colour[1] = atof(com_token);
s = COM_Parse(s);
cl.fog_colour[2] = atof(com_token);
}
else if (!strcmp("sky", key)) // for Quake2 maps else if (!strcmp("sky", key)) // for Quake2 maps
{ {
Q_strncpyz(cl.skyname, com_token, sizeof(cl.skyname)); Q_strncpyz(cl.skyname, com_token, sizeof(cl.skyname));

View file

@ -466,7 +466,6 @@ static void D3DBE_ApplyShaderBits(unsigned int bits)
void D3DBE_Init(void) void D3DBE_Init(void)
{ {
unsigned int i;
be_maxpasses = MAX_TMUS; be_maxpasses = MAX_TMUS;
memset(&shaderstate, 0, sizeof(shaderstate)); memset(&shaderstate, 0, sizeof(shaderstate));
shaderstate.curvertdecl = -1; shaderstate.curvertdecl = -1;
@ -1499,6 +1498,21 @@ static qboolean BE_DrawMeshChain_SetupPass(shaderpass_t *pass, unsigned int vert
return true; return true;
} }
static void BE_RenderMeshProgram(unsigned int vertcount, unsigned int idxfirst, unsigned int idxcount)
{
shader_t *s = shaderstate.curshader;
shaderpass_t *pass = s->passes;
IDirect3DDevice9_SetVertexShader(pD3DDev9, s->prog->handle[0].hlsl.vert);
IDirect3DDevice9_SetPixelShader(pD3DDev9, s->prog->handle[0].hlsl.frag);
// IDirect3DDevice9_SetVertexShaderConstantF(pD3DDev9,
d3dcheck(IDirect3DDevice9_DrawIndexedPrimitive(pD3DDev9, D3DPT_TRIANGLELIST, 0, 0, vertcount, idxfirst, idxcount/3));
IDirect3DDevice9_SetVertexShader(pD3DDev9, NULL);
IDirect3DDevice9_SetPixelShader(pD3DDev9, NULL);
}
static void BE_Cull(unsigned int cullflags) static void BE_Cull(unsigned int cullflags)
{ {
cullflags |= r_refdef.flipcull; cullflags |= r_refdef.flipcull;
@ -1574,8 +1588,9 @@ static void BE_DrawMeshChain_Internal(void)
d3dcheck(IDirect3DIndexBuffer9_Unlock(shaderstate.dynidx_buff)); d3dcheck(IDirect3DIndexBuffer9_Unlock(shaderstate.dynidx_buff));
d3dcheck(IDirect3DDevice9_SetIndices(pD3DDev9, shaderstate.dynidx_buff)); d3dcheck(IDirect3DDevice9_SetIndices(pD3DDev9, shaderstate.dynidx_buff));
if (shaderstate.mode == BEM_DEPTHONLY) switch (shaderstate.mode)
{ {
case BEM_DEPTHONLY:
IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRS_COLORWRITEENABLE, 0); IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRS_COLORWRITEENABLE, 0);
/*deactivate any extras*/ /*deactivate any extras*/
for (passno = 0; passno < shaderstate.lastpasscount; ) for (passno = 0; passno < shaderstate.lastpasscount; )
@ -1588,21 +1603,29 @@ static void BE_DrawMeshChain_Internal(void)
shaderstate.lastpasscount = 0; shaderstate.lastpasscount = 0;
d3dcheck(IDirect3DDevice9_DrawIndexedPrimitive(pD3DDev9, D3DPT_TRIANGLELIST, 0, 0, vertcount, idxfirst, idxcount/3)); d3dcheck(IDirect3DDevice9_DrawIndexedPrimitive(pD3DDev9, D3DPT_TRIANGLELIST, 0, 0, vertcount, idxfirst, idxcount/3));
IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_ALPHA); IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_ALPHA);
} break;
else default:
{ case BEM_STANDARD:
/*now go through and flush each pass*/ if (shaderstate.curshader->prog)
for (passno = 0; passno < shaderstate.curshader->numpasses; passno += pass->numMergedPasses)
{ {
if (!BE_DrawMeshChain_SetupPass(pass+passno, vertcount)) BE_RenderMeshProgram(vertcount, idxfirst, idxcount);
continue;
#ifdef BENCH
shaderstate.bench.draws++;
if (shaderstate.bench.clamp && shaderstate.bench.clamp < shaderstate.bench.draws)
continue;
#endif
d3dcheck(IDirect3DDevice9_DrawIndexedPrimitive(pD3DDev9, D3DPT_TRIANGLELIST, 0, 0, vertcount, idxfirst, idxcount/3));
} }
else
{
/*now go through and flush each pass*/
for (passno = 0; passno < shaderstate.curshader->numpasses; passno += pass->numMergedPasses)
{
if (!BE_DrawMeshChain_SetupPass(pass+passno, vertcount))
continue;
#ifdef BENCH
shaderstate.bench.draws++;
if (shaderstate.bench.clamp && shaderstate.bench.clamp < shaderstate.bench.draws)
continue;
#endif
d3dcheck(IDirect3DDevice9_DrawIndexedPrimitive(pD3DDev9, D3DPT_TRIANGLELIST, 0, 0, vertcount, idxfirst, idxcount/3));
}
}
break;
} }
} }

View file

@ -5,7 +5,7 @@
DECLARE_HANDLE(HMONITOR); DECLARE_HANDLE(HMONITOR);
#endif #endif
#include <d3d9.h> #include <d3d9.h>
LPDIRECT3DDEVICE9 pD3DDev9; extern LPDIRECT3DDEVICE9 pD3DDev9;
typedef struct d3dtexture_s typedef struct d3dtexture_s
{ {
@ -133,7 +133,6 @@ static void Upload_Texture_32(LPDIRECT3DTEXTURE9 tex, unsigned int *data, int wi
unsigned char swapbuf[4]; unsigned char swapbuf[4];
unsigned char swapbuf2[4]; unsigned char swapbuf2[4];
D3DLOCKED_RECT lock; D3DLOCKED_RECT lock;
int i;
D3DSURFACE_DESC desc; D3DSURFACE_DESC desc;
IDirect3DTexture9_GetLevelDesc(tex, 0, &desc); IDirect3DTexture9_GetLevelDesc(tex, 0, &desc);

View file

@ -347,7 +347,20 @@ static LRESULT WINAPI D3D9_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
IN_RawInput_Read((HANDLE)lParam); IN_RawInput_Read((HANDLE)lParam);
break; break;
case WM_SIZE: 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:
if (!vid_initializing) if (!vid_initializing)
{ {
extern cvar_t vid_conautoscale, vid_conwidth; extern cvar_t vid_conautoscale, vid_conwidth;
@ -529,7 +542,7 @@ static qboolean initD3D9Device(HWND hWnd, rendererstate_t *info, unsigned int de
char *s; char *s;
for (s = inf.Description + strlen(inf.Description)-1; s >= inf.Description && *s <= ' '; s--) for (s = inf.Description + strlen(inf.Description)-1; s >= inf.Description && *s <= ' '; s--)
*s = 0; *s = 0;
Con_Printf("D3D9: Using device %s\n", inf.Description); Con_Printf("D3D9: %s\n", inf.Description);
vid.numpages = d3dpp.BackBufferCount; vid.numpages = d3dpp.BackBufferCount;
@ -555,6 +568,8 @@ static qboolean initD3D9Device(HWND hWnd, rendererstate_t *info, unsigned int de
rect.bottom = d3dpp.BackBufferHeight; rect.bottom = d3dpp.BackBufferHeight;
AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, FALSE, 0); AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, FALSE, 0);
MoveWindow(d3dpp.hDeviceWindow, mi.rcWork.left, mi.rcWork.top, rect.right-rect.left, rect.bottom-rect.top, false); MoveWindow(d3dpp.hDeviceWindow, mi.rcWork.left, mi.rcWork.top, rect.right-rect.left, rect.bottom-rect.top, false);
D3DShader_Init();
} }
return true; //successful return true; //successful
} }

View file

@ -11361,176 +11361,6 @@
/> />
</FileConfiguration> </FileConfiguration>
</File> </File>
<File
RelativePath="..\client\r_bulleten.c"
>
<FileConfiguration
Name="MinGLDebug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="MinGLDebug|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="D3DDebug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="D3DDebug|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="MinGLRelease|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="MinGLRelease|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="GLDebug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="GLDebug|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release Dedicated Server|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release Dedicated Server|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="MRelease|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="MRelease|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug Dedicated Server|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug Dedicated Server|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="MDebug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="MDebug|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="GLRelease|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="GLRelease|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File <File
RelativePath="..\client\r_part.c" RelativePath="..\client\r_part.c"
> >
@ -14105,13 +13935,6 @@
<File <File
RelativePath="..\client\snd_al.c" RelativePath="..\client\snd_al.c"
> >
<FileConfiguration
Name="D3DDebug|x64"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration <FileConfiguration
Name="Release Dedicated Server|Win32" Name="Release Dedicated Server|Win32"
ExcludedFromBuild="true" ExcludedFromBuild="true"
@ -14128,20 +13951,6 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
/> />
</FileConfiguration> </FileConfiguration>
<FileConfiguration
Name="MRelease|Win32"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="MRelease|x64"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration <FileConfiguration
Name="Debug Dedicated Server|Win32" Name="Debug Dedicated Server|Win32"
ExcludedFromBuild="true" ExcludedFromBuild="true"
@ -14158,13 +13967,6 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
/> />
</FileConfiguration> </FileConfiguration>
<FileConfiguration
Name="MDebug|x64"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\client\snd_directx.c" RelativePath="..\client\snd_directx.c"
@ -28256,6 +28058,10 @@
RelativePath="..\d3d\d3d_image.c" RelativePath="..\d3d\d3d_image.c"
> >
</File> </File>
<File
RelativePath="..\d3d\d3d_shader.c"
>
</File>
<File <File
RelativePath="..\d3d\vid_d3d.c" RelativePath="..\d3d\vid_d3d.c"
> >

View file

@ -1,6 +1,7 @@
#include "quakedef.h" #include "quakedef.h"
//#define FORCESTATE //#define FORCESTATE
//#define WIREFRAME
#ifdef GLQUAKE #ifdef GLQUAKE
@ -432,6 +433,12 @@ void GL_SetShaderState2D(qboolean is2d)
{ {
shaderstate.updatetime = realtime; shaderstate.updatetime = realtime;
shaderstate.force2d = is2d; shaderstate.force2d = is2d;
#ifdef WIREFRAME
if (!is2d)
qglPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
else
qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
#endif
BE_SelectMode(BEM_STANDARD, 0); BE_SelectMode(BEM_STANDARD, 0);
} }
@ -928,29 +935,39 @@ void Shader_LightPass_Spot(char *shortname, shader_t *s, const void *args)
Shader_DefaultScript(shortname, s, shadertext); Shader_DefaultScript(shortname, s, shadertext);
} }
texid_t GenerateFogTexture(void) void GenerateFogTexture(texid_t *tex, float density, float zscale)
{ {
#define FOGS 256 #define FOGS 256
#define FOGT 32 #define FOGT 32
byte_vec4_t fogdata[FOGS*FOGT]; byte_vec4_t fogdata[FOGS*FOGT];
int s, t; int s, t;
float f; float f, z;
for(s = 0; s < FOGS; s++) for(s = 0; s < FOGS; s++)
for(t = 0; t < FOGT; t++) for(t = 0; t < FOGT; t++)
{ {
f = (float)s / FOGS; z = (float)s / (FOGS-1);
z *= zscale;
if (0)//q3
f = pow(f, 0.5);
else if (1)//GL_EXP
f = 1-exp(-density * z);
else //GL_EXP2
f = 1-exp(-(density*density) * z);
if (f < 0) if (f < 0)
f = 0; f = 0;
if (f > 1) if (f > 1)
f = 1; f = 1;
f = pow(f, 0.5);
fogdata[t*FOGS + s][0] = 255; fogdata[t*FOGS + s][0] = 255;
fogdata[t*FOGS + s][1] = 255; fogdata[t*FOGS + s][1] = 255;
fogdata[t*FOGS + s][2] = 255; fogdata[t*FOGS + s][2] = 255;
fogdata[t*FOGS + s][3] = 255*f; fogdata[t*FOGS + s][3] = 255*f;
} }
return R_LoadTexture32("fog", FOGS, FOGT, fogdata, IF_CLAMP|IF_NOMIPMAP); if (!TEXVALID(*tex))
*tex = R_AllocNewTexture(FOGS, FOGT);
R_Upload(*tex, "fog", TF_RGBA32, fogdata, NULL, FOGS, FOGT, IF_CLAMP|IF_NOMIPMAP);
} }
void GLBE_Init(void) void GLBE_Init(void)
@ -1001,8 +1018,7 @@ void GLBE_Init(void)
currententity = &r_worldentity; currententity = &r_worldentity;
shaderstate.fogtexture = r_nulltex;
shaderstate.fogtexture = GenerateFogTexture();
} }
//end tables //end tables
@ -2648,10 +2664,17 @@ void GLBE_SelectEntity(entity_t *ent)
qglDepthRange (gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin)); qglDepthRange (gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin));
} }
void BE_SelectFog(vec3_t colour, float alpha, float fardist) void BE_SelectFog(vec3_t colour, float alpha, float density)
{ {
float zscale;
density /= 64;
zscale = 2048; /*this value is meant to be the distance at which fog the value becomes as good as fully fogged, just hack it to 2048...*/
GenerateFogTexture(&shaderstate.fogtexture, density, zscale);
shaderstate.fogfar = 1/zscale; /*scaler for z coords*/
qglColor4f(colour[0], colour[1], colour[2], alpha); qglColor4f(colour[0], colour[1], colour[2], alpha);
shaderstate.fogfar = 1/fardist;
} }
#ifdef RTLIGHTS #ifdef RTLIGHTS
@ -3089,8 +3112,14 @@ static void BE_SubmitMeshesSortList(batch_t *sortlist)
if (batch->shader->flags & SHADER_SKY) if (batch->shader->flags & SHADER_SKY)
{ {
if (shaderstate.mode == BEM_STANDARD) if (shaderstate.mode == BEM_STANDARD)
R_DrawSkyChain (batch); {
if (shaderstate.mode != BEM_FOG) if (!batch->shader->prog)
{
R_DrawSkyChain (batch);
continue;
}
}
else if (shaderstate.mode != BEM_FOG)
continue; continue;
} }
@ -3311,29 +3340,11 @@ void GLBE_DrawWorld (qbyte *vis)
BE_DrawPolys(false); BE_DrawPolys(false);
if (1)//gl_fog.value) if (r_refdef.gfog_alpha)
{ {
cvar_t *v; BE_SelectMode(BEM_FOG, 0);
vec3_t rgb; BE_SelectFog(r_refdef.gfog_rgb, r_refdef.gfog_alpha, r_refdef.gfog_density);
float alpha; GLBE_SubmitMeshes(true, batches);
float fardist;
v = Cvar_Get("_gl_fog", "0", 0, "experimental");
if (v->value)
{
v = Cvar_Get("_gl_fog_red", "1", 0, "experimental");
rgb[0] = v->value;
v = Cvar_Get("_gl_fog_green", "1", 0, "experimental");
rgb[1] = v->value;
v = Cvar_Get("_gl_fog_blue", "1", 0, "experimental");
rgb[2] = v->value;
v = Cvar_Get("_gl_fog_alpha", "1", 0, "experimental");
alpha = v->value;
v = Cvar_Get("_gl_fog_dist", "512", 0, "experimental");
fardist = v->value;
BE_SelectMode(BEM_FOG, 0);
BE_SelectFog(rgb, alpha, fardist);
GLBE_SubmitMeshes(true, batches);
}
} }
BE_SelectEntity(&r_worldentity); BE_SelectEntity(&r_worldentity);

View file

@ -777,7 +777,7 @@ static void Shader_LoadPermutations(program_t *prog, char *script, int qrtype)
if (qrenderer != qrtype) if (qrenderer != qrtype)
{ {
} }
#ifdef GLQUAKE #ifdef GLQUAKE
else if (qrenderer == QR_OPENGL) else if (qrenderer == QR_OPENGL)
{ {
if (nopermutation & p) if (nopermutation & p)
@ -793,7 +793,24 @@ static void Shader_LoadPermutations(program_t *prog, char *script, int qrtype)
permutationdefines[pn++] = NULL; permutationdefines[pn++] = NULL;
prog->handle[p].glsl = GLSlang_CreateProgram(permutationdefines, script, script); prog->handle[p].glsl = GLSlang_CreateProgram(permutationdefines, script, script);
} }
#endif #endif
#ifdef D3DQUAKE
else if (qrenderer == QR_DIRECT3D)
{
if (nopermutation & p)
{
continue;
}
pn = 0;
for (n = 0; permutationname[n]; n++)
{
if (p & (1u<<n))
permutationdefines[pn++] = permutationname[n];
}
permutationdefines[pn++] = NULL;
prog->handle[p] = D3DShader_CreateProgram(permutationdefines, script, script);
}
#endif
} }
Shader_ProgAutoFields(prog); Shader_ProgAutoFields(prog);
@ -1031,14 +1048,14 @@ struct sbuiltin_s
"uniform sampler2D s_t1;\n" "uniform sampler2D s_t1;\n"
"uniform mediump float e_time;\n" "uniform mediump float e_time;\n"
"uniform mediump vec3 eyepos;\n" "uniform mediump vec3 e_eyepos;\n"
"varying mediump vec3 pos;\n" "varying mediump vec3 pos;\n"
"void main (void)\n" "void main (void)\n"
"{\n" "{\n"
" mediump vec2 tccoord;\n" " mediump vec2 tccoord;\n"
" mediump vec3 dir = pos - eyepos;\n" " mediump vec3 dir = pos - e_eyepos;\n"
" dir.z *= 3.0;\n" " dir.z *= 3.0;\n"
" dir.xy /= 0.5*length(dir);\n" " dir.xy /= 0.5*length(dir);\n"
@ -1068,7 +1085,7 @@ struct sbuiltin_s
"#ifdef FRAGMENT_SHADER\n" "#ifdef FRAGMENT_SHADER\n"
"uniform float e_time;\n" "uniform float e_time;\n"
"uniform vec3 eyepos;\n" "uniform vec3 e_eyepos;\n"
"varying vec3 pos;\n" "varying vec3 pos;\n"
"uniform sampler2D s_t0;\n" "uniform sampler2D s_t0;\n"
"uniform sampler2D s_t1;\n" "uniform sampler2D s_t1;\n"
@ -1077,7 +1094,7 @@ struct sbuiltin_s
"{\n" "{\n"
" vec2 tccoord;\n" " vec2 tccoord;\n"
" vec3 dir = pos - eyepos;\n" " vec3 dir = pos - e_eyepos;\n"
" dir.z *= 3.0;\n" " dir.z *= 3.0;\n"
" dir.xy /= 0.5*length(dir);\n" " dir.xy /= 0.5*length(dir);\n"
@ -1209,6 +1226,56 @@ struct sbuiltin_s
"}\n" "}\n"
"#endif\n" "#endif\n"
}, },
#endif
#if 0//def D3DQUAKE
{QR_DIRECT3D, 9, "defaultsky",
"struct a2v {\n"
"float4 pos: POSITION;\n"
"};\n"
"struct v2f {\n"
"#ifdef VERTEX_SHADER\n"
"float4 pos: POSITION;\n"
"#endif\n"
"float3 vpos: COLOR;\n"
"};\n"
"#ifdef VERTEX_SHADER\n"
"float4x4 ModelViewProj;\n"
"v2f main (a2v inp)\n"
"{\n"
" v2f outp;\n"
" outp.pos = mul(inp.pos, ModelViewProj);\n"
" outp.vpos = inp.pos;\n"
" return outp;\n"
"}\n"
"#endif\n"
"#ifdef FRAGMENT_SHADER\n"
"float e_time;\n"
"float3 e_eyepos;\n"
"sampler2D s_t0;\n"
"sampler2D s_t1;\n"
"float4 main (v2f inp) : COLOR0\n"
"{\n"
" float2 tccoord;\n"
" float3 dir = inp.vpos - e_eyepos;\n"
" dir.z *= 3.0;\n"
" dir.xy /= 0.5*length(dir);\n"
" tccoord = (dir.xy + e_time*0.03125);\n"
" float4 solid = tex2D(s_t0, tccoord);\n"
" tccoord = (dir.xy + e_time*0.0625);\n"
" float4 clouds = tex2D(s_t1, tccoord);\n"
" return float4((solid.rgb*(1.0-clouds.a)) + (clouds.a*clouds.rgb), 1);\n"
// " return solid.rgb;/*gl_FragColor.g = clouds.r;*/gl_FragColor.b = clouds.a;\n"
"}\n"
"#endif\n"
},
#endif #endif
{QR_NONE} {QR_NONE}
}; };
@ -1317,6 +1384,7 @@ static void Shader_ProgAutoFields(program_t *prog)
/*ent properties*/ /*ent properties*/
{"e_time", SP_TIME}, {"e_time", SP_TIME},
{"e_eyepos", SP_EYEPOS},
{"e_colour", SP_ENTCOLOURS}, {"e_colour", SP_ENTCOLOURS},
{"e_topcolour", SP_TOPCOLOURS}, {"e_topcolour", SP_TOPCOLOURS},
{"e_bottomcolour", SP_BOTTOMCOLOURS}, {"e_bottomcolour", SP_BOTTOMCOLOURS},
@ -1439,6 +1507,10 @@ static void Shader_GLSLProgramName (shader_t *shader, shaderpass_t *pass, char *
{ {
Shader_SLProgramName(shader,pass,ptr,QR_OPENGL); Shader_SLProgramName(shader,pass,ptr,QR_OPENGL);
} }
static void Shader_ProgramName (shader_t *shader, shaderpass_t *pass, char **ptr)
{
Shader_SLProgramName(shader,pass,ptr,qrenderer);
}
static void Shader_HLSLProgramName (shader_t *shader, shaderpass_t *pass, char **ptr) static void Shader_HLSLProgramName (shader_t *shader, shaderpass_t *pass, char **ptr)
{ {
Shader_SLProgramName(shader,pass,ptr,QR_DIRECT3D); Shader_SLProgramName(shader,pass,ptr,QR_DIRECT3D);
@ -1627,7 +1699,7 @@ static shaderkey_t shaderkeys[] =
{"entitymergable", Shader_EntityMergable}, {"entitymergable", Shader_EntityMergable},
{"glslprogram", Shader_GLSLProgramName}, {"glslprogram", Shader_GLSLProgramName},
{"program", Shader_GLSLProgramName}, //legacy {"program", Shader_ProgramName}, //legacy
{"hlslprogram", Shader_HLSLProgramName}, //for d3d {"hlslprogram", Shader_HLSLProgramName}, //for d3d
{"param", Shader_ProgramParam}, {"param", Shader_ProgramParam},
@ -3575,28 +3647,11 @@ void Shader_DefaultBSPQ1(char *shortname, shader_t *s, const void *args)
Shader_Free(s); Shader_Free(s);
memset (s, 0, sizeof(*s)); memset (s, 0, sizeof(*s));
} }
#ifdef GLQUAKE
if (!builtin && qrenderer == QR_OPENGL && gl_config.arb_shader_objects)
builtin = (
"{\n"
"sort sky\n"
"program defaultsky\n"
"param eyepos eyepos\n"
"surfaceparm nodlight\n"
//"skyparms - 512 -\n"
"{\n"
"map $diffuse\n"
"}\n"
"{\n"
"map $fullbright\n"
"}\n"
"}\n"
);
#endif
if (!builtin) if (!builtin)
builtin = ( builtin = (
"{\n" "{\n"
"sort sky\n" "sort sky\n"
"program defaultsky\n"
"skyparms - 512 -\n" "skyparms - 512 -\n"
/*WARNING: these values are not authentic quake, only close aproximations*/ /*WARNING: these values are not authentic quake, only close aproximations*/
"{\n" "{\n"

View file

@ -1705,6 +1705,19 @@ LONG WINAPI GLMainWndProc (
IN_RawInput_Read((HANDLE)lParam); IN_RawInput_Read((HANDLE)lParam);
break; break;
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: case WM_SIZE:
if (!vid_initializing) if (!vid_initializing)
{ {

View file

@ -314,6 +314,13 @@ typedef struct {
union programhandle_u union programhandle_u
{ {
int glsl; int glsl;
#ifdef D3DQUAKE
struct
{
void *vert;
void *frag;
} hlsl;
#endif
}; };
typedef struct programshared_s typedef struct programshared_s
@ -452,6 +459,9 @@ void D3DBE_UploadAllLightmaps(void);
void D3DBE_DrawWorld (qbyte *vis); void D3DBE_DrawWorld (qbyte *vis);
qboolean D3DBE_LightCullModel(vec3_t org, model_t *model); qboolean D3DBE_LightCullModel(vec3_t org, model_t *model);
void D3DBE_SelectEntity(entity_t *ent); void D3DBE_SelectEntity(entity_t *ent);
union programhandle_u D3DShader_CreateProgram (char **precompilerconstants, char *vert, char *frag);
void D3DShader_Init(void);
#endif #endif
//Asks the backend to invoke DrawMeshChain for each surface, and to upload lightmaps as required //Asks the backend to invoke DrawMeshChain for each surface, and to upload lightmaps as required

View file

@ -611,7 +611,7 @@ void PR_LoadGlabalStruct(void)
} }
if (!((nqglobalvars_t*)pr_globals)->trace_fraction) if (!((nqglobalvars_t*)pr_globals)->trace_fraction)
{ {
((nqglobalvars_t*)pr_globals)->trace_fraction = (vec3_t *)PR_FindGlobal(svprogfuncs, "trace_frac", 0); ((nqglobalvars_t*)pr_globals)->trace_fraction = (float *)PR_FindGlobal(svprogfuncs, "trace_frac", 0);
if (!((nqglobalvars_t*)pr_globals)->trace_fraction) if (!((nqglobalvars_t*)pr_globals)->trace_fraction)
SV_Error("Could not find export trace_fraction in progs\n"); SV_Error("Could not find export trace_fraction in progs\n");
} }