From 551f37340b96afbefe4d70dcfc7a31aa5564911d Mon Sep 17 00:00:00 2001 From: TimeServ Date: Sat, 6 May 2006 03:28:48 +0000 Subject: [PATCH] r_drawflat, r_wallcolour, r_floorcolour to callbacks git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2243 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/renderer.c | 6 +-- engine/gl/gl_ppl.c | 97 +++++++++++++++++++--------------------- engine/gl/gl_rmisc.c | 10 +++++ 3 files changed, 60 insertions(+), 53 deletions(-) diff --git a/engine/client/renderer.c b/engine/client/renderer.c index ba215cd50..fea5f6f24 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -219,9 +219,9 @@ cvar_t r_lightstylespeed = SCVAR("r_lightstylespeed", "10"); extern cvar_t r_novis; extern cvar_t r_netgraph; -cvar_t r_drawflat = SCVARF("r_drawflat","0", CVAR_SEMICHEAT); -cvar_t r_wallcolour = SCVAR("r_wallcolour","0 0 1"); -cvar_t r_floorcolour = SCVAR("r_floorcolour","0.5 0.5 1"); +cvar_t r_drawflat = SCVARF("r_drawflat","0", CVAR_SEMICHEAT|CVAR_RENDERERCALLBACK); +cvar_t r_wallcolour = SCVAR("r_wallcolour","1 1 1"); +cvar_t r_floorcolour = SCVAR("r_floorcolour","1 1 1"); cvar_t d_palconvwrite = SCVAR("d_palconvwrite", "1"); cvar_t d_palremapsize = SCVARF("d_palremapsize", "64", CVAR_RENDERERLATCH); diff --git a/engine/gl/gl_ppl.c b/engine/gl/gl_ppl.c index 70b29e085..dafd98cf3 100644 --- a/engine/gl/gl_ppl.c +++ b/engine/gl/gl_ppl.c @@ -1161,11 +1161,22 @@ static void PPL_BaseChain_Specular_FP(msurface_t *s, texture_t *tex) #endif +static vec_t wallcolour[4] = {0,0,0,1}; +static vec_t floorcolour[4] = {0,0,0,1}; + //single textured. +void GLR_Wallcolour_Callback(struct cvar_s *var, char *oldvalue) +{ + SCR_StringToRGB(var->string, wallcolour, 1); +} + +void GLR_Floorcolour_Callback(struct cvar_s *var, char *oldvalue) +{ + SCR_StringToRGB(var->string, floorcolour, 1); +} + static void PPL_BaseChain_Flat(msurface_t *first) { - static vec_t wallcolour[4] = {0,0,0,1}; - static vec_t floorcolour[4] = {0,0,0,1}; msurface_t *s; int iswall = -1; int vi=-10; @@ -1183,21 +1194,6 @@ static void PPL_BaseChain_Flat(msurface_t *first) qglEnable(GL_TEXTURE_2D); return; } - else - { - if (r_wallcolour.modified) - { - r_wallcolour.modified = false; - - SCR_StringToRGB(r_wallcolour.string, wallcolour, 1); - } - if (r_floorcolour.modified) - { - r_floorcolour.modified = false; - - SCR_StringToRGB(r_floorcolour.string, floorcolour, 1); - } - } PPL_EnableVertexArrays(); GL_TexEnv(GL_MODULATE); @@ -1260,6 +1256,39 @@ static void PPL_BaseChain_Flat(msurface_t *first) qglColor3f(1,1,1); } +static int nprtextures[10]; + +void GLR_Drawflat_Callback(struct cvar_s *var, char *oldvalue) +{ + int i; + + for (i = 0; i < sizeof(nprtextures)/sizeof(nprtextures[0]); i++) + { + nprtextures[i] = Mod_LoadHiResTexture(va("sketch%i", i+1), "sketch", true, false, false); + if (!nprtextures[i]) + { + int data[128*128]; + FILE *file; + unsigned char *f; + int p; + + file = fopen(va("nprtextures/tex%i_3_128_128.raw", i+1), "rb"); + + if (file) + { + f = Hunk_TempAlloc(128*128*3); + if (fread(f, 128*3, 128, file) == 128) + { + for (p = 0; p < 128*128; p++) + data[p] = LittleLong(f[p*3] + (f[p*3+1]<<8) + (f[p*3+2]<<16) + (255<<24)); + nprtextures[i] = GL_LoadTexture32 (va("textures/tex%i_3_128_128.raw", i+1), 128, 128, data, true, false); + } + fclose(file); + } + } + } +} + static void PPL_BaseChain_NPR_Sketch(msurface_t *first) { msurface_t *s; @@ -1267,39 +1296,7 @@ static void PPL_BaseChain_NPR_Sketch(msurface_t *first) int i; glRect_t *theRect; - static int textures[10]; - GL_SelectTexture(GL_TEXTURE0_ARB); - if (r_drawflat.modified) //reload textures - { - r_drawflat.modified = false; - for (i = 0; i < sizeof(textures)/sizeof(textures[0]); i++) - { - textures[i] = Mod_LoadHiResTexture(va("sketch%i", i+1), "sketch", true, false, false); - if (!textures[i]) - { - int data[128*128]; - FILE *file; - unsigned char *f; - int p; - - file = fopen(va("textures/tex%i_3_128_128.raw", i+1), "rb"); - - if (file) - { - f = Hunk_TempAlloc(128*128*3); - if (fread(f, 128*3, 128, file) == 128) - { - for (p = 0; p < 128*128; p++) - data[p] = LittleLong(f[p*3] + (f[p*3+1]<<8) + (f[p*3+2]<<16) + (255<<24)); - textures[i] = GL_LoadTexture32 (va("textures/tex%i_3_128_128.raw", i+1), 128, 128, data, true, false); - } - fclose(file); - } - } - } - } - PPL_EnableVertexArrays(); //draw the surface properly @@ -1323,7 +1320,7 @@ static void PPL_BaseChain_NPR_Sketch(msurface_t *first) PPL_FlushArrays(); vi = s->lightmaptexturenum; - GL_MBind(GL_TEXTURE0_ARB, textures[rand()%10]); + GL_MBind(GL_TEXTURE0_ARB, nprtextures[rand()%10]); if (vi < 0) GL_MBind(GL_TEXTURE1_ARB, 0 ); diff --git a/engine/gl/gl_rmisc.c b/engine/gl/gl_rmisc.c index 9b68e3c37..ac1a9e1c7 100644 --- a/engine/gl/gl_rmisc.c +++ b/engine/gl/gl_rmisc.c @@ -661,6 +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; 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); @@ -673,6 +674,9 @@ void GL_Fontedgeclamp_Callback (struct cvar_s *var, char *oldvalue); void GLVID_Conwidth_Callback(struct cvar_s *var, char *oldvalue); 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_Drawflat_Callback(struct cvar_s *var, char *oldvalue); void GLR_DeInit (void) { @@ -694,6 +698,9 @@ void GLR_DeInit (void) Cvar_Unhook(&vid_conautoscale); Cvar_Unhook(&vid_conheight); Cvar_Unhook(&vid_conwidth); + Cvar_Unhook(&r_wallcolour); + Cvar_Unhook(&r_floorcolour); + Cvar_Unhook(&r_drawflat); GLDraw_DeInit(); @@ -719,6 +726,9 @@ void GLR_Init (void) Cvar_Hook(&vid_conautoscale, GLVID_Conautoscale_Callback); Cvar_Hook(&vid_conheight, GLVID_Conheight_Callback); Cvar_Hook(&vid_conwidth, GLVID_Conwidth_Callback); + Cvar_Hook(&r_floorcolour, GLR_Floorcolour_Callback); + Cvar_Hook(&r_wallcolour, GLR_Wallcolour_Callback); + Cvar_Hook(&r_drawflat, GLR_Drawflat_Callback); R_InitBubble();