From d0ef9e113344005031cf0761d0dbfcf6a3d7acac Mon Sep 17 00:00:00 2001 From: terminx Date: Sun, 10 Dec 2006 01:21:30 +0000 Subject: [PATCH] I guess this is some kind of an optimization :o git-svn-id: https://svn.eduke32.com/eduke32@393 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/build/src/polymost.c | 38 ++++++++++++++++++------------------ polymer/build/src/winlayer.c | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/polymer/build/src/polymost.c b/polymer/build/src/polymost.c index 8d5def1a4..b0bc3093f 100644 --- a/polymer/build/src/polymost.c +++ b/polymer/build/src/polymost.c @@ -135,20 +135,20 @@ long fullbrightloadingpass = 0; long fullbrightdrawingpass = 0; long shadeforfullbrightpass; -float fogcalc (signed char shade, char vis) -{ - float result; -// if(vis < 16) vis = 16; - if (vis < 240) result = (float)(vis+16+(shade<0?(-(shade)*(shade))/8.f:((shade)*(shade))/8.f)); - else result = (float)((vis-240+(shade<0?(-(shade)*(shade))/8.f:((shade)*(shade))/8.f))/(klabs(vis-256))); +float fogresult; - result *= gvisibility; +float fogcalc (const signed char *shade, const char *vis) +{ + if (*vis < 240) fogresult = (float)(*vis+16+(*shade<0?(-(*shade)*(*shade))/8.f:((*shade)*(*shade))/8.f)); + else fogresult = (float)((*vis-240+(*shade<0?(-(*shade)*(*shade))/8.f:((*shade)*(*shade))/8.f))/(klabs(*vis-256))); + + fogresult *= gvisibility; // initprintf("result: %.f\n",result); - if (result < 0.010) return (0.010); - else if (result > 10.000) return (10.000); - else return (result); + if (fogresult < 0.010) return (0.010); + else if (fogresult > 10.000) return (10.000); + else return (fogresult); } #endif @@ -2509,7 +2509,7 @@ static void polymost_drawalls (long bunch) if (globalposz >= getflorzofslope(sectnum,globalposx,globalposy)) domostpolymethod = -1; //Back-face culling #ifdef USE_OPENGL if (!nofog) - bglFogf(GL_FOG_DENSITY,fogcalc(sec->floorshade,sec->visibility)); + bglFogf(GL_FOG_DENSITY,fogcalc(&sec->floorshade,&sec->visibility)); #endif pow2xsplit = 0; domost(x0,fy0,x1,fy1); //flor domostpolymethod = 0; @@ -2528,7 +2528,7 @@ static void polymost_drawalls (long bunch) } */ if (!nofog) - bglFogf(GL_FOG_DENSITY,fogcalc(sec->floorshade,sec->visibility) * 0.005); + bglFogf(GL_FOG_DENSITY,fogcalc(&sec->floorshade,&sec->visibility) * 0.005); //Use clamping for tiled sky textures for (i=(1<0;i--) @@ -2869,7 +2869,7 @@ static void polymost_drawalls (long bunch) if (globalposz <= getceilzofslope(sectnum,globalposx,globalposy)) domostpolymethod = -1; //Back-face culling #ifdef USE_OPENGL if (!nofog) - bglFogf(GL_FOG_DENSITY,fogcalc(sec->ceilingshade,sec->visibility)); + bglFogf(GL_FOG_DENSITY,fogcalc(&sec->ceilingshade,&sec->visibility)); #endif pow2xsplit = 0; domost(x1,cy1,x0,cy0); //ceil domostpolymethod = 0; @@ -2887,7 +2887,7 @@ static void polymost_drawalls (long bunch) } */ if (!nofog) - bglFogf(GL_FOG_DENSITY,fogcalc(sec->ceilingshade,sec->visibility) * 0.005); + bglFogf(GL_FOG_DENSITY,fogcalc(&sec->ceilingshade,&sec->visibility) * 0.005); //Use clamping for tiled sky textures for (i=(1<0;i--) if (pskyoff[i] != pskyoff[i-1]) @@ -3199,7 +3199,7 @@ static void polymost_drawalls (long bunch) if (wal->cstat&256) { gvx = -gvx; gvy = -gvy; gvo = -gvo; } //yflip #ifdef USE_OPENGL if (!nofog) - bglFogf(GL_FOG_DENSITY,fogcalc(wal->shade,sec->visibility)); + bglFogf(GL_FOG_DENSITY,fogcalc(&wal->shade,&sec->visibility)); #endif pow2xsplit = 1; domost(x1,ocy1,x0,ocy0); if (wal->cstat&8) { gux = ogux; guy = oguy; guo = oguo; } @@ -3237,7 +3237,7 @@ static void polymost_drawalls (long bunch) if (nwal->cstat&256) { gvx = -gvx; gvy = -gvy; gvo = -gvo; } //yflip #ifdef USE_OPENGL if (!nofog) - bglFogf(GL_FOG_DENSITY,fogcalc(nwal->shade,sec->visibility)); + bglFogf(GL_FOG_DENSITY,fogcalc(&nwal->shade,&sec->visibility)); #endif pow2xsplit = 1; domost(x0,ofy0,x1,ofy1); if (wal->cstat&(2+8)) { guo = oguo; gux = ogux; guy = oguy; } @@ -3271,7 +3271,7 @@ static void polymost_drawalls (long bunch) if (wal->cstat&256) { gvx = -gvx; gvy = -gvy; gvo = -gvo; } //yflip #ifdef USE_OPENGL if (!nofog) - bglFogf(GL_FOG_DENSITY,fogcalc(wal->shade,sec->visibility)); + bglFogf(GL_FOG_DENSITY,fogcalc(&wal->shade,&sec->visibility)); #endif pow2xsplit = 1; domost(x0,-10000,x1,-10000); } @@ -3726,7 +3726,7 @@ if (yp1 < SCISDIST) { t1 = (SCISDIST-oyp0)/(yp1-oyp0); xp1 = (xp1-oxp0)*t1+oxp0; bglFogfv(GL_FOG_COLOR,col); if (!nofog) - bglFogf(GL_FOG_DENSITY,fogcalc(wal->shade,sec->visibility)); + bglFogf(GL_FOG_DENSITY,fogcalc(&wal->shade,&sec->visibility)); } } #endif @@ -3834,7 +3834,7 @@ if (tspr->cstat&2) { if (!(tspr->cstat&512)) method = 2+4; else method = 3+4; } col[3] = 0; bglFogfv(GL_FOG_COLOR,col); //default is 0,0,0,0 - bglFogf(GL_FOG_DENSITY,fogcalc(globalshade,sector[tspr->sectnum].visibility)); + bglFogf(GL_FOG_DENSITY,fogcalc((signed char *)&globalshade,§or[tspr->sectnum].visibility)); } while (rendmode >= 3 && !(spriteext[tspr->owner].flags&SPREXT_NOTMD)) { diff --git a/polymer/build/src/winlayer.c b/polymer/build/src/winlayer.c index 5115ad9aa..ffef2139e 100644 --- a/polymer/build/src/winlayer.c +++ b/polymer/build/src/winlayer.c @@ -3512,7 +3512,7 @@ static LRESULT CALLBACK WndProcCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPA if (!appactive && fullscreen) { realfs = fullscreen; - setvideomode(xdim,ydim,bpp,!fullscreen); + setgamemode(!fullscreen,xdim,ydim,bpp); ShowWindow(hWindow, SW_MINIMIZE); } else if (appactive && realfs) @@ -3520,7 +3520,7 @@ static LRESULT CALLBACK WndProcCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPA ShowWindow(hWindow, SW_SHOWNORMAL); SetForegroundWindow(hWindow); SetFocus(hWindow); - setvideomode(xdim,ydim,bpp,realfs); + setgamemode(realfs,xdim,ydim,bpp); realfs = 0; } }