diff --git a/engine/Makefile b/engine/Makefile index e3c0e1921..ea7e1bfce 100644 --- a/engine/Makefile +++ b/engine/Makefile @@ -195,7 +195,20 @@ PROFILE_DIR=$(BASE_DIR)/profile ALL_CFLAGS=$(HAVECONFIG) $(CFLAGS) $(BASE_CFLAGS) $(WCFLAGS) -DO_CC=@echo $< && $(CC) $(ALL_CFLAGS) -o $@ -c $< +#cheap compile-everything-in-one-unit (compile becomes preprocess only) +ifneq ($(WPO),) + LTO_CC= -E + LTO_LD= -combine -fwhole-program -x c + LTO_END=ltoxnone + LTO_START=ltoxc +endif +#proper/consistant link-time optimisations (requires gcc 4.5+ or so) +ifneq ($(LTO),) + LTO_CC=-flto + LTO_LD=-flto +endif + +DO_CC=@echo $< && $(CC) $(LTO_CC) $(ALL_CFLAGS) -o $@ -c $< ifeq ($(FTE_TARGET),vc) BASELDFLAGS= @@ -536,7 +549,7 @@ ifeq ($(FTE_TARGET),win32_SDL) LIBS_DIR=./libs/ #the defaults for sdl come first - GLCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) gl_vidsdl.o snd_sdl.o cd_sdl.o sys_sdl.o in_sdl.o snd_directx.o resources.o + GLCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) gl_vidsdl.o snd_sdl.o cd_sdl.o sys_sdl.o in_sdl.o snd_directx.o $(LTO_END) resources.o $(LTO_START) GL_EXE_NAME=../fteqw_sdl_gl.exe GLCL_EXE_NAME=../fteqwcl_sdl.exe ifdef windir @@ -548,7 +561,7 @@ ifeq ($(FTE_TARGET),win32_SDL) GLB_DIR=gl_mgw_sdl$(BITS) GLCL_DIR=glcl_mgw_sdl$(BITS) - SV_OBJS=$(COMMON_OBJS) $(SERVER_OBJS) $(PROGS_OBJS) $(WINDOWSSERVERONLY_OBJS) resources.o + SV_OBJS=$(COMMON_OBJS) $(SERVER_OBJS) $(PROGS_OBJS) $(WINDOWSSERVERONLY_OBJS) $(LTO_END) resources.o $(LTO_START) SV_EXE_NAME=../fteqw_sdl_sv.exe SV_CFLAGS=$(SERVER_ONLY_CFLAGS) -D_SDL SV_LDFLAGS=./libs/mingw-libs/libz.a -lm -lmingw32 -lws2_32 -lwinmm @@ -558,7 +571,7 @@ ifeq ($(FTE_TARGET),win32_SDL) MB_DIR=m_mgw_sdl$(BITS) M_EXE_NAME=../fteqw_sdl.exe - MCL_OBJS=$(GLQUAKE_OBJS) $(SOFTWARE_OBJS) $(D3DQUAKE_OBJS) gl_vidsdl.o snd_sdl.o cd_sdl.o sys_sdl.o in_sdl.o snd_directx.o resources.o + MCL_OBJS=$(GLQUAKE_OBJS) $(SOFTWARE_OBJS) $(D3DQUAKE_OBJS) gl_vidsdl.o snd_sdl.o cd_sdl.o sys_sdl.o in_sdl.o snd_directx.o $(LTO_END) resources.o $(LTO_START) M_CFLAGS=$(D3DCFLAGS) -D_MINGW_VFPRINTF -D_SDL -I./libs/ -I./libs/mingw-libs/ -I./libs/mingw-libs $(GLCFLAGS) `sdl-config --cflags` -D_MERGED_SDL -I./libs/dxsdk7/include/ M_LDFLAGS=$(GLLDFLAGS) $(IMAGELDFLAGS) @@ -569,7 +582,7 @@ ifeq ($(FTE_TARGET),win32_SDL) M_LDFLAGS=$(IMAGELDFLAGS) -lws2_32 -lmingw32 ./libs/mingw-libs/libSDL.a ./libs/mingw-libs/libSDLmain.a -mwindows -ldxguid -lwinmm -lole32 $(MLDFLAGS) `sdl-config --libs` $(IMAGELDFLAGS) endif - D3DCL_OBJS=$(D3DQUAKE_OBJS) snd_sdl.o cd_sdl.o sys_sdl.o in_sdl.o snd_directx.o resources.o $(D3DONLY_OBJS) + D3DCL_OBJS=$(D3DQUAKE_OBJS) snd_sdl.o cd_sdl.o sys_sdl.o in_sdl.o snd_directx.o $(D3DONLY_OBJS) $(LTO_END) resources.o $(LTO_START) D3D_EXE_NAME=../fted3dqw.exe D3DCL_EXE_NAME=../fted3dclqw.exe D3D_LDFLAGS=$(IMAGELDFLAGS) -lws2_32 -lmingw32 ./libs/mingw-libs/libSDL.a ./libs/mingw-libs/libSDLmain.a -mwindows -ldxguid -lwinmm -lole32 @@ -582,7 +595,7 @@ ifeq ($(FTE_TARGET),win64_SDL) LIBS_DIR=./libs/ #the defaults for sdl come first - GLCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) gl_vidsdl.o snd_sdl.o cd_sdl.o sys_sdl.o in_sdl.o snd_directx.o resources.o + GLCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) gl_vidsdl.o snd_sdl.o cd_sdl.o sys_sdl.o in_sdl.o snd_directx.o $(LTO_END) resources.o $(LTO_START) GL_EXE_NAME=../fteqw_sdl_gl64.exe GLCL_EXE_NAME=../fteqwcl_sdl64.exe ifdef windir @@ -594,7 +607,7 @@ ifeq ($(FTE_TARGET),win64_SDL) GLB_DIR=gl_mgw_sdl$(BITS) GLCL_DIR=glcl_mgw_sdl$(BITS) - SV_OBJS=$(COMMON_OBJS) $(SERVER_OBJS) $(PROGS_OBJS) $(WINDOWSSERVERONLY_OBJS) resources.o + SV_OBJS=$(COMMON_OBJS) $(SERVER_OBJS) $(PROGS_OBJS) $(WINDOWSSERVERONLY_OBJS) $(LTO_END) resources.o $(LTO_START) SV_EXE_NAME=../fteqw_sdl_sv64.exe SV_CFLAGS=$(SERVER_ONLY_CFLAGS) -D_SDL SV_LDFLAGS=./libs/mingw64-libs/libz.a -lm -lmingw32 -lws2_32 -lwinmm @@ -604,7 +617,7 @@ ifeq ($(FTE_TARGET),win64_SDL) MB_DIR=m_mgw_sdl$(BITS) M_EXE_NAME=../fteqw_sdl64.exe - MCL_OBJS=$(GLQUAKE_OBJS) $(SOFTWARE_OBJS) $(D3DQUAKE_OBJS) gl_vidsdl.o snd_sdl.o cd_sdl.o sys_sdl.o in_sdl.o snd_directx.o resources.o + MCL_OBJS=$(GLQUAKE_OBJS) $(SOFTWARE_OBJS) $(D3DQUAKE_OBJS) gl_vidsdl.o snd_sdl.o cd_sdl.o sys_sdl.o in_sdl.o snd_directx.o $(LTO_END) resources.o $(LTO_START) M_CFLAGS= $(D3DCFLAGS) -D_MINGW_VFPRINTF -D_SDL -I./libs/ -I./libs/mingw64-libs/ -I./libs/mingw64-libs $(GLCFLAGS) `sdl-config --cflags` -D_MERGED_SDL -I./libs/dxsdk7/include/ M_LDFLAGS=$(GLLDFLAGS) $(IMAGELDFLAGS) @@ -659,11 +672,11 @@ ifeq ($(FTE_TARGET),win32) LIBS_DIR = $(BASE_DIR)/libs SV_EXE_NAME=../fteqwsv.exe SV_LDFLAGS=$(LIBS_DIR)/mingw-libs/zlib.lib -lws2_32 -lwinmm - SV_DIR=sv_mingw - SV_OBJS=$(COMMON_OBJS) $(SERVER_OBJS) $(PROGS_OBJS) $(WINDOWSSERVERONLY_OBJS) fs_win32.o resources.o + V_DIR=sv_mingw + SV_OBJS=$(COMMON_OBJS) $(SERVER_OBJS) $(PROGS_OBJS) $(WINDOWSSERVERONLY_OBJS) fs_win32.o $(LTO_END) resources.o $(LTO_START) - GLCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) fs_win32.o gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o resources.o + GLCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) fs_win32.o gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o $(LTO_END) resources.o $(LTO_START) GL_EXE_NAME=../fteglqw.exe GLCL_EXE_NAME=../fteglqwcl.exe GL_LDFLAGS=$(GLLDFLAGS) $(IMAGELDFLAGS) -ldxguid -lws2_32 -lwinmm -lgdi32 -lole32 @@ -671,7 +684,7 @@ ifeq ($(FTE_TARGET),win32) GLB_DIR=gl_mgw GLCL_DIR=glcl_mgw - NPQTVCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) fs_win32.o gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o npplug.o sys_npqtv.o sys_plugfte.o ../../ftequake/npapi.def + NPQTVCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) fs_win32.o gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o sys_npqtv.o sys_plugfte.o $(LTO_END) npplug.o ../../ftequake/npapi.def $(LTO_START) NPQTV_DLL_NAME=../npqtv.dll NPQTVCL_DLL_NAME=../npqtvcl.dll NPQTV_LDFLAGS=--enable-stdcall-fixup $(GLLDFLAGS) $(IMAGELDFLAGS) -ldxguid -lws2_32 -lwinmm -lgdi32 -lole32 -shared @@ -679,7 +692,7 @@ ifeq ($(FTE_TARGET),win32) NPQTVB_DIR=npqtv_mgw NPQTVCL_DIR=npqtvcl_mgw - MCL_OBJS=$(GLQUAKE_OBJS) $(SOFTWARE_OBJS) $(D3DQUAKE_OBJS) fs_win32.o gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o resources.o + MCL_OBJS=$(GLQUAKE_OBJS) $(SOFTWARE_OBJS) $(D3DQUAKE_OBJS) fs_win32.o gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o $(LTO_END) resources.o $(LTO_START) M_EXE_NAME=../fteqw.exe MCL_EXE_NAME=../fteqwcl.exe M_LDFLAGS=$(GLLDFLAGS) $(IMAGELDFLAGS) -ldxguid -lws2_32 -lwinmm -lgdi32 -lole32 @@ -687,7 +700,7 @@ ifeq ($(FTE_TARGET),win32) MB_DIR=m_mgw MCL_DIR=mcl_mgw - D3DCL_OBJS=$(D3DQUAKE_OBJS) snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o resources.o $(D3DONLY_OBJS) fs_win32.o + D3DCL_OBJS=$(D3DQUAKE_OBJS) snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o $(D3DONLY_OBJS) fs_win32.o $(LTO_END) resources.o $(LTO_START) D3D_EXE_NAME=../fted3dqw.exe D3DCL_EXE_NAME=../fted3dclqw.exe D3D_LDFLAGS=$(IMAGELDFLAGS) -ldxguid -lws2_32 -lwinmm -lgdi32 -lole32 @@ -714,10 +727,10 @@ ifeq ($(FTE_TARGET),win64) SV_EXE_NAME=../fteqwsv64.exe SV_LDFLAGS=$(LIBS_DIR)/mingw64-libs/libz.a -lws2_32 -lwinmm SV_DIR=sv_mingw64 - SV_OBJS=$(COMMON_OBJS) $(SERVER_OBJS) $(PROGS_OBJS) $(WINDOWSSERVERONLY_OBJS) fs_win32.o resources.o + SV_OBJS=$(COMMON_OBJS) $(SERVER_OBJS) $(PROGS_OBJS) $(WINDOWSSERVERONLY_OBJS) fs_win32.o $(LTO_END) resources.o $(LTO_START) - GLCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) fs_win32.o gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o resources.o + GLCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) fs_win32.o gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o $(LTO_END) resources.o $(LTO_START) GL_EXE_NAME=../fteglqw64.exe GLCL_EXE_NAME=../fteglqwcl64.exe GL_LDFLAGS=$(GLLDFLAGS) $(IMAGELDFLAGS) -ldxguid -lws2_32 -lwinmm -lgdi32 -lole32 @@ -725,7 +738,7 @@ ifeq ($(FTE_TARGET),win64) GLB_DIR=gl_mgw64 GLCL_DIR=glcl_mgw64 - NPQTVCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) fs_win32.o gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o npplug.o sys_npqtv.o sys_plugfte.o ../../ftequake/npapi.def + NPQTVCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) fs_win32.o gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o sys_npqtv.o sys_plugfte.o $(LTO_END) npplug.o ../../ftequake/npapi.def $(LTO_START) NPQTV_DLL_NAME=../npqtv64.dll NPQTVCL_DLL_NAME=../npqtvcl64.dll NPQTV_LDFLAGS=--enable-stdcall-fixup $(GLLDFLAGS) $(IMAGELDFLAGS) -ldxguid -lws2_32 -lwinmm -lgdi32 -lole32 -shared @@ -733,7 +746,7 @@ ifeq ($(FTE_TARGET),win64) NPQTVB_DIR=npqtv_mgw64 NPQTVCL_DIR=npqtvcl_mgw64 - MCL_OBJS=$(GLQUAKE_OBJS) $(SOFTWARE_OBJS) $(D3DQUAKE_OBJS) fs_win32.o gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o resources.o + MCL_OBJS=$(GLQUAKE_OBJS) $(SOFTWARE_OBJS) $(D3DQUAKE_OBJS) fs_win32.o gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o $(LTO_END) resources.o $(LTO_START) M_EXE_NAME=../fteqw64.exe MCL_EXE_NAME=../fteqwcl64.exe M_LDFLAGS=$(GLLDFLAGS) $(IMAGELDFLAGS) -ldxguid -lws2_32 -lwinmm -lgdi32 -lole32 @@ -741,7 +754,7 @@ ifeq ($(FTE_TARGET),win64) MB_DIR=m_mgw64 MCL_DIR=mcl_mgw64 - D3DCL_OBJS=$(D3DQUAKE_OBJS) snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o resources.o $(D3DONLY_OBJS) fs_win32.o + D3DCL_OBJS=$(D3DQUAKE_OBJS) snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o $(D3DONLY_OBJS) fs_win32.o $(LTO_END) resources.o $(LTO_START) D3D_EXE_NAME=../fted3dqw64.exe D3DCL_EXE_NAME=../fted3dclqw64.exe D3D_LDFLAGS=$(IMAGELDFLAGS) -ldxguid -lws2_32 -lwinmm -lgdi32 -lole32 @@ -986,9 +999,9 @@ PRECOMPHEADERS ?= $(OUT_DIR)/quakedef.h.gch #god knows how gcc loads the list properly. #or at least I hope he does. It makes no sence to mortals. -DO_LD ?= $(CC) -o $@ $(WCFLAGS) $(CFLAGS) -$(OUT_DIR)/$(EXE_NAME): $(PRECOMPHEADERS) $(addprefix $(OUT_DIR)/, $(CUSTOMOBJS) $(foreach ol, $(OBJS), $($(ol)))) - $(DO_LD) $(addprefix $(OUT_DIR)/, $(CUSTOMOBJS) $(foreach ol, $(OBJS), $($(ol)))) $(LDFLAGS) +DO_LD ?= $(CC) -o $@ $(LTO_LD) $(WCFLAGS) $(CFLAGS) +$(OUT_DIR)/$(EXE_NAME): $(PRECOMPHEADERS) $(foreach fn, $(CUSTOMOBJS) $(foreach ol, $(OBJS), $($(ol))),$(if $(findstring ltox,$(fn)),,$(OUT_DIR)/$(fn))) + $(DO_LD) $(foreach fn, $(CUSTOMOBJS) $(foreach ol, $(OBJS) $(LTO_END), $($(ol))),$(if $(findstring ltox,$(fn)),$(subst ltox,-x ,$(fn)),$(OUT_DIR)/$(fn)) ) -x none $(LDFLAGS) _out-rel: $(MAKE) $(OUT_DIR)/$(EXE_NAME) EXE_NAME="$(EXE_NAME)" OUT_DIR="$(OUT_DIR)" WCFLAGS="$(WCFLAGS) $(RELEASE_CFLAGS)" LDFLAGS="$(BASELDFLAGS) $(LDFLAGS) $(RELEASE_LDFLAGS)" OBJS="$(OBJS)" diff --git a/engine/client/image.c b/engine/client/image.c index 8684ab261..698cec5c7 100644 --- a/engine/client/image.c +++ b/engine/client/image.c @@ -2244,7 +2244,6 @@ static struct }; int image_width, image_height; -qbyte *COM_LoadFile (char *path, int usehunk); //fixme: should probably get rid of the 'Mod' prefix, and use something more suitable. texid_t R_LoadHiResTexture(char *name, char *subpath, unsigned int flags) { diff --git a/engine/client/in_win.c b/engine/client/in_win.c index bc6e4f973..e3497e328 100644 --- a/engine/client/in_win.c +++ b/engine/client/in_win.c @@ -63,8 +63,6 @@ cvar_t m_threshold_noforce = SCVAR("m_threshold_noforce", "0"); cvar_t cl_keypad = SCVAR("cl_keypad", "0"); extern cvar_t cl_forcesplitclient; -qboolean Key_MouseShouldBeFree(void); - typedef struct { union { HANDLE rawinputhandle; diff --git a/engine/client/keys.c b/engine/client/keys.c index b91ac8e96..ca40ef84c 100644 --- a/engine/client/keys.c +++ b/engine/client/keys.c @@ -30,7 +30,7 @@ void Editor_Key(int key, int unicode); #define KEY_MODIFIERSTATES 8 #define MAXCMDLINE 256 -char key_lines[32][MAXCMDLINE]; +unsigned char key_lines[32][MAXCMDLINE]; int key_linepos; int shift_down=false; int key_lastpress; diff --git a/engine/client/m_single.c b/engine/client/m_single.c index 515bd8cca..ab74c6185 100644 --- a/engine/client/m_single.c +++ b/engine/client/m_single.c @@ -19,8 +19,6 @@ typedef struct { char m_filenames[MAX_SAVEGAMES][SAVEGAME_COMMENT_LENGTH+1]; int loadable[MAX_SAVEGAMES]; -menubutton_t *VARGS MC_AddConsoleCommandf(menu_t *menu, int x, int y, char *text, char *command, ...); - void M_ScanSaves (void) { int i, j; diff --git a/engine/client/menu.h b/engine/client/menu.h index b422eccdd..c5f369bd7 100644 --- a/engine/client/menu.h +++ b/engine/client/menu.h @@ -296,6 +296,7 @@ menubutton_t *MC_AddConsoleCommand(menu_t *menu, int x, int y, const char *text, menubutton_t *MC_AddConsoleCommandQBigFont(menu_t *menu, int x, int y, const char *text, const char *command); mpic_t *QBigFontWorks(void); menubutton_t *MC_AddConsoleCommandHexen2BigFont(menu_t *menu, int x, int y, const char *text, const char *command); +menubutton_t *VARGS MC_AddConsoleCommandf(menu_t *menu, int x, int y, const char *text, char *command, ...); menubutton_t *MC_AddCommand(menu_t *menu, int x, int y, char *text, qboolean (*command) (union menuoption_s *,struct menu_s *,int)); menucombo_t *MC_AddCombo(menu_t *menu, int x, int y, const char *caption, const char **text, int initialvalue); menubutton_t *MC_AddCommand(menu_t *menu, int x, int y, char *text, qboolean (*command) (union menuoption_s *,struct menu_s *,int)); diff --git a/engine/client/r_2d.c b/engine/client/r_2d.c index 31e58dd97..fdb88fbb8 100644 --- a/engine/client/r_2d.c +++ b/engine/client/r_2d.c @@ -6,11 +6,12 @@ texid_t missing_texture; static mpic_t *conback; static mpic_t *draw_backtile; -static mpic_t *draw_fill, *draw_fill_trans; +static shader_t *shader_draw_fill, *shader_draw_fill_trans; mpic_t *draw_disc; shader_t *shader_brighten; shader_t *shader_polyblend; +shader_t *shader_menutint; static mesh_t draw_mesh; static vecV_t draw_mesh_xyz[4]; @@ -91,14 +92,14 @@ void R2D_Init(void) if (!draw_backtile) draw_backtile = Draw_SafeCachePic ("gfx/menu/backtile.lmp"); - draw_fill = R_RegisterShader("fill_opaque", + shader_draw_fill = R_RegisterShader("fill_opaque", "{\n" "{\n" "map $whiteimage\n" "rgbgen vertex\n" "}\n" "}\n"); - draw_fill_trans = R_RegisterShader("fill_trans", + shader_draw_fill_trans = R_RegisterShader("fill_trans", "{\n" "{\n" "map $whiteimage\n" @@ -127,6 +128,60 @@ void R2D_Init(void) "}\n" "}\n" ); + shader_menutint = R_RegisterShader("menutint_glsl", + "{\n" + "if $glsl && gl_menutint_shader != 0\n" + "[\n" + "glslprogram\n" + "{\n" + "#ifdef VERTEX_SHADER\n" + "\ + varying vec2 texcoord;\ + uniform vec3 rendertexturescale;\ + void main(void)\ + {\ + texcoord.x = gl_MultiTexCoord0.x*rendertexturescale.x;\ + texcoord.y = (1-gl_MultiTexCoord0.y)*rendertexturescale.y;\ + gl_Position = ftransform();\ + }\ + \n" + "#endif\n" + "#ifdef FRAGMENT_SHADER\n" + "\ + varying vec2 texcoord;\ + uniform vec3 colorparam;\ + uniform sampler2D source;\ + uniform int invert;\ + const vec3 lumfactors = vec3(0.299, 0.587, 0.114);\ + const vec3 invertvec = vec3(1.0, 1.0, 1.0);\ + void main(void)\ + {\ + vec3 texcolor = texture2D(source, texcoord).rgb;\ + float luminance = dot(lumfactors, texcolor);\ + texcolor = vec3(luminance, luminance, luminance);\ + texcolor *= colorparam;\ + texcolor = (invert > 0) ? (invertvec - texcolor) : texcolor;\ + gl_FragColor = vec4(texcolor, 1.0);\ + }\n" + "#endif\n" + "}\n" + "param cvari r_menutint_inverse invert\n" + "param cvar3f r_menutint colorparam\n" + "param texture 0 source\n" + "param rendertexturescale rendertexturescale\n" + + "{\n" + "map $currentrender\n" + "}\n" + "][\n" + "{\n" + "map $whitetexture\n" + "blendfunc gl_dst_color gl_zero\n" + "rgbgen const $r_menutint\n" + "}\n" + "]\n" + "}\n" + ); Cvar_Hook(&gl_font, R2D_Font_Callback); Cvar_Hook(&vid_conautoscale, R2D_Conautoscale_Callback); @@ -234,9 +289,9 @@ void R2D_FillBlock(int x, int y, int w, int h) draw_mesh_xyz[3][1] = y+h; if (draw_mesh_colors[0][3] != 1) - BE_DrawMesh_Single(draw_fill_trans, &draw_mesh, NULL, &draw_fill_trans->defaulttextures); + BE_DrawMesh_Single(shader_draw_fill_trans, &draw_mesh, NULL, &shader_draw_fill_trans->defaulttextures); else - BE_DrawMesh_Single(draw_fill, &draw_mesh, NULL, &draw_fill->defaulttextures); + BE_DrawMesh_Single(shader_draw_fill, &draw_mesh, NULL, &shader_draw_fill->defaulttextures); } void R2D_ScalePic (int x, int y, int width, int height, mpic_t *pic) @@ -567,4 +622,13 @@ void R2D_BrightenScreen (void) RSpeedEnd(RSPEED_PALETTEFLASHES); } + +//for menus +void R2D_FadeScreen (void) +{ + R2D_ScalePic(0, 0, vid.width, vid.height, shader_menutint); + + Sbar_Changed(); +} + #endif diff --git a/engine/client/snd_ov.c b/engine/client/snd_ov.c index 99092c062..ec0a9252a 100644 --- a/engine/client/snd_ov.c +++ b/engine/client/snd_ov.c @@ -74,8 +74,6 @@ int OV_DecodeSome(sfx_t *s, int minlength); void OV_CancelDecoder(sfx_t *s); qboolean OV_StartDecode(unsigned char *start, unsigned long length, ovdecoderbuffer_t *buffer); -qbyte *COM_LoadFile (char *path, int usehunk); - sfxcache_t *S_LoadOVSound (sfx_t *s, qbyte *data, int datalen, int sndspeed) { //char namebuffer[MAX_OSPATH]; //unreferenced diff --git a/engine/client/view.c b/engine/client/view.c index ff0b1daa7..74f179bb9 100644 --- a/engine/client/view.c +++ b/engine/client/view.c @@ -101,8 +101,6 @@ extern cvar_t cl_chasecam; float v_dmg_time[MAX_SPLITS], v_dmg_roll[MAX_SPLITS], v_dmg_pitch[MAX_SPLITS]; -extern int in_forward, in_forward2, in_back; - frame_t *view_frame; player_state_t *view_message; diff --git a/engine/client/wad.c b/engine/client/wad.c index 80bee9bd5..cd67f3fa8 100644 --- a/engine/client/wad.c +++ b/engine/client/wad.c @@ -65,7 +65,6 @@ void W_CleanupName (const char *in, char *out) W_LoadWadFile ==================== */ -qbyte *COM_LoadFile (char *path, int usehunk); void W_LoadWadFile (char *filename) { lumpinfo_t *lump_p; diff --git a/engine/common/common.h b/engine/common/common.h index 5d77d28a8..df7644330 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -396,6 +396,8 @@ qbyte *FS_LoadMallocFile (const char *path); int FS_LoadFile(char *name, void **file); void FS_FreeFile(void *file); +qbyte *COM_LoadFile (const char *path, int usehunk); + qboolean COM_LoadMapPackFile(const char *name, int offset); void COM_FlushTempoaryPacks(void); diff --git a/engine/common/fs.c b/engine/common/fs.c index b66e66a18..2fdb8610d 100644 --- a/engine/common/fs.c +++ b/engine/common/fs.c @@ -8,6 +8,7 @@ #include #include "fs.h" +#include "shader.h" #if defined(MINGW) && defined(_SDL) #include "./mingw-libs/SDL_syswm.h" // mingw sdl cross binary complains off sys_parentwindow @@ -1633,10 +1634,7 @@ void COM_Gamedir (const char *dir) } } - { - extern void Shader_Init(void); - Shader_Init(); //FIXME! - } + Shader_Init(); //FIXME! COM_Effectinfo_Clear(); diff --git a/engine/common/pmove.c b/engine/common/pmove.c index c347110ce..445e545eb 100644 --- a/engine/common/pmove.c +++ b/engine/common/pmove.c @@ -20,8 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" -extern float pm_stepheight; - movevars_t movevars; playermove_t pmove; diff --git a/engine/common/pr_common.h b/engine/common/pr_common.h index 2192b7d5f..1074f9815 100644 --- a/engine/common/pr_common.h +++ b/engine/common/pr_common.h @@ -267,7 +267,6 @@ void QCBUILTIN PF_buf_cvarlist (progfuncs_t *prinst, struct globalvars_s *pr_gl void QCBUILTIN PF_whichpack (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_fclose_progs (progfuncs_t *prinst); -char *PF_VarString (progfuncs_t *prinst, int first, struct globalvars_s *pr_globals); int QCEditor (progfuncs_t *prinst, char *filename, int line, int nump, char **parms); void PF_Common_RegisterCvars(void); diff --git a/engine/d3d/d3d_backend.c b/engine/d3d/d3d_backend.c index b76b1469a..2416dd2fe 100644 --- a/engine/d3d/d3d_backend.c +++ b/engine/d3d/d3d_backend.c @@ -175,6 +175,42 @@ enum }; IDirect3DVertexDeclaration9 *vertexdecls[D3D_VDEC_MAX]; +static void BE_ApplyTMUState(unsigned int tu, unsigned int flags) +{ + if ((flags ^ shaderstate.tmuflags[tu]) & SHADER_PASS_CLAMP) + { + shaderstate.tmuflags[tu] ^= SHADER_PASS_CLAMP; + if (flags & SHADER_PASS_CLAMP) + { + IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); + IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); + IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP); + } + else + { + IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP); + IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP); + IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_ADDRESSW, D3DTADDRESS_WRAP); + } + } + if ((flags ^ shaderstate.tmuflags[tu]) & SHADER_PASS_NOMIPMAP) + { + shaderstate.tmuflags[tu] ^= SHADER_PASS_NOMIPMAP; + /*lightmaps don't use mipmaps*/ + if (flags & SHADER_PASS_NOMIPMAP) + { + IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); + IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_MIPFILTER, D3DTEXF_NONE); + IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); + } + else + { + IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); + IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR); + IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); + } + } +} void D3DBE_Reset(qboolean before) { @@ -289,42 +325,11 @@ void D3DBE_Reset(qboolean before) IDirect3DDevice9_CreateVertexBuffer(pD3DDev9, shaderstate.dynst_size, D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &shaderstate.dynst_buff[tmu], NULL); IDirect3DDevice9_CreateVertexBuffer(pD3DDev9, shaderstate.dyncol_size, D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &shaderstate.dyncol_buff, NULL); IDirect3DDevice9_CreateIndexBuffer(pD3DDev9, shaderstate.dynidx_size, D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY, D3DFMT_QINDEX, D3DPOOL_DEFAULT, &shaderstate.dynidx_buff, NULL); - } -} - -static void BE_ApplyTMUState(unsigned int tu, unsigned int flags) -{ - if ((flags ^ shaderstate.tmuflags[tu]) & SHADER_PASS_CLAMP) - { - shaderstate.tmuflags[tu] ^= SHADER_PASS_CLAMP; - if (flags & SHADER_PASS_CLAMP) + + for (i = 0; i < MAX_TMUS; i++) { - IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); - IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); - IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP); - } - else - { - IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP); - IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP); - IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_ADDRESSW, D3DTADDRESS_WRAP); - } - } - if ((flags ^ shaderstate.tmuflags[tu]) & SHADER_PASS_NOMIPMAP) - { - shaderstate.tmuflags[tu] ^= SHADER_PASS_NOMIPMAP; - /*lightmaps don't use mipmaps*/ - if (flags & SHADER_PASS_NOMIPMAP) - { - IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); - IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_MIPFILTER, D3DTEXF_NONE); - IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); - } - else - { - IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); - IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR); - IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); + shaderstate.tmuflags[i] = ~0; + BE_ApplyTMUState(i, 0); } } } @@ -479,11 +484,6 @@ void D3DBE_Init(void) shaderstate.shaderbits = ~0; D3DBE_ApplyShaderBits(0); - for (i = 0; i < MAX_TMUS; i++) - { - shaderstate.tmuflags[i] = ~0; - BE_ApplyTMUState(i, 0); - } } static void allocvertexbuffer(IDirect3DVertexBuffer9 *buff, unsigned int bmaxsize, unsigned int *offset, void **data, unsigned int bytes) @@ -666,9 +666,17 @@ static void SelectPassTexture(unsigned int tu, shaderpass_t *pass) { if (shaderstate.passsinglecolour) { - IDirect3DDevice9_SetTextureStageState(pD3DDev9, tu, D3DTSS_COLORARG2, D3DTA_CONSTANT); - IDirect3DDevice9_SetTextureStageState(pD3DDev9, tu, D3DTSS_ALPHAARG2, D3DTA_CONSTANT); - IDirect3DDevice9_SetTextureStageState(pD3DDev9, tu, D3DTSS_CONSTANT, shaderstate.passcolour); + if (shaderstate.passcolour == D3DCOLOR_RGBA(255,255,255,255)) + { + IDirect3DDevice9_SetTextureStageState(pD3DDev9, tu, D3DTSS_COLOROP, D3DTOP_SELECTARG1); + IDirect3DDevice9_SetTextureStageState(pD3DDev9, tu, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); + } + else + { + IDirect3DDevice9_SetTextureStageState(pD3DDev9, tu, D3DTSS_COLORARG2, D3DTA_CONSTANT); + IDirect3DDevice9_SetTextureStageState(pD3DDev9, tu, D3DTSS_ALPHAARG2, D3DTA_CONSTANT); + IDirect3DDevice9_SetTextureStageState(pD3DDev9, tu, D3DTSS_CONSTANT, shaderstate.passcolour); + } } else { @@ -736,11 +744,10 @@ static void colourgenbyte(const shaderpass_t *pass, int cnt, const byte_vec4_t * break; case RGB_GEN_IDENTITY_LIGHTING: //compensate for overbrights + block = D3DCOLOR_RGBA(255, 255, 255, 255); //shaderstate.identitylighting while((cnt)--) { - dst[cnt][0] = 255;//shaderstate.identitylighting; - dst[cnt][1] = 255;//shaderstate.identitylighting; - dst[cnt][2] = 255;//shaderstate.identitylighting; + ((D3DCOLOR*)dst)[cnt] = block; } break; default: diff --git a/engine/d3d/d3d_image.c b/engine/d3d/d3d_image.c index 3020c2847..1d4854b1d 100644 --- a/engine/d3d/d3d_image.c +++ b/engine/d3d/d3d_image.c @@ -103,6 +103,29 @@ static void D3D9_RoundDimensions(int *scaled_width, int *scaled_height, qboolean *scaled_height = 1; } +#if 0 +static void D3D_MipMap (qbyte *out, int outwidth, int outheight, qbyte *in, int inwidth, int inheight) +{ + int i, j; + qbyte *inrow; + + //with npot + int rowwidth = inwidth*4; //rowwidth is the byte width of the input + inrow = in; + + for (i=0 ; i>2; + out[1] = (in[1] + in[5] + in[rowwidth+1] + in[rowwidth+5])>>2; + out[2] = (in[2] + in[6] + in[rowwidth+2] + in[rowwidth+6])>>2; + out[3] = (in[3] + in[7] + in[rowwidth+3] + in[rowwidth+7])>>2; + } + } +} +#endif + static void Upload_Texture_32(LPDIRECT3DTEXTURE9 tex, unsigned int *data, int width, int height, unsigned int flags) { int x, y; @@ -110,32 +133,26 @@ static void Upload_Texture_32(LPDIRECT3DTEXTURE9 tex, unsigned int *data, int wi unsigned char swapbuf[4]; unsigned char swapbuf2[4]; D3DLOCKED_RECT lock; + int i; D3DSURFACE_DESC desc; IDirect3DTexture9_GetLevelDesc(tex, 0, &desc); - IDirect3DTexture9_LockRect(tex, 0, &lock, NULL, D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY); + IDirect3DTexture9_LockRect(tex, 0, &lock, NULL, D3DLOCK_NOSYSLOCK|D3DLOCK_DISCARD); if (width == desc.Width && height == desc.Height) { -// if (desc.lPitch == twidth*4) -// { -// memcpy(desc.lpSurface, data, width*height*4); -// } -// else + for (y = 0; y < height; y++) { - for (y = 0; y < height; y++) + dest = (unsigned int *)((char *)lock.pBits + lock.Pitch*y); + for (x = 0; x < width; x++) { - dest = (unsigned int *)((char *)lock.pBits + lock.Pitch*y); - for (x = 0; x < width; x++) - { - *(unsigned int*)swapbuf2 = *(unsigned int*)swapbuf = data[x]; - swapbuf[0] = swapbuf2[2]; - swapbuf[2] = swapbuf2[0]; - dest[x] = *(unsigned int*)swapbuf; - } - data += width; + *(unsigned int*)swapbuf2 = *(unsigned int*)swapbuf = data[x]; + swapbuf[0] = swapbuf2[2]; + swapbuf[2] = swapbuf2[0]; + dest[x] = *(unsigned int*)swapbuf; } + data += width; } } else @@ -157,17 +174,27 @@ static void Upload_Texture_32(LPDIRECT3DTEXTURE9 tex, unsigned int *data, int wi row[x] = *(unsigned int*)swapbuf; } } - - - - //mimic opengl and draw it white -// memset(desc.lpSurface, 255, twidth*theight*4); } - IDirect3DTexture9_UnlockRect(tex, 0); - +#if 0 //D3DUSAGE_AUTOGENMIPMAP so this isn't needed if (!(flags & IF_NOMIPMAP)) - IDirect3DBaseTexture9_GenerateMipSubLevels(tex); + { + int max = IDirect3DTexture9_GetLevelCount(tex); + for (i = 1; i < max; i++) + { + width = desc.Width; + height = desc.Height; + data = lock.pBits; + IDirect3DTexture9_LockRect(tex, i, &lock, NULL, D3DLOCK_NOSYSLOCK|D3DLOCK_DISCARD); + IDirect3DTexture9_GetLevelDesc(tex, i, &desc); + D3D_MipMap(lock.pBits, desc.Width, desc.Height, data, width, height); + IDirect3DTexture9_UnlockRect(tex, i-1); + } + IDirect3DTexture9_UnlockRect(tex, i-1); + } + else +#endif + IDirect3DTexture9_UnlockRect(tex, 0); } //create a basic shader from a 32bit image @@ -190,7 +217,7 @@ static LPDIRECT3DBASETEXTURE9 D3D9_LoadTexture_32(d3dtexture_t *tex, unsigned in newsurf = tex->tex.ptr; if (!newsurf) - IDirect3DDevice9_CreateTexture(pD3DDev9, nwidth, nheight, 0, ((flags & IF_NOMIPMAP)?0:D3DUSAGE_AUTOGENMIPMAP), D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &newsurf, NULL); + IDirect3DDevice9_CreateTexture(pD3DDev9, nwidth, nheight, (flags & IF_NOMIPMAP)?1:0, ((flags & IF_NOMIPMAP)?0:D3DUSAGE_AUTOGENMIPMAP), D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &newsurf, NULL); if (!newsurf) return NULL; diff --git a/engine/d3d/vid_d3d.c b/engine/d3d/vid_d3d.c index b791fee09..b838aca50 100644 --- a/engine/d3d/vid_d3d.c +++ b/engine/d3d/vid_d3d.c @@ -244,8 +244,8 @@ static LRESULT WINAPI D3D9_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA if ( uMsg == uiWheelMessage ) uMsg = WM_MOUSEWHEEL; - switch (uMsg) - { + switch (uMsg) + { case WM_KILLFOCUS: if (modestate == MS_FULLDIB) ShowWindow(mainwindow, SW_SHOWMINNOACTIVE); @@ -347,7 +347,7 @@ static LRESULT WINAPI D3D9_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA IN_RawInput_Read((HANDLE)lParam); break; - case WM_SIZE: + case WM_SIZE: if (!vid_initializing) { extern cvar_t vid_conautoscale, vid_conwidth; @@ -365,9 +365,9 @@ static LRESULT WINAPI D3D9_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA Cvar_ForceCallback(&vid_conautoscale); Cvar_ForceCallback(&vid_conwidth); } - break; + break; - case WM_CLOSE: + case WM_CLOSE: if (!vid_initializing) if (MessageBox (mainwindow, "Are you sure you want to quit?", "Confirm Exit", MB_YESNO | MB_SETFOREGROUND | MB_ICONQUESTION) == IDYES) @@ -604,7 +604,7 @@ static void initD3D9(HWND hWnd, rendererstate_t *info) numadaptors = IDirect3D9_GetAdapterCount(pD3D); for (i = 0; i < numadaptors; i++) - { //try each adaptor in turn until we get one that actually works + { //NVIDIA's debug app requires that we use a specific device memset(&inf, 0, sizeof(inf)); err = IDirect3D9_GetAdapterIdentifier(pD3D, i, 0, &inf); if (strstr(inf.Description, "PerfHUD")) @@ -681,8 +681,6 @@ static qboolean D3D9_VID_Init(rendererstate_t *info, unsigned char *palette) } ShowWindow(mainwindow, SW_NORMAL); - //IDirect3DDevice9_Clear(pD3DDev9, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 1, 0); - //IDirect3DDevice9_Present(pD3DDev9, NULL, NULL, NULL, NULL); IDirect3DDevice9_Clear(pD3DDev9, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); IDirect3DDevice9_BeginScene(pD3DDev9); @@ -701,9 +699,6 @@ static qboolean D3D9_VID_Init(rendererstate_t *info, unsigned char *palette) vid_initializing = false; - //IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRENDERSTATE_DITHERENABLE, FALSE); - //IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRENDERSTATE_SPECULARENABLE, FALSE); - //IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRENDERSTATE_TEXTUREPERSPECTIVE, TRUE); IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRS_LIGHTING, FALSE); GetWindowRect(mainwindow, &window_rect); @@ -1043,9 +1038,6 @@ static void (D3D9_Draw_Fill) (int x, int y, int w, int h, unsigned int c) static void (D3D9_Draw_FillRGB) (int x, int y, int w, int h, float r, float g, float b) { } -static void (D3D9_Draw_FadeScreen) (void) -{ -} static void (D3D9_Draw_BeginDisc) (void); static void (D3D9_Draw_EndDisc) (void); @@ -1186,7 +1178,7 @@ rendererinfo_t d3drendererinfo = R2D_TileClear, D3D9_Draw_Fill, D3D9_Draw_FillRGB, - D3D9_Draw_FadeScreen, + R2D_FadeScreen, D3D9_Draw_BeginDisc, D3D9_Draw_EndDisc, diff --git a/engine/gl/gl_alias.c b/engine/gl/gl_alias.c index 9b9a3d4ae..69bd49136 100644 --- a/engine/gl/gl_alias.c +++ b/engine/gl/gl_alias.c @@ -48,15 +48,6 @@ void GLMod_FloodFillSkin( qbyte *skin, int skinwidth, int skinheight ); extern char loadname[32]; // for hunk tags -int numTempColours; -byte_vec4_t *tempColours; - -int numTempVertexCoords; -vec3_t *tempVertexCoords; - -int numTempNormals; -vec3_t *tempNormals; - extern cvar_t gl_ati_truform; extern cvar_t r_vertexdlights; extern cvar_t mod_md3flags; diff --git a/engine/gl/gl_draw.c b/engine/gl/gl_draw.c index fbada1d06..b59e41361 100644 --- a/engine/gl/gl_draw.c +++ b/engine/gl/gl_draw.c @@ -705,60 +705,6 @@ void GLDraw_Fill (int x, int y, int w, int h, unsigned int c) } //============================================================================= -/* -================ -Draw_FadeScreen - -================ -*/ -vec3_t fadecolor; -int faderender; - -void GLR_Menutint_Callback (struct cvar_s *var, char *oldvalue) -{ - // parse r_menutint and clear defaults - faderender = GL_DST_COLOR; - - if (var->string[0]) - SCR_StringToRGB(var->string, fadecolor, 1); - else - faderender = 0; - - // bounds check and inverse check - if (faderender) - { - if (fadecolor[0] < 0) - { - faderender = GL_ONE_MINUS_DST_COLOR; - fadecolor[0] = -(fadecolor[0]); - } - if (fadecolor[1] < 0) - { - faderender = GL_ONE_MINUS_DST_COLOR; - fadecolor[1] = -(fadecolor[1]); - } - if (fadecolor[2] < 0) - { - faderender = GL_ONE_MINUS_DST_COLOR; - fadecolor[2] = -(fadecolor[2]); - } - } -} - -void GLDraw_FadeScreen (void) -{ - extern shader_t *scenepp_mt_shader; - - if (!faderender) - return; - - R2D_ScalePic(0, 0, vid.width, vid.height, scenepp_mt_shader); - - Sbar_Changed(); -} - -//============================================================================= - /* ================ Draw_BeginDisc @@ -836,190 +782,6 @@ void GL_Set2D (void) } } - - - - -#if 0 -void MediaGL_ShowFrame8bit(qbyte *framedata, int inwidth, int inheight, qbyte *palette) //bottom up -{ - if (!TEXVALID(filmtexture)) - { - filmtexture=GL_AllocNewTexture(); - } - - GL_Set2D (); - - GL_Bind(filmtexture); - GL_Upload8Pal24(framedata, palette, inwidth, inheight, IF_NOMIPMAP|IF_NOALPHA); //we may need to rescale the image -// glTexImage2D (GL_TEXTURE_2D, 0, 3, roqfilm->width, roqfilm->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, framedata); -// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max); -// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); - - qglDisable(GL_BLEND); - qglDisable(GL_ALPHA_TEST); - qglBegin(GL_QUADS); - qglTexCoord2f(0, 0); - qglVertex2f(0, 0); - qglTexCoord2f(0, 1); - qglVertex2f(0, vid.height); - qglTexCoord2f(1, 1); - qglVertex2f(vid.width, vid.height); - qglTexCoord2f(1, 0); - qglVertex2f(vid.width, 0); - qglEnd(); - qglEnable(GL_ALPHA_TEST); - - - SCR_SetUpToDrawConsole(); - if (scr_con_current) - SCR_DrawConsole (false); - - M_Draw(0); -} - -void MediaGL_ShowFrameRGBA_32(qbyte *framedata, int inwidth, int inheight)//top down -{ - if (!TEXVALID(filmtexture)) - { - filmtexture=GL_AllocNewTexture(); - } - - GL_Set2D (); - - PPL_RevertToKnownState(); - - GL_Bind(filmtexture); - GL_Upload32("", (unsigned *)framedata, inwidth, inheight, IF_NOMIPMAP|IF_NOALPHA|IF_NOGAMMA); //we may need to rescale the image - - qglDisable(GL_BLEND); - qglDisable(GL_ALPHA_TEST); - qglEnable(GL_TEXTURE_2D); - qglBegin(GL_QUADS); - qglTexCoord2f(0, 0); - qglVertex2f(0, 0); - qglTexCoord2f(0, 1); - qglVertex2f(0, vid.height); - qglTexCoord2f(1, 1); - qglVertex2f(vid.width, vid.height); - qglTexCoord2f(1, 0); - qglVertex2f(vid.width, 0); - qglEnd(); - qglEnable(GL_ALPHA_TEST); - - - SCR_SetUpToDrawConsole(); - if (scr_con_current) - SCR_DrawConsole (false); -} - -int filmnwidth = 640; -int filmnheight = 640; - -void MediaGL_ShowFrameBGR_24_Flip(qbyte *framedata, int inwidth, int inheight) -{ - //we need these as we resize it as we convert to rgba - - int y, x; - - int v; - unsigned int f, fstep; - qbyte *src, *dest; - dest = uploadmemorybufferintermediate; - //change from bgr bottomup to rgba topdown - - for (filmnwidth = 1; filmnwidth < inwidth; filmnwidth*=2) - ; - for (filmnheight = 1; filmnheight < inheight; filmnheight*=2) - ; - - if (filmnwidth > 512) - filmnwidth = 512; - if (filmnheight > 512) - filmnheight = 512; - - if (inwidth*inheight > sizeofuploadmemorybufferintermediate/4) - Sys_Error("MediaGL_ShowFrameBGR_24_Flip: image too big (%i*%i)", inwidth, inheight); - - for (y=1 ; y<=filmnheight ; y++) - { - v = ((filmnheight - y)*(float)inheight/filmnheight); - src = framedata + v*(inwidth*3); - { - f = 0; - fstep = ((inwidth)*0x10000)/filmnwidth; - - for (x=filmnwidth ; x&3 ; x--) //do the odd ones first. (bigger condition) - { - *dest++ = src[(f>>16)*3+2]; - *dest++ = src[(f>>16)*3+1]; - *dest++ = src[(f>>16)*3+0]; - *dest++ = 255; - f += fstep; - } - for ( ; x ; x-=4) //loop through the remaining chunks. - { - dest[0] = src[(f>>16)*3+2]; - dest[1] = src[(f>>16)*3+1]; - dest[2] = src[(f>>16)*3+0]; - dest[3] = 255; - f += fstep; - - dest[4] = src[(f>>16)*3+2]; - dest[5] = src[(f>>16)*3+1]; - dest[6] = src[(f>>16)*3+0]; - dest[7] = 255; - f += fstep; - - dest[8] = src[(f>>16)*3+2]; - dest[9] = src[(f>>16)*3+1]; - dest[10] = src[(f>>16)*3+0]; - dest[11] = 255; - f += fstep; - - dest[12] = src[(f>>16)*3+2]; - dest[13] = src[(f>>16)*3+1]; - dest[14] = src[(f>>16)*3+0]; - dest[15] = 255; - f += fstep; - - dest += 16; - } - } - } - - if (!TEXVALID(filmtexture)) - { - filmtexture=GL_AllocNewTexture(); - } - - GL_Set2D (); - - GL_Bind(filmtexture); - GL_Upload32("", (unsigned *)uploadmemorybufferintermediate, filmnwidth, filmnheight, IF_NOMIPMAP|IF_NOALPHA|IF_NOGAMMA); //we may need to rescale the image - - qglDisable(GL_BLEND); - qglDisable(GL_ALPHA_TEST); - qglBegin(GL_QUADS); - qglTexCoord2f(0, 0); - qglVertex2f(0, 0); - qglTexCoord2f(0, 1); - qglVertex2f(0, vid.height); - qglTexCoord2f(1, 1); - qglVertex2f(vid.width, vid.height); - qglTexCoord2f(1, 0); - qglVertex2f(vid.width, 0); - qglEnd(); - qglEnable(GL_ALPHA_TEST); - - - SCR_SetUpToDrawConsole(); - if (scr_con_current) - SCR_DrawConsole (false); -} -#endif - - //==================================================================== /* @@ -1038,13 +800,6 @@ texid_t GL_FindTexture (char *identifier) image_height = glt->height; return glt->texnum; } -/* - for (glt=gltextures ; glt ; glt=glt->next) - { - if (!strcmp (identifier, glt->identifier)) - return glt->texnum; - } -*/ return r_nulltex; } @@ -1221,7 +976,7 @@ static void Image_Resample32Lerp(const void *indata, int inwidth, int inheight, GL_ResampleTexture ================ */ -void GL_ResampleTexture (unsigned *in, int inwidth, int inheight, unsigned *out, int outwidth, int outheight) +static void GL_ResampleTexture (unsigned *in, int inwidth, int inheight, unsigned *out, int outwidth, int outheight) { int i, j; unsigned *inrow; @@ -1264,7 +1019,7 @@ void GL_ResampleTexture (unsigned *in, int inwidth, int inheight, unsigned *out, GL_Resample8BitTexture -- JACK ================ */ -void GL_Resample8BitTexture (unsigned char *in, int inwidth, int inheight, unsigned char *out, int outwidth, int outheight) +static void GL_Resample8BitTexture (unsigned char *in, int inwidth, int inheight, unsigned char *out, int outwidth, int outheight) { int i, j; unsigned char *inrow; @@ -1296,7 +1051,7 @@ GL_MipMap Operates in place, quartering the size of the texture ================ */ -void GL_MipMap (qbyte *in, int width, int height) +static void GL_MipMap (qbyte *in, int width, int height) { int i, j; qbyte *out; @@ -1393,7 +1148,7 @@ GL_MipMap8Bit Mipping for 8 bit textures ================ */ -void GL_MipMap8Bit (qbyte *in, int width, int height) +static void GL_MipMap8Bit (qbyte *in, int width, int height) { int i, j; qbyte *out; @@ -1588,7 +1343,7 @@ void GL_Upload32_Int (char *name, unsigned *data, int width, int height, unsigne if (scaled_height < 1) scaled_height = 1; miplevel++; - qglTexImage2D (GL_TEXTURE_2D, miplevel, samples, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaled); + qglTexImage2D (GL_TEXTURE_2D, miplevel, samples, scaled_width, scaled_height, 0, glcolormode, GL_UNSIGNED_BYTE, scaled); } } if (gl_config.arb_texture_compression && gl_compress.value && gl_savecompressedtex.value && name && !(flags&IF_NOMIPMAP)) @@ -2634,7 +2389,6 @@ texid_t GL_LoadTexture32_BGRA (char *identifier, int width, int height, unsigned texid_t GL_LoadCompressed(char *name) { - qbyte *COM_LoadFile (char *path, int usehunk); unsigned char *file; gltexture_t *glt; char inname[MAX_OSPATH]; @@ -2763,5 +2517,4 @@ texid_t GL_LoadPicTexture (qpic_t *pic) return GL_LoadTexture ("", pic->width, pic->height, pic->data, IF_NOMIPMAP, 1); } -/****************************************/ #endif diff --git a/engine/gl/gl_draw.h b/engine/gl/gl_draw.h index 3754f501a..9464c6ae7 100644 --- a/engine/gl/gl_draw.h +++ b/engine/gl/gl_draw.h @@ -30,7 +30,6 @@ void GLDraw_BeginDisc (void); void GLDraw_EndDisc (void); void GLDraw_FillRGB (int x, int y, int w, int h, float r, float g, float b); void GLDraw_Fill (int x, int y, int w, int h, unsigned int c); -void GLDraw_FadeScreen (void); void GLDraw_Crosshair(void); void GLDraw_LevelPic (mpic_t *pic); @@ -44,6 +43,7 @@ void R2D_SubPic(int x, int y, int width, int height, mpic_t *pic, int srcx, int void R2D_ConsoleBackground (int firstline, int lastline, qboolean forceopaque); void R2D_EditorBackground (void); void R2D_TileClear (int x, int y, int w, int h); +void R2D_FadeScreen (void); void R2D_Init(void); void R2D_Shutdown(void); diff --git a/engine/gl/gl_rmain.c b/engine/gl/gl_rmain.c index fe574d361..3ca4c25dc 100644 --- a/engine/gl/gl_rmain.c +++ b/engine/gl/gl_rmain.c @@ -105,7 +105,6 @@ cvar_t r_xflip = SCVAR("leftisright", "0"); extern cvar_t scr_fov; shader_t *scenepp_waterwarp; -shader_t *scenepp_mt_shader; // post processing stuff texid_t sceneblur_texture; @@ -270,78 +269,12 @@ void GL_InitFisheyeFov(void) } } -void GL_InitSceneProcessingShaders_MenuTint(void) -{ - extern cvar_t gl_menutint_shader; - - if (gl_config.arb_shader_objects && gl_menutint_shader.ival) - { - scenepp_mt_shader = R_RegisterShader("menutint", - "{\n" - "glslprogram\n" - "{\n" - "#ifdef VERTEX_SHADER\n" - "\ - varying vec2 texcoord;\ - uniform vec3 rendertexturescale;\ - void main(void)\ - {\ - texcoord.x = gl_MultiTexCoord0.x*rendertexturescale.x;\ - texcoord.y = (1-gl_MultiTexCoord0.y)*rendertexturescale.y;\ - gl_Position = ftransform();\ - }\ - \n" - "#endif\n" - "#ifdef FRAGMENT_SHADER\n" - "\ - varying vec2 texcoord;\ - uniform vec3 colorparam;\ - uniform sampler2D source;\ - uniform int invert;\ - const vec3 lumfactors = vec3(0.299, 0.587, 0.114);\ - const vec3 invertvec = vec3(1.0, 1.0, 1.0);\ - void main(void)\ - {\ - vec3 texcolor = texture2D(source, texcoord).rgb;\ - float luminance = dot(lumfactors, texcolor);\ - texcolor = vec3(luminance, luminance, luminance);\ - texcolor *= colorparam;\ - texcolor = (invert > 0) ? (invertvec - texcolor) : texcolor;\ - gl_FragColor = vec4(texcolor, 1.0);\ - }\n" - "#endif\n" - "}\n" - "param cvari r_menutint_inverse invert\n" - "param cvar3f r_menutint colorparam\n" - "param texture 0 source\n" - - "{\n" - "map $currentrender\n" - "}\n" - "param rendertexturescale rendertexturescale\n" - "}"); - } - else - { - scenepp_mt_shader = R_RegisterShader("menutint", - "{\n" - "{\n" - "map $whitetexture\n" - "blendfunc gl_dst_color gl_zero\n" - "rgbgen const $r_menutint\n" - "}\n" - "}\n" - ); - } -} - void GL_InitSceneProcessingShaders (void) { if (gl_config.arb_shader_objects) { GL_InitSceneProcessingShaders_WaterWarp(); GL_InitFisheyeFov(); - GL_InitSceneProcessingShaders_MenuTint(); } } diff --git a/engine/gl/gl_rmisc.c b/engine/gl/gl_rmisc.c index 69a09dd86..7eaedc945 100644 --- a/engine/gl/gl_rmisc.c +++ b/engine/gl/gl_rmisc.c @@ -446,7 +446,7 @@ extern cvar_t gl_bump, v_contrast, r_drawflat; extern cvar_t r_stains, r_stainfadetime, r_stainfadeammount; // callback defines -extern cvar_t gl_font, r_menutint; +extern cvar_t gl_font; extern cvar_t vid_conautoscale, vid_conheight, vid_conwidth; extern cvar_t crosshair, crosshairimage, crosshaircolor, r_skyboxname; extern cvar_t r_floorcolour, r_wallcolour, r_floortexture, r_walltexture; @@ -454,7 +454,6 @@ extern cvar_t r_fastskycolour; void GLCrosshairimage_Callback(struct cvar_s *var, char *oldvalue); void GLCrosshair_Callback(struct cvar_s *var, char *oldvalue); void GLCrosshaircolor_Callback(struct cvar_s *var, char *oldvalue); -void GLR_Menutint_Callback (struct cvar_s *var, char *oldvalue); void GLV_Gamma_Callback(struct cvar_s *var, char *oldvalue); void GLR_DeInit (void) @@ -469,7 +468,6 @@ void GLR_DeInit (void) Cvar_Unhook(&crosshairimage); Cvar_Unhook(&crosshaircolor); Cvar_Unhook(&r_skyboxname); - Cvar_Unhook(&r_menutint); Cvar_Unhook(&vid_conautoscale); Cvar_Unhook(&vid_conheight); Cvar_Unhook(&vid_conwidth); @@ -500,7 +498,6 @@ void GLR_Init (void) Cvar_Hook(&crosshair, GLCrosshair_Callback); Cvar_Hook(&crosshairimage, GLCrosshairimage_Callback); Cvar_Hook(&crosshaircolor, GLCrosshaircolor_Callback); - Cvar_Hook(&r_menutint, GLR_Menutint_Callback); // Cvar_Hook(&r_floorcolour, GLR_Floorcolour_Callback); // Cvar_Hook(&r_fastskycolour, GLR_Fastskycolour_Callback); // Cvar_Hook(&r_wallcolour, GLR_Wallcolour_Callback); diff --git a/engine/gl/gl_shader.c b/engine/gl/gl_shader.c index fc02140f9..b2949141d 100644 --- a/engine/gl/gl_shader.c +++ b/engine/gl/gl_shader.c @@ -230,6 +230,24 @@ static qboolean Shader_EvaluateCondition(char **ptr) else if (!Q_stricmp(token, "normalmap") ) conditiontrue = conditiontrue == !!gl_bump.value; + else if (!Q_stricmp(token, "glsl") ) + { +#ifdef GLQUAKE + conditiontrue = conditiontrue == ((qrenderer == QR_OPENGL) && gl_config.arb_shader_objects); +#else + conditiontrue = conditiontrue == false; +#endif + } + else if (!Q_stricmp(token, "hlsl") ) + { +#ifdef D3DQUAKE + conditiontrue = conditiontrue == false;//((qrenderer == QR_DIRECT3D) && gl_config.arb_shader_objects); +#else + conditiontrue = conditiontrue == false; +#endif + } + + // GCC hates these within if statements "error: expected '}' before 'else'" #ifdef _MSC_VER #pragma message("shader fixme") @@ -244,9 +262,11 @@ static qboolean Shader_EvaluateCondition(char **ptr) conditiontrue = conditiontrue == false; else if (!Q_stricmp(token, "loweroverlay") ) conditiontrue = conditiontrue == false; - else + { + Con_Printf("Unrecognised builtin shader condition '%s'\n", token); conditiontrue = conditiontrue == false; + } } else { @@ -280,6 +300,11 @@ static qboolean Shader_EvaluateCondition(char **ptr) conditiontrue = conditiontrue == !!cv->value; } } + token = COM_ParseExt ( ptr, false ); + if (!strcmp(token, "&&")) + return Shader_EvaluateCondition(ptr) && conditiontrue; + if (!strcmp(token, "||")) + return Shader_EvaluateCondition(ptr) || conditiontrue; return conditiontrue; } @@ -1588,15 +1613,15 @@ static void Shader_Translucent(shader_t *shader, shaderpass_t *pass, char **ptr) static shaderkey_t shaderkeys[] = { - {"cull", Shader_Cull}, - {"skyparms", Shader_SkyParms}, + {"cull", Shader_Cull}, + {"skyparms", Shader_SkyParms}, {"fogparms", Shader_FogParms}, {"surfaceparm", Shader_SurfaceParm}, - {"nomipmaps", Shader_NoMipMaps}, + {"nomipmaps", Shader_NoMipMaps}, {"nopicmip", Shader_NoPicMip}, {"polygonoffset", Shader_PolygonOffset}, {"sort", Shader_Sort}, - {"deformvertexes", Shader_DeformVertexes}, + {"deformvertexes", Shader_DeformVertexes}, {"portal", Shader_Portal}, {"entitymergable", Shader_EntityMergable}, @@ -1616,7 +1641,7 @@ static shaderkey_t shaderkeys[] = {"nooverlays", NULL}, {"nofragment", NULL}, - {NULL, NULL} + {NULL, NULL} }; // =============================================================== @@ -1698,24 +1723,24 @@ static void Shaderpass_Map (shader_t *shader, shaderpass_t *pass, char **ptr) pass->tcgen = TC_GEN_BASE; pass->anim_frames[0] = Shader_FindImage (token, flags); - } + } } static void Shaderpass_AnimMap (shader_t *shader, shaderpass_t *pass, char **ptr) { - int flags; + int flags; char *token; texid_t image; flags = Shader_SetImageFlags (shader); pass->tcgen = TC_GEN_BASE; - pass->flags |= SHADER_PASS_ANIMMAP; + pass->flags |= SHADER_PASS_ANIMMAP; pass->texgen = T_GEN_ANIMMAP; - pass->anim_fps = (int)Shader_ParseFloat (ptr); + pass->anim_fps = (int)Shader_ParseFloat (ptr); pass->anim_numframes = 0; - for ( ; ; ) + for ( ; ; ) { token = Shader_ParseString(ptr); if (!token[0]) @@ -1996,7 +2021,7 @@ static void Shaderpass_BlendFunc (shader_t *shader, shaderpass_t *pass, char **p if (*token == ',') token = Shader_ParseString (ptr); pass->shaderbits |= Shader_BlendFactor(token, true); - } + } } static void Shaderpass_AlphaFunc (shader_t *shader, shaderpass_t *pass, char **ptr) @@ -2006,7 +2031,7 @@ static void Shaderpass_AlphaFunc (shader_t *shader, shaderpass_t *pass, char **p pass->shaderbits &= ~SBITS_ATEST_BITS; token = Shader_ParseString (ptr); - if (!Q_stricmp (token, "gt0")) + if (!Q_stricmp (token, "gt0")) { pass->shaderbits = SBITS_ATEST_GT0; } @@ -2017,7 +2042,7 @@ static void Shaderpass_AlphaFunc (shader_t *shader, shaderpass_t *pass, char **p else if (!Q_stricmp (token, "ge128")) { pass->shaderbits = SBITS_ATEST_GE128; - } + } } static void Shaderpass_DepthFunc (shader_t *shader, shaderpass_t *pass, char **ptr) @@ -2025,9 +2050,9 @@ static void Shaderpass_DepthFunc (shader_t *shader, shaderpass_t *pass, char **p char *token; token = Shader_ParseString (ptr); - if (!Q_stricmp (token, "equal")) + if (!Q_stricmp (token, "equal")) pass->shaderbits |= SBITS_MISC_DEPTHEQUALONLY; - else if (!Q_stricmp (token, "lequal")) + else if (!Q_stricmp (token, "lequal")) pass->shaderbits &= ~SBITS_MISC_DEPTHEQUALONLY; else Con_DPrintf("Invalid depth func %s\n", token); @@ -2035,8 +2060,8 @@ static void Shaderpass_DepthFunc (shader_t *shader, shaderpass_t *pass, char **p static void Shaderpass_DepthWrite (shader_t *shader, shaderpass_t *pass, char **ptr) { - shader->flags |= SHADER_DEPTHWRITE; - pass->shaderbits |= SBITS_MISC_DEPTHWRITE; + shader->flags |= SHADER_DEPTHWRITE; + pass->shaderbits |= SBITS_MISC_DEPTHWRITE; } static void Shaderpass_TcMod (shader_t *shader, shaderpass_t *pass, char **ptr) @@ -2288,25 +2313,25 @@ static void Shaderpass_CubeMap(shader_t *shader, shaderpass_t *pass, char **ptr) static shaderkey_t shaderpasskeys[] = { - {"rgbgen", Shaderpass_RGBGen}, - {"blendfunc", Shaderpass_BlendFunc}, - {"depthfunc", Shaderpass_DepthFunc}, - {"depthwrite", Shaderpass_DepthWrite}, - {"alphafunc", Shaderpass_AlphaFunc}, - {"tcmod", Shaderpass_TcMod}, - {"map", Shaderpass_Map}, - {"animmap", Shaderpass_AnimMap}, - {"clampmap", Shaderpass_ClampMap}, - {"videomap", Shaderpass_VideoMap}, - {"tcgen", Shaderpass_TcGen}, - {"envmap", Shaderpass_EnvMap},//for alienarena - {"nolightmap", Shaderpass_NoLightMap},//for alienarena - {"scale", Shaderpass_Scale},//for alienarena - {"scroll", Shaderpass_Scroll},//for alienarena - {"alphagen", Shaderpass_AlphaGen}, - {"alphashift", Shaderpass_AlphaShift},//for alienarena - {"alphamask", Shaderpass_AlphaMask},//for alienarena - {"detail", Shaderpass_Detail}, + {"rgbgen", Shaderpass_RGBGen }, + {"blendfunc", Shaderpass_BlendFunc }, + {"depthfunc", Shaderpass_DepthFunc }, + {"depthwrite", Shaderpass_DepthWrite }, + {"alphafunc", Shaderpass_AlphaFunc }, + {"tcmod", Shaderpass_TcMod }, + {"map", Shaderpass_Map }, + {"animmap", Shaderpass_AnimMap }, + {"clampmap", Shaderpass_ClampMap }, + {"videomap", Shaderpass_VideoMap }, + {"tcgen", Shaderpass_TcGen }, + {"envmap", Shaderpass_EnvMap },//for alienarena + {"nolightmap", Shaderpass_NoLightMap },//for alienarena + {"scale", Shaderpass_Scale },//for alienarena + {"scroll", Shaderpass_Scroll },//for alienarena + {"alphagen", Shaderpass_AlphaGen }, + {"alphashift", Shaderpass_AlphaShift },//for alienarena + {"alphamask", Shaderpass_AlphaMask },//for alienarena + {"detail", Shaderpass_Detail }, /*doom3 compat*/ {"blend", Shaderpass_BlendFunc}, @@ -2318,7 +2343,7 @@ static shaderkey_t shaderpasskeys[] = {"alphatest", Shaderpass_AlphaTest}, {"texgen", Shaderpass_TexGen}, {"cameracubemap",Shaderpass_CubeMap}, - {NULL, NULL} + {NULL, NULL} }; // =============================================================== @@ -2406,10 +2431,10 @@ static void Shader_MakeCache ( char *path ) char *Shader_Skip ( char *ptr ) { char *tok; - int brace_count; + int brace_count; // Opening brace - tok = COM_ParseExt ( &ptr, true ); + tok = COM_ParseExt ( &ptr, true ); if (!ptr) return NULL; @@ -2419,8 +2444,8 @@ char *Shader_Skip ( char *ptr ) tok = COM_ParseExt ( &ptr, true ); } - for (brace_count = 1; brace_count > 0 ; ptr++) - { + for (brace_count = 1; brace_count > 0 ; ptr++) + { tok = COM_ParseExt ( &ptr, true ); if ( !tok[0] ) @@ -2433,7 +2458,7 @@ char *Shader_Skip ( char *ptr ) { brace_count--; } - } + } return ptr; } @@ -2591,7 +2616,7 @@ void Shader_SetBlendmode (shaderpass_t *pass) void Shader_Readpass (shader_t *shader, char **ptr) { - char *token; + char *token; shaderpass_t *pass; qboolean ignore; static shader_t dummy; @@ -2610,10 +2635,10 @@ void Shader_Readpass (shader_t *shader, char **ptr) } // Set defaults - pass->flags = 0; - pass->anim_frames[0] = r_nulltex; + pass->flags = 0; + pass->anim_frames[0] = r_nulltex; pass->anim_numframes = 0; - pass->rgbgen = RGB_GEN_UNKNOWN; + pass->rgbgen = RGB_GEN_UNKNOWN; pass->alphagen = ALPHA_GEN_IDENTITY; pass->tcgen = TC_GEN_BASE; pass->numtcmods = 0; @@ -2636,6 +2661,7 @@ void Shader_Readpass (shader_t *shader, char **ptr) } else if (!Q_stricmp(token, "if")) { + int nest = 0; qboolean conditionistrue = Shader_EvaluateCondition(ptr); while (*ptr) @@ -2644,7 +2670,18 @@ void Shader_Readpass (shader_t *shader, char **ptr) if ( !token[0] ) continue; else if (token[0] == ']') - break; + { + if (--nest <= 0) + { + nest++; + if (!strcmp(token, "][")) + conditionistrue = !conditionistrue; + else + break; + } + } + else if (token[0] == '[') + nest++; else if (conditionistrue) { Shader_Parsetok (shader, pass, shaderpasskeys, token, ptr); @@ -2706,7 +2743,7 @@ void Shader_Readpass (shader_t *shader, char **ptr) static qboolean Shader_Parsetok (shader_t *shader, shaderpass_t *pass, shaderkey_t *keys, char *token, char **ptr) { - shaderkey_t *key; + shaderkey_t *key; for (key = keys; key->keyword != NULL; key++) { @@ -3487,8 +3524,7 @@ void Shader_DefaultBSPQ1(char *shortname, shader_t *s, const void *args) "}\n" ); } -#ifdef GLQUAKE - else if (qrenderer == QR_OPENGL && gl_config.arb_shader_objects) + else { builtin = ( "{\n" @@ -3499,6 +3535,7 @@ void Shader_DefaultBSPQ1(char *shortname, shader_t *s, const void *args) "tcmod turb 0 0 3 0.1\n" "if r_wateralpha != 1\n" "[\n" + "alphagen const $r_wateralpha\n" "blendfunc gl_src_alpha gl_one_minus_src_alpha\n" "]\n" "}\n" @@ -3506,35 +3543,6 @@ void Shader_DefaultBSPQ1(char *shortname, shader_t *s, const void *args) "}\n" ); } -#endif - else if (r_wateralpha.value < 1) - { - builtin = ( - "{\n" - "{\n" - "map $diffuse\n" - "tcmod turb 0 0 3 0.1\n" - "alphagen const $r_wateralpha\n" - "blendfunc blend\n" - "}\n" - "sort blend\n" - "surfaceparm nodlight\n" - "}\n" - ); - } - else - { - builtin = ( - "{\n" - "{\n" - "map $diffuse\n" - "tcmod turb 0 0 3 0.1\n" - "}\n" - "sort blend\n" - "surfaceparm nodlight\n" - "}\n" - ); - } } if (!builtin && !strncmp(shortname, "sky", 3)) { @@ -3823,6 +3831,7 @@ static void Shader_ReadShader(shader_t *s, char *shadersource) break; else if (!Q_stricmp(token, "if")) { + int nest = 0; qboolean conditionistrue = Shader_EvaluateCondition(&shadersource); while (shadersource) @@ -3830,8 +3839,19 @@ static void Shader_ReadShader(shader_t *s, char *shadersource) token = COM_ParseExt (&shadersource, true); if ( !token[0] ) continue; - else if (token[0] == ']') - break; + else if (token[0] == ']') + { + if (--nest <= 0) + { + nest++; + if (!strcmp(token, "][")) + conditionistrue = !conditionistrue; + else + break; + } + } + else if (token[0] == '[') + nest++; else if (conditionistrue) { if (token[0] == '{') diff --git a/engine/gl/gl_vidcommon.c b/engine/gl/gl_vidcommon.c index 3e3f974d0..9730e59f3 100644 --- a/engine/gl/gl_vidcommon.c +++ b/engine/gl/gl_vidcommon.c @@ -1078,7 +1078,7 @@ rendererinfo_t openglrendererinfo = { R2D_TileClear, GLDraw_Fill, GLDraw_FillRGB, - GLDraw_FadeScreen, + R2D_FadeScreen, GLDraw_BeginDisc, GLDraw_EndDisc, diff --git a/engine/gl/gl_vidnt.c b/engine/gl/gl_vidnt.c index a65971d9c..2264ae219 100644 --- a/engine/gl/gl_vidnt.c +++ b/engine/gl/gl_vidnt.c @@ -621,7 +621,7 @@ qboolean VID_SetFullDIBMode (rendererstate_t *info) return true; } -extern int gammaworks; +extern qboolean gammaworks; static void ReleaseGL(void); static qboolean CreateMainWindow(rendererstate_t *info) { diff --git a/engine/qclib/progsint.h b/engine/qclib/progsint.h index 4c203d98e..e1c25dcc5 100644 --- a/engine/qclib/progsint.h +++ b/engine/qclib/progsint.h @@ -155,7 +155,6 @@ char *SaveEnts(progfuncs_t *progfuncs, char *mem, int *size, int mode); int LoadEnts(progfuncs_t *progfuncs, char *file, float killonspawnflags); char *SaveEnt (progfuncs_t *progfuncs, char *buf, int *size, struct edict_s *ed); struct edict_s *RestoreEnt (progfuncs_t *progfuncs, char *buf, int *size, struct edict_s *ed); -char *PF_VarString (int first); void PR_StackTrace (progfuncs_t *progfuncs); extern int noextensions; diff --git a/engine/qclib/qcc.h b/engine/qclib/qcc.h index 2cae198e8..13d85a60e 100644 --- a/engine/qclib/qcc.h +++ b/engine/qclib/qcc.h @@ -319,6 +319,7 @@ typedef struct temp_s { pbool used; unsigned int size; } temp_t; +void QCC_PurgeTemps(void); //not written typedef struct QCC_def_s diff --git a/engine/qclib/qcc_pr_comp.c b/engine/qclib/qcc_pr_comp.c index e2387364f..6f5e57b2e 100644 --- a/engine/qclib/qcc_pr_comp.c +++ b/engine/qclib/qcc_pr_comp.c @@ -1370,6 +1370,10 @@ static void QCC_FreeTemps(void) #else #define QCC_FreeTemps() #endif +void QCC_PurgeTemps(void) +{ + functemps = NULL; +} //temps that are still in use over a function call can be considered dodgy. //we need to remap these to locally defined temps, on return from the function so we know we got them all. diff --git a/engine/qclib/qccmain.c b/engine/qclib/qccmain.c index 122aa5e67..18300d010 100644 --- a/engine/qclib/qccmain.c +++ b/engine/qclib/qccmain.c @@ -11,8 +11,6 @@ char QCC_copyright[1024]; int QCC_packid; char QCC_Packname[5][128]; -extern QCC_def_t *functemps; //floats/strings/funcs/ents... - extern int optres_test1; extern int optres_test2; @@ -2965,7 +2963,7 @@ void QCC_main (int argc, char **argv) //as part of the quake engine numtemps = 0; - functemps=NULL; + QCC_PurgeTemps(); strings = (void *)qccHunkAlloc(sizeof(char) * MAX_STRINGS); strofs = 1; diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index b98085d5d..047149c8f 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -1896,8 +1896,6 @@ static void SV_CustomTEnt_Spawn(int index, float *org, float *org2, int count, f int externcallsdepth; -void PR_MoveParms(int progs1, int progs2); //from 2 to 1 - float PR_LoadAditionalProgs(char *s); static void QCBUILTIN PF_addprogs(progfuncs_t *prinst, globalvars_t *pr_globals) diff --git a/engine/server/svq2_ents.c b/engine/server/svq2_ents.c index 16e460a74..72e4a4c0b 100644 --- a/engine/server/svq2_ents.c +++ b/engine/server/svq2_ents.c @@ -27,11 +27,6 @@ Encode a client frame onto the network channel ============================================================================= */ -void SV_Q2BSP_FatPVS (vec3_t org); - - - - /* ================== MSG_WriteDeltaEntity