From 6197004228524bbf416086f62f44c8270dd87888 Mon Sep 17 00:00:00 2001 From: TimeServ Date: Mon, 8 May 2006 04:30:04 +0000 Subject: [PATCH] add r_floortexture/r_walltexture, tweak to Doom speaker sounds git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2252 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/renderer.c | 5 ++ engine/client/snd_mem.c | 7 ++- engine/gl/gl_ppl.c | 122 ++++++++++++++++++++++++++++++++++++++- engine/gl/gl_rmisc.c | 8 ++- 4 files changed, 136 insertions(+), 6 deletions(-) diff --git a/engine/client/renderer.c b/engine/client/renderer.c index a0ee9cf69..c62dc5277 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -222,6 +222,8 @@ extern cvar_t r_netgraph; cvar_t r_drawflat = SCVARF("r_drawflat","0", CVAR_SEMICHEAT|CVAR_RENDERERCALLBACK); cvar_t r_wallcolour = SCVARF("r_wallcolour","1 1 1", CVAR_RENDERERCALLBACK); cvar_t r_floorcolour = SCVARF("r_floorcolour","1 1 1", CVAR_RENDERERCALLBACK); +cvar_t r_walltexture = SCVARF("r_walltexture","", CVAR_RENDERERCALLBACK); +cvar_t r_floortexture = SCVARF("r_floortexture","", CVAR_RENDERERCALLBACK); cvar_t d_palconvwrite = SCVAR("d_palconvwrite", "1"); cvar_t d_palremapsize = SCVARF("d_palremapsize", "64", CVAR_RENDERERLATCH); @@ -364,6 +366,9 @@ void GLRenderer_Init(void) Cvar_Register (&r_wallcolour, GLRENDEREROPTIONS); Cvar_Register (&r_floorcolour, GLRENDEREROPTIONS); + Cvar_Register (&r_walltexture, GLRENDEREROPTIONS); + Cvar_Register (&r_floortexture, GLRENDEREROPTIONS); + Cvar_Register (&r_vertexdlights, GLRENDEREROPTIONS); Cvar_Register (&gl_schematics, GLRENDEREROPTIONS); diff --git a/engine/client/snd_mem.c b/engine/client/snd_mem.c index 4499e1162..d1f8c5a06 100644 --- a/engine/client/snd_mem.c +++ b/engine/client/snd_mem.c @@ -148,8 +148,9 @@ void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, qbyte *data) //============================================================================= #ifdef DOOMWADS -#define DSPK_RATE 140 -#define DSPK_FREQ 30 +// needs fine tuning.. educated guesses +#define DSPK_RATE 128 +#define DSPK_FREQ 31 sfxcache_t *S_LoadDoomSpeakerSound (sfx_t *s, qbyte *data, int datalen, int sndspeed) { @@ -308,7 +309,7 @@ S_LoadSound_t AudioInputPlugins[10] = S_LoadWavSound, #ifdef DOOMWADS S_LoadDoomSound, - S_LoadDoomSpeakerSound + S_LoadDoomSpeakerSound, #endif }; diff --git a/engine/gl/gl_ppl.c b/engine/gl/gl_ppl.c index 52efb1e17..7b32228b4 100644 --- a/engine/gl/gl_ppl.c +++ b/engine/gl/gl_ppl.c @@ -1163,6 +1163,9 @@ static void PPL_BaseChain_Specular_FP(msurface_t *s, texture_t *tex) static vec_t wallcolour[4] = {0,0,0,1}; static vec_t floorcolour[4] = {0,0,0,1}; +static int walltexture = 0; +static int floortexture = 0; +static qboolean simpletextures = false; //single textured. void GLR_Wallcolour_Callback(struct cvar_s *var, char *oldvalue) @@ -1175,6 +1178,36 @@ void GLR_Floorcolour_Callback(struct cvar_s *var, char *oldvalue) SCR_StringToRGB(var->string, floorcolour, 1); } +void GLR_Walltexture_Callback(struct cvar_s *var, char *oldvalue) +{ + if (!var->string[0]) + { + walltexture = 0; + if (!floortexture) + simpletextures = false; + return; + } + + walltexture = Mod_LoadHiResTexture(var->string, NULL, true, false, true); + if (walltexture) + simpletextures = true; +} + +void GLR_Floortexture_Callback(struct cvar_s *var, char *oldvalue) +{ + if (!var->string[0]) + { + floortexture = 0; + if (!walltexture) + simpletextures = false; + return; + } + + floortexture = Mod_LoadHiResTexture(var->string, NULL, true, false, true); + if (floortexture) + simpletextures = true; +} + static void PPL_BaseChain_Flat(msurface_t *first) { msurface_t *s; @@ -1233,7 +1266,7 @@ static void PPL_BaseChain_Flat(msurface_t *first) } } - if ((s->plane->normal[2]*s->plane->normal[2]) <= 0.5*0.5) + if (s->plane->normal[2] <= 0.5) { if (iswall != 0) { @@ -1292,6 +1325,88 @@ void GLR_Drawflat_Callback(struct cvar_s *var, char *oldvalue) } } +static void PPL_BaseChain_SimpleTexture(msurface_t *first) +{ + msurface_t *s; + int vi=-10; + int iswall; + int oldwall=-1; + glRect_t *theRect; + + GL_SelectTexture(GL_TEXTURE0_ARB); + PPL_EnableVertexArrays(); + +//draw the surface properly + qglEnable(GL_TEXTURE_2D); + qglEnableClientState(GL_TEXTURE_COORD_ARRAY); + qglTexCoordPointer(2, GL_FLOAT, sizeof(surfvertexarray_t), varray_v->stw); + + GL_TexEnv(GL_MODULATE); + + GL_SelectTexture(GL_TEXTURE1_ARB); + GL_TexEnv(GL_MODULATE); + qglEnable(GL_TEXTURE_2D); + qglEnableClientState(GL_TEXTURE_COORD_ARRAY); + qglTexCoordPointer(2, GL_FLOAT, sizeof(surfvertexarray_t), varray_v->stl); + + for (s = first; s ; s=s->texturechain) + { + if (s->plane->normal[2] <= 0.5) + iswall = 1; + else + iswall = 0; + + if (vi != s->lightmaptexturenum || iswall != oldwall) + { + PPL_FlushArrays(); + vi = s->lightmaptexturenum; + oldwall = iswall; + + if (iswall) + { + GL_MBind(GL_TEXTURE0_ARB, walltexture); + qglColor4fv(wallcolour); + } + else + { + GL_MBind(GL_TEXTURE0_ARB, floortexture); + qglColor4fv(floorcolour); + } + + if (vi < 0) + GL_MBind(GL_TEXTURE1_ARB, 0 ); + else + { + GL_MBind(GL_TEXTURE1_ARB, lightmap_textures[vi] ); + if (lightmap[vi]->modified) + { + lightmap[vi]->modified = false; + theRect = &lightmap[vi]->rectchange; + qglTexSubImage2D(GL_TEXTURE_2D, 0, 0, theRect->t, + LMBLOCK_WIDTH, theRect->h, gl_lightmap_format, GL_UNSIGNED_BYTE, + lightmap[vi]->lightmaps+(theRect->t) *LMBLOCK_WIDTH*lightmap_bytes); + theRect->l = LMBLOCK_WIDTH; + theRect->t = LMBLOCK_HEIGHT; + theRect->h = 0; + theRect->w = 0; + } + } + } + PPL_GenerateArrays(s); + } + PPL_FlushArrays(); + qglDisableClientState(GL_TEXTURE_COORD_ARRAY); + qglDisableClientState(GL_VERTEX_ARRAY); + qglDisable(GL_TEXTURE_2D); + qglColor3f(1,1,1); + + GL_SelectTexture(GL_TEXTURE0_ARB); + qglDisableClientState(GL_TEXTURE_COORD_ARRAY); + qglDisableClientState(GL_VERTEX_ARRAY); + qglEnable(GL_TEXTURE_2D); + qglColor3f(1,1,1); +} + static void PPL_BaseChain_NPR_Sketch(msurface_t *first) { msurface_t *s; @@ -1402,7 +1517,10 @@ static void PPL_BaseTextureChain(msurface_t *first) } else { - PPL_BaseChain_Flat(first); //who cares about texture? :/ + if (gl_mtexarbable >= 2 && simpletextures) + PPL_BaseChain_SimpleTexture(first); + else + PPL_BaseChain_Flat(first); //who cares about texture? :/ return; } } diff --git a/engine/gl/gl_rmisc.c b/engine/gl/gl_rmisc.c index b4b296bbe..08138e83e 100644 --- a/engine/gl/gl_rmisc.c +++ b/engine/gl/gl_rmisc.c @@ -661,7 +661,7 @@ extern cvar_t r_stains, r_stainfadetime, r_stainfadeammount; extern cvar_t gl_conback, gl_font, gl_smoothfont, gl_fontedgeclamp, r_menutint; extern cvar_t vid_conautoscale, vid_conheight, vid_conwidth; extern cvar_t crosshair, crosshairimage, crosshaircolor, r_skyboxname; -extern cvar_t r_floorcolour, r_wallcolour; +extern cvar_t r_floorcolour, r_wallcolour, r_floortexture, r_walltexture; 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); @@ -676,6 +676,8 @@ void GLVID_Conautoscale_Callback(struct cvar_s *var, char *oldvalue); void GLVID_Conheight_Callback(struct cvar_s *var, char *oldvalue); void GLR_Wallcolour_Callback(struct cvar_s *var, char *oldvalue); void GLR_Floorcolour_Callback(struct cvar_s *var, char *oldvalue); +void GLR_Walltexture_Callback(struct cvar_s *var, char *oldvalue); +void GLR_Floortexture_Callback(struct cvar_s *var, char *oldvalue); void GLR_Drawflat_Callback(struct cvar_s *var, char *oldvalue); void GLV_Gamma_Callback(struct cvar_s *var, char *oldvalue); @@ -701,6 +703,8 @@ void GLR_DeInit (void) Cvar_Unhook(&vid_conwidth); Cvar_Unhook(&r_wallcolour); Cvar_Unhook(&r_floorcolour); + Cvar_Unhook(&r_walltexture); + Cvar_Unhook(&r_floortexture); Cvar_Unhook(&r_drawflat); Cvar_Unhook(&v_gamma); Cvar_Unhook(&v_contrast); @@ -731,6 +735,8 @@ void GLR_Init (void) Cvar_Hook(&vid_conwidth, GLVID_Conwidth_Callback); Cvar_Hook(&r_floorcolour, GLR_Floorcolour_Callback); Cvar_Hook(&r_wallcolour, GLR_Wallcolour_Callback); + Cvar_Hook(&r_floortexture, GLR_Floortexture_Callback); + Cvar_Hook(&r_walltexture, GLR_Walltexture_Callback); Cvar_Hook(&r_drawflat, GLR_Drawflat_Callback); Cvar_Hook(&v_gamma, GLV_Gamma_Callback); Cvar_Hook(&v_contrast, GLV_Gamma_Callback);