From ad24a1ce319299af81be2a3c215ca65c7ebb733c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 30 Dec 2019 19:29:32 +0100 Subject: [PATCH] - place weapon sprites in a separate render list. They need to be drawn in a different pass than the 2D overlay HUD so the backend must have them separately. --- source/blood/src/view.cpp | 150 +++++++++--------- source/build/src/engine.cpp | 8 +- source/build/src/polymost.cpp | 2 +- source/common/2d/v_2ddrawer.cpp | 4 +- source/common/2d/v_2ddrawer.h | 29 +++- source/common/console/c_console.cpp | 34 ++-- source/common/menu/listmenu.cpp | 16 +- source/common/menu/loadsavemenu.cpp | 26 +-- source/common/menu/menu.cpp | 6 +- source/common/menu/menuinput.cpp | 16 +- source/common/menu/messagebox.cpp | 10 +- source/common/menu/optionmenu.cpp | 2 +- source/common/menu/optionmenuitems.h | 2 +- source/common/menu/savegamemanager.cpp | 2 +- .../rendering/gl/system/gl_framebuffer.cpp | 20 ++- source/common/rendering/v_framebuffer.cpp | 4 +- source/common/utility/stats.cpp | 2 +- source/duke3d/src/screens.cpp | 4 +- source/exhumed/src/gun.cpp | 2 + source/exhumed/src/view.cpp | 2 +- source/glbackend/glbackend.cpp | 16 +- source/glbackend/hw_draw2d.cpp | 1 - source/rr/src/screens.cpp | 4 +- source/sw/src/panel.cpp | 5 + 24 files changed, 204 insertions(+), 163 deletions(-) diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index 7b63d9fb4..1eafb05d0 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -63,6 +63,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "zstring.h" #include "menu/menu.h" #include "gstrings.h" +#include "v_2ddrawer.h" CVARD(Bool, hud_powerupduration, true, CVAR_ARCHIVE|CVAR_FRONTEND_BLOOD, "enable/disable displaying the remaining seconds for power-ups") @@ -3065,11 +3066,11 @@ void viewDrawScreen(void) newaspect_enable = 1; videoSetCorrectedAspect(); } - renderSetAspect(Blrintf(float(viewingrange) * tanf(r_fov * (PI/360.f))), yxaspect); + renderSetAspect(Blrintf(float(viewingrange) * tanf(r_fov * (PI / 360.f))), yxaspect); int cX = gView->pSprite->x; int cY = gView->pSprite->y; int cZ = gView->zView; - int zDelta = gView->zWeapon-gView->zView-(12<<8); + int zDelta = gView->zWeapon - gView->zView - (12 << 8); fix16_t cA = gView->q16ang; fix16_t q16horiz = gView->q16horiz; fix16_t q16slopehoriz = gView->q16slopehoriz; @@ -3097,7 +3098,7 @@ void viewDrawScreen(void) } else { - VIEW *pView = &gPrevView[gViewIndex]; + VIEW* pView = &gPrevView[gViewIndex]; cX = interpolate(pView->at50, cX, gInterpolate); cY = interpolate(pView->at54, cY, gInterpolate); cZ = interpolate(pView->at38, cZ, gInterpolate); @@ -3119,13 +3120,13 @@ void viewDrawScreen(void) cZ += shakeZ; v4c += shakeBobX; v48 += shakeBobY; - q16horiz += fix16_from_int(mulscale30(0x40000000-Cos(gView->tiltEffect<<2), 30)); + q16horiz += fix16_from_int(mulscale30(0x40000000 - Cos(gView->tiltEffect << 2), 30)); if (gViewPos == 0) { if (cl_viewhbob) { - cX -= mulscale30(v74, Sin(fix16_to_int(cA)))>>4; - cY += mulscale30(v74, Cos(fix16_to_int(cA)))>>4; + cX -= mulscale30(v74, Sin(fix16_to_int(cA))) >> 4; + cY += mulscale30(v74, Cos(fix16_to_int(cA))) >> 4; } if (cl_viewvbob) { @@ -3135,7 +3136,7 @@ void viewDrawScreen(void) { q16horiz += q16slopehoriz; } - cZ += fix16_to_int(q16horiz*10); + cZ += fix16_to_int(q16horiz * 10); cameradist = -1; cameraclock = (int)totalclock; } @@ -3174,10 +3175,10 @@ void viewDrawScreen(void) tiltdim = 320; } renderSetTarget(TILTBUFFER, tiltdim, tiltdim); - int nAng = v78&511; + int nAng = v78 & 511; if (nAng > 256) { - nAng = 512-nAng; + nAng = 512 - nAng; } renderSetAspect(mulscale16(vr, dmulscale32(Cos(nAng), 262144, Sin(nAng), 163840)), yxaspect); } @@ -3188,7 +3189,7 @@ void viewDrawScreen(void) } else if (v4 && gNetPlayers > 1) { - int tmp = ((int)totalclock/240)%(gNetPlayers-1); + int tmp = ((int)totalclock / 240) % (gNetPlayers - 1); int i = connecthead; while (1) { @@ -3199,7 +3200,7 @@ void viewDrawScreen(void) i = connectpoint2[i]; tmp--; } - PLAYER *pOther = &gPlayer[i]; + PLAYER* pOther = &gPlayer[i]; //othercameraclock = gGameClock; if (!tileData(4079)) { @@ -3215,16 +3216,16 @@ void viewDrawScreen(void) int v54 = 0; if (pOther->flickerEffect) { - int nValue = ClipHigh(pOther->flickerEffect*8, 2000); - v54 += QRandom2(nValue>>8); - v50 += QRandom2(nValue>>8); - vd8 += QRandom2(nValue>>4); - vd4 += QRandom2(nValue>>4); + int nValue = ClipHigh(pOther->flickerEffect * 8, 2000); + v54 += QRandom2(nValue >> 8); + v50 += QRandom2(nValue >> 8); + vd8 += QRandom2(nValue >> 4); + vd4 += QRandom2(nValue >> 4); vd0 += QRandom2(nValue); } if (pOther->quakeEffect) { - int nValue = ClipHigh(pOther->quakeEffect*8, 2000); + int nValue = ClipHigh(pOther->quakeEffect * 8, 2000); v54 += QRandom2(nValue >> 8); v50 += QRandom2(nValue >> 8); vd8 += QRandom2(nValue >> 4); @@ -3237,21 +3238,21 @@ void viewDrawScreen(void) { v14 = 10; } - memcpy(bakMirrorGotpic, gotpic+510, 2); - memcpy(gotpic+510, otherMirrorGotpic, 2); - g_visibility = (int32_t)(ClipLow(gVisibility-32*pOther->visibility, 0) * (numplayers > 1 ? 1.f : r_ambientlightrecip)); + memcpy(bakMirrorGotpic, gotpic + 510, 2); + memcpy(gotpic + 510, otherMirrorGotpic, 2); + g_visibility = (int32_t)(ClipLow(gVisibility - 32 * pOther->visibility, 0) * (numplayers > 1 ? 1.f : r_ambientlightrecip)); int vc4, vc8; getzsofslope(vcc, vd8, vd4, &vc8, &vc4); if (vd0 >= vc4) { - vd0 = vc4-(gUpperLink[vcc] >= 0 ? 0 : (8<<8)); + vd0 = vc4 - (gUpperLink[vcc] >= 0 ? 0 : (8 << 8)); } if (vd0 <= vc8) { - vd0 = vc8+(gLowerLink[vcc] >= 0 ? 0 : (8<<8)); + vd0 = vc8 + (gLowerLink[vcc] >= 0 ? 0 : (8 << 8)); } v54 = ClipRange(v54, -200, 200); -RORHACKOTHER: + RORHACKOTHER: int ror_status[16]; for (int i = 0; i < 16; i++) ror_status[i] = TestBitString(gotpic, 4080 + i); @@ -3265,8 +3266,8 @@ RORHACKOTHER: do_ror_hack = true; if (do_ror_hack) goto RORHACKOTHER; - memcpy(otherMirrorGotpic, gotpic+510, 2); - memcpy(gotpic+510, bakMirrorGotpic, 2); + memcpy(otherMirrorGotpic, gotpic + 510, 2); + memcpy(gotpic + 510, bakMirrorGotpic, 2); viewProcessSprites(vd8, vd4, vd0, v50, gInterpolate); renderDrawMasks(); renderRestoreTarget(); @@ -3286,26 +3287,26 @@ RORHACKOTHER: int unk = 0; while (nSprite >= 0) { - spritetype *pSprite = &sprite[nSprite]; + spritetype* pSprite = &sprite[nSprite]; int nXSprite = pSprite->extra; dassert(nXSprite > 0 && nXSprite < kMaxXSprites); - XSPRITE *pXSprite = &xsprite[nXSprite]; + XSPRITE* pXSprite = &xsprite[nXSprite]; if (TestBitString(gotsector, pSprite->sectnum)) { - unk += pXSprite->data3*32; + unk += pXSprite->data3 * 32; } nSprite = nextspritestat[nSprite]; } nSprite = headspritestat[kStatProjectile]; while (nSprite >= 0) { - spritetype *pSprite = &sprite[nSprite]; + spritetype* pSprite = &sprite[nSprite]; switch (pSprite->type) { - case kMissileFlareRegular: - case kMissileTeslaAlt: - case kMissileFlareAlt: - case kMissileTeslaRegular: - if (TestBitString(gotsector, pSprite->sectnum)) unk += 256; - break; + case kMissileFlareRegular: + case kMissileTeslaAlt: + case kMissileFlareAlt: + case kMissileTeslaRegular: + if (TestBitString(gotsector, pSprite->sectnum)) unk += 256; + break; } nSprite = nextspritestat[nSprite]; } @@ -3315,17 +3316,17 @@ RORHACKOTHER: getzsofslope(nSectnum, cX, cY, &vfc, &vf8); if (cZ >= vf8) { - cZ = vf8-(gUpperLink[nSectnum] >= 0 ? 0 : (8<<8)); + cZ = vf8 - (gUpperLink[nSectnum] >= 0 ? 0 : (8 << 8)); } if (cZ <= vfc) { - cZ = vfc+(gLowerLink[nSectnum] >= 0 ? 0 : (8<<8)); + cZ = vfc + (gLowerLink[nSectnum] >= 0 ? 0 : (8 << 8)); } q16horiz = ClipRange(q16horiz, F16(-200), F16(200)); -RORHACK: + RORHACK: int ror_status[16]; for (int i = 0; i < 16; i++) - ror_status[i] = TestBitString(gotpic, 4080+i); + ror_status[i] = TestBitString(gotpic, 4080 + i); fix16_t deliriumPitchI = interpolate(fix16_from_int(deliriumPitchO), fix16_from_int(deliriumPitch), gInterpolate); DrawMirrors(cX, cY, cZ, cA, q16horiz + fix16_from_int(defaultHoriz) + deliriumPitchI, gInterpolate, gViewIndex); int bakCstat = gView->pSprite->cstat; @@ -3347,7 +3348,7 @@ RORHACK: viewProcessSprites(cX, cY, cZ, fix16_to_int(cA), gInterpolate); bool do_ror_hack = false; for (int i = 0; i < 16; i++) - if (ror_status[i] != TestBitString(gotpic, 4080+i)) + if (ror_status[i] != TestBitString(gotpic, 4080 + i)) do_ror_hack = true; if (do_ror_hack) { @@ -3367,28 +3368,28 @@ RORHACK: { if (videoGetRenderMode() == REND_CLASSIC) { - dassert(tileData(TILTBUFFER) != 0); + dassert(tileData(TILTBUFFER) != 0); renderRestoreTarget(); - int vrc = 64+4+2+1024; + int vrc = 64 + 4 + 2 + 1024; if (bDelirium) { - vrc = 64+32+4+2+1+1024; + vrc = 64 + 32 + 4 + 2 + 1 + 1024; } int nAng = v78 & 511; if (nAng > 256) { nAng = 512 - nAng; } - int nScale = dmulscale32(Cos(nAng), 262144, Sin(nAng), 163840)>>tiltcs; - rotatesprite(160<<16, 100<<16, nScale, v78+512, TILTBUFFER, 0, 0, vrc, gViewX0, gViewY0, gViewX1, gViewY1); + int nScale = dmulscale32(Cos(nAng), 262144, Sin(nAng), 163840) >> tiltcs; + rotatesprite(160 << 16, 100 << 16, nScale, v78 + 512, TILTBUFFER, 0, 0, vrc, gViewX0, gViewY0, gViewX1, gViewY1); } #ifdef USE_OPENGL else { if (videoGetRenderMode() == REND_POLYMOST && gDeliriumBlur) { - // todo: Implement using modern techniques instead of relying on deprecated old stuff that isn't well supported anymore. - /* names broken up so that searching for GL keywords won't find them anymore + // todo: Implement using modern techniques instead of relying on deprecated old stuff that isn't well supported anymore. + /* names broken up so that searching for GL keywords won't find them anymore if (!bDeliriumOld) { g lAccum(GL_LOAD, 1.f); @@ -3400,7 +3401,7 @@ RORHACK: g lAccum(GL _ACCUM, 1.f-fBlur); g lAccum(GL _RETURN, 1.f); } - */ + */ } } #endif @@ -3411,52 +3412,53 @@ RORHACK: if (r_usenewaspect) newaspect_enable = 0; renderSetAspect(viewingRange, yxAspect); - int nClipDist = gView->pSprite->clipdist<<2; + int nClipDist = gView->pSprite->clipdist << 2; int ve8, vec, vf0, vf4; GetZRange(gView->pSprite, &vf4, &vf0, &vec, &ve8, nClipDist, 0); #if 0 int tmpSect = nSectnum; if ((vf0 & 0xc000) == 0x4000) { - tmpSect = vf0 & (kMaxWalls-1); + tmpSect = vf0 & (kMaxWalls - 1); } - int v8 = byte_1CE5C2 > 0 && (sector[tmpSect].ceilingstat&1); + int v8 = byte_1CE5C2 > 0 && (sector[tmpSect].ceilingstat & 1); if (gWeather.at12d8 > 0 || v8) { gWeather.Draw(cX, cY, cZ, cA, q16horiz + defaultHoriz + deliriumPitch, gWeather.at12d8); if (v8) { - gWeather.at12d8 = ClipRange(delta*8+gWeather.at12d8, 0, 4095); + gWeather.at12d8 = ClipRange(delta * 8 + gWeather.at12d8, 0, 4095); } else { - gWeather.at12d8 = ClipRange(gWeather.at12d8-delta*64, 0, 4095); + gWeather.at12d8 = ClipRange(gWeather.at12d8 - delta * 64, 0, 4095); } } #endif + //PspTwoDSetter set; if (gViewPos == 0) { if (cl_crosshair) { - rotatesprite(160<<16, defaultHoriz<<16, 65536, 0, kCrosshairTile, 0, CROSSHAIR_PAL, 2, gViewX0, gViewY0, gViewX1, gViewY1); + rotatesprite(160 << 16, defaultHoriz << 16, 65536, 0, kCrosshairTile, 0, CROSSHAIR_PAL, 2, gViewX0, gViewY0, gViewX1, gViewY1); } - cX = (v4c>>8)+160; - cY = (v48>>8)+220+(zDelta>>7); + cX = (v4c >> 8) + 160; + cY = (v48 >> 8) + 220 + (zDelta >> 7); int nShade = sector[nSectnum].floorshade; int nPalette = 0; if (sector[gView->pSprite->sectnum].extra > 0) { - sectortype *pSector = §or[gView->pSprite->sectnum]; - XSECTOR *pXSector = &xsector[pSector->extra]; + sectortype* pSector = §or[gView->pSprite->sectnum]; + XSECTOR* pXSector = &xsector[pSector->extra]; if (pXSector->color) nPalette = pSector->floorpal; } - + if (gView->sceneQav < 0) WeaponDraw(gView, nShade, cX, cY, nPalette); else if (gView->pXSprite->health > 0) qavSceneDraw(gView, nShade, cX, cY, nPalette); else { gView->sceneQav = gView->weaponQav = -1; gView->weaponTimer = gView->curWeapon = 0; } - + } if (gViewPos == 0 && gView->pXSprite->burnTime > 60) @@ -3465,20 +3467,20 @@ RORHACK: } if (packItemActive(gView, 1)) { - rotatesprite(0, 0, 65536, 0, 2344, 0, 0, 256+18, gViewX0, gViewY0, gViewX1, gViewY1); - rotatesprite(320<<16, 0, 65536, 1024, 2344, 0, 0, 512+22, gViewX0, gViewY0, gViewX1, gViewY1); - rotatesprite(0, 200<<16, 65536, 0, 2344, 0, 0, 256+22, gViewX0, gViewY0, gViewX1, gViewY1); - rotatesprite(320<<16, 200<<16, 65536, 1024, 2344, 0, 0, 512+18, gViewX0, gViewY0, gViewX1, gViewY1); + rotatesprite(0, 0, 65536, 0, 2344, 0, 0, 256 + 18, gViewX0, gViewY0, gViewX1, gViewY1); + rotatesprite(320 << 16, 0, 65536, 1024, 2344, 0, 0, 512 + 22, gViewX0, gViewY0, gViewX1, gViewY1); + rotatesprite(0, 200 << 16, 65536, 0, 2344, 0, 0, 256 + 22, gViewX0, gViewY0, gViewX1, gViewY1); + rotatesprite(320 << 16, 200 << 16, 65536, 1024, 2344, 0, 0, 512 + 18, gViewX0, gViewY0, gViewX1, gViewY1); if (gDetail >= 4) { - rotatesprite(15<<16, 3<<16, 65536, 0, 2346, 32, 0, 256+19, gViewX0, gViewY0, gViewX1, gViewY1); - rotatesprite(212<<16, 77<<16, 65536, 0, 2347, 32, 0, 512+19, gViewX0, gViewY0, gViewX1, gViewY1); + rotatesprite(15 << 16, 3 << 16, 65536, 0, 2346, 32, 0, 256 + 19, gViewX0, gViewY0, gViewX1, gViewY1); + rotatesprite(212 << 16, 77 << 16, 65536, 0, 2347, 32, 0, 512 + 19, gViewX0, gViewY0, gViewX1, gViewY1); } } if (powerupCheck(gView, kPwUpAsbestArmor) > 0) { - rotatesprite(0, 200<<16, 65536, 0, 2358, 0, 0, 256+22, gViewX0, gViewY0, gViewX1, gViewY1); - rotatesprite(320<<16, 200<<16, 65536, 1024, 2358, 0, 0, 512+18, gViewX0, gViewY0, gViewX1, gViewY1); + rotatesprite(0, 200 << 16, 65536, 0, 2358, 0, 0, 256 + 22, gViewX0, gViewY0, gViewX1, gViewY1); + rotatesprite(320 << 16, 200 << 16, 65536, 1024, 2358, 0, 0, 512 + 18, gViewX0, gViewY0, gViewX1, gViewY1); } if (v4 && gNetPlayers > 1) { @@ -3486,22 +3488,22 @@ RORHACK: viewingRange = viewingrange; yxAspect = yxaspect; renderSetAspect(65536, 54613); - rotatesprite(280<<16, 35<<16, 53248, 512, 4077, v10, v14, 512+6, gViewX0, gViewY0, gViewX1, gViewY1); - rotatesprite(280<<16, 35<<16, 53248, 0, 1683, v10, 0, 512+35, gViewX0, gViewY0, gViewX1, gViewY1); + rotatesprite(280 << 16, 35 << 16, 53248, 512, 4077, v10, v14, 512 + 6, gViewX0, gViewY0, gViewX1, gViewY1); + rotatesprite(280 << 16, 35 << 16, 53248, 0, 1683, v10, 0, 512 + 35, gViewX0, gViewY0, gViewX1, gViewY1); renderSetAspect(viewingRange, yxAspect); } - + if (powerupCheck(gView, kPwUpDeathMask) > 0) nPalette = 4; - else if(powerupCheck(gView, kPwUpReflectShots) > 0) nPalette = 1; + else if (powerupCheck(gView, kPwUpReflectShots) > 0) nPalette = 1; else if (gView->isUnderwater) { if (gView->nWaterPal) nPalette = gView->nWaterPal; else { if (gView->pXSprite->medium == kMediumWater) nPalette = 1; else if (gView->pXSprite->medium == kMediumGoo) nPalette = 3; else nPalette = 2; + } } - } - } + } if (gViewMode == 4) { gViewMap.sub_25DB0(gView->pSprite); diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 5fba05ef4..7ecdafbcb 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -9446,8 +9446,6 @@ int32_t videoSetGameMode(char davidoption, int32_t daupscaledxdim, int32_t daups return 0; } -void DrawFullscreenBlends(); - // // nextpage // @@ -9472,8 +9470,6 @@ void videoNextPage(void) { g_beforeSwapTime = timerGetHiTicks(); - // Draw the console plus debug output on top of everything else. - DrawFullscreenBlends(); videoShowFrame(0); } @@ -10732,8 +10728,6 @@ void rotatesprite_(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, int8_t dashade, uint8_t dapalnum, int32_t dastat, uint8_t daalpha, uint8_t dablend, int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2) { - int32_t i; - if ((unsigned)picnum >= MAXTILES) return; @@ -10754,7 +10748,7 @@ void rotatesprite_(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, return; } // We must store all calls in the 2D drawer so that the backend can operate on a clean 3D view. - twod.rotatesprite(sx, sy, z, a, picnum, dashade, dapalnum, dastat, daalpha, dablend, cx1, cy1, cx2, cy2); + twod->rotatesprite(sx, sy, z, a, picnum, dashade, dapalnum, dastat, daalpha, dablend, cx1, cy1, cx2, cy2); // RS_PERM code was removed because the current backend supports only one page that needs to be redrawn each frame in which case the perm list was skipped anyway. } diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 699e1c108..376c051b1 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -3268,7 +3268,7 @@ void polymost_drawrooms() // This is a global setting for the entire scene, so let's do it here, right at the start. auto& hh = hictinting[MAXPALOOKUPS - 1]; // This sets a tinting color for global palettes, e.g. water or slime - only used for hires replacements (also an option for low-resource hardware where duplicating the textures may be problematic.) - GLInterface.SetBasepalTint(PalEntry(hh.sr, hh.sg, hh.sb)); + GLInterface.SetBasepalTint(PalEntry(hh.r, hh.g, hh.b)); polymost_outputGLDebugMessage(3, "polymost_drawrooms()"); diff --git a/source/common/2d/v_2ddrawer.cpp b/source/common/2d/v_2ddrawer.cpp index aeac22c7a..a8233c2b4 100644 --- a/source/common/2d/v_2ddrawer.cpp +++ b/source/common/2d/v_2ddrawer.cpp @@ -39,7 +39,9 @@ //#include "g_levellocals.h" //#include "vm.h" -F2DDrawer twod; +F2DDrawer twodpsp; +F2DDrawer twodgen; +F2DDrawer *twod = &twodgen; //========================================================================== // diff --git a/source/common/2d/v_2ddrawer.h b/source/common/2d/v_2ddrawer.h index 0641d42b1..95f40a338 100644 --- a/source/common/2d/v_2ddrawer.h +++ b/source/common/2d/v_2ddrawer.h @@ -132,6 +132,33 @@ public: bool mIsFirstPass = true; }; -extern F2DDrawer twod; +extern F2DDrawer twodgen; +extern F2DDrawer twodpsp; +extern F2DDrawer* twod; + +// This is for safely substituting the 2D drawer for a block of code. +class PspTwoDSetter +{ + F2DDrawer* old; +public: + PspTwoDSetter() + { + old = twod; + twod = &twodpsp; + } + ~PspTwoDSetter() + { + twod = old; + } + // Shadow Warrior fucked this up and draws the weapons in the same pass as the hud, meaning we have to switch this on and off depending on context. + void set() + { + twod = &twodpsp; + } + void clear() + { + twod = old; + } +}; #endif diff --git a/source/common/console/c_console.cpp b/source/common/console/c_console.cpp index 237b64ec0..d73a12e89 100644 --- a/source/common/console/c_console.cpp +++ b/source/common/console/c_console.cpp @@ -206,25 +206,25 @@ public: { if (scale == 1) { - DrawChar(&twod, CurrentConsoleFont, CR_ORANGE, x, y, '\x1c', TAG_DONE); - DrawText(&twod, CurrentConsoleFont, CR_ORANGE, x + CurrentConsoleFont->CharWidth(0x1c), y, + DrawChar(twod, CurrentConsoleFont, CR_ORANGE, x, y, '\x1c', TAG_DONE); + DrawText(twod, CurrentConsoleFont, CR_ORANGE, x + CurrentConsoleFont->CharWidth(0x1c), y, &Text[StartPos], TAG_DONE); if (cursor) { - DrawChar(&twod, CurrentConsoleFont, CR_YELLOW, + DrawChar(twod, CurrentConsoleFont, CR_YELLOW, x + CurrentConsoleFont->CharWidth(0x1c) + (CursorPosCells - StartPosCells) * CurrentConsoleFont->CharWidth(0xb), y, '\xb', TAG_DONE); } } else { - DrawChar(&twod, CurrentConsoleFont, CR_ORANGE, x, y, '\x1c', + DrawChar(twod, CurrentConsoleFont, CR_ORANGE, x, y, '\x1c', DTA_VirtualWidth, screen->GetWidth() / scale, DTA_VirtualHeight, screen->GetHeight() / scale, DTA_KeepRatio, true, TAG_DONE); - DrawText(&twod, CurrentConsoleFont, CR_ORANGE, x + CurrentConsoleFont->CharWidth(0x1c), y, + DrawText(twod, CurrentConsoleFont, CR_ORANGE, x + CurrentConsoleFont->CharWidth(0x1c), y, &Text[StartPos], DTA_VirtualWidth, screen->GetWidth() / scale, DTA_VirtualHeight, screen->GetHeight() / scale, @@ -232,7 +232,7 @@ public: if (cursor) { - DrawChar(&twod, CurrentConsoleFont, CR_YELLOW, + DrawChar(twod, CurrentConsoleFont, CR_YELLOW, x + CurrentConsoleFont->CharWidth(0x1c) + (CursorPosCells - StartPosCells) * CurrentConsoleFont->CharWidth(0xb), y, '\xb', DTA_VirtualWidth, screen->GetWidth() / scale, @@ -1116,13 +1116,13 @@ void FNotifyBuffer::Draw() int scale = active_con_scaletext(generic_ui); if (!center) - DrawText (&twod, font, color, 0, line, notify.Text, + DrawText (twod, font, color, 0, line, notify.Text, DTA_VirtualWidth, screen->GetWidth() / scale, DTA_VirtualHeight, screen->GetHeight() / scale, DTA_KeepRatio, true, DTA_Alpha, alpha, TAG_DONE); else - DrawText (&twod, font, color, (screen->GetWidth() - + DrawText (twod, font, color, (screen->GetWidth() - font->StringWidth (notify.Text) * scale) / 2 / scale, line, notify.Text, DTA_VirtualWidth, screen->GetWidth() / scale, @@ -1182,7 +1182,7 @@ void C_DrawConsole () if (conback) { - DrawTexture (&twod, conback, 0, visheight - screen->GetHeight(), + DrawTexture (twod, conback, 0, visheight - screen->GetHeight(), DTA_DestWidth, screen->GetWidth(), DTA_DestHeight, screen->GetHeight(), DTA_ColorOverlay, conshade, @@ -1193,22 +1193,22 @@ void C_DrawConsole () else { PalEntry pe((uint8_t)(con_alpha * 255), 0, 0, 0); - twod.AddColorOnlyQuad(0, 0, screen->GetWidth(), visheight, pe); + twod->AddColorOnlyQuad(0, 0, screen->GetWidth(), visheight, pe); } if (conline && visheight < screen->GetHeight()) { - twod.AddColorOnlyQuad(0, visheight, screen->GetWidth(), visheight+1, 0xff000000); + twod->AddColorOnlyQuad(0, visheight, screen->GetWidth(), visheight+1, 0xff000000); } if (ConBottom >= 12) { if (textScale == 1) - DrawText (&twod, CurrentConsoleFont, CR_ORANGE, screen->GetWidth() - 8 - + DrawText (twod, CurrentConsoleFont, CR_ORANGE, screen->GetWidth() - 8 - CurrentConsoleFont->StringWidth (GetVersionString()), ConBottom / textScale - CurrentConsoleFont->GetHeight() - 4, GetVersionString(), TAG_DONE); else - DrawText(&twod, CurrentConsoleFont, CR_ORANGE, screen->GetWidth() / textScale - 8 - + DrawText(twod, CurrentConsoleFont, CR_ORANGE, screen->GetWidth() / textScale - 8 - CurrentConsoleFont->StringWidth(GetVersionString()), ConBottom / textScale - CurrentConsoleFont->GetHeight() - 4, GetVersionString(), @@ -1241,11 +1241,11 @@ void C_DrawConsole () { if (textScale == 1) { - DrawText(&twod, CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text, TAG_DONE); + DrawText(twod, CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text, TAG_DONE); } else { - DrawText(&twod, CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text, + DrawText(twod, CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text, DTA_VirtualWidth, screen->GetWidth() / textScale, DTA_VirtualHeight, screen->GetHeight() / textScale, DTA_KeepRatio, true, TAG_DONE); @@ -1263,9 +1263,9 @@ void C_DrawConsole () // Indicate that the view has been scrolled up (10) // and if we can scroll no further (12) if (textScale == 1) - DrawChar (&twod, CurrentConsoleFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10, TAG_DONE); + DrawChar (twod, CurrentConsoleFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10, TAG_DONE); else - DrawChar(&twod, CurrentConsoleFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10, + DrawChar(twod, CurrentConsoleFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10, DTA_VirtualWidth, screen->GetWidth() / textScale, DTA_VirtualHeight, screen->GetHeight() / textScale, DTA_KeepRatio, true, TAG_DONE); diff --git a/source/common/menu/listmenu.cpp b/source/common/menu/listmenu.cpp index f9d2562b7..f66133fb1 100644 --- a/source/common/menu/listmenu.cpp +++ b/source/common/menu/listmenu.cpp @@ -321,7 +321,7 @@ void FListMenuItem::DrawSelector(int xofs, int yofs, FTexture *tex) { if ((DMenu::MenuTime%8) < 6) { - DrawText(&twod, ConFont, OptionSettings.mFontColorSelection, + DrawText(twod, ConFont, OptionSettings.mFontColorSelection, (mXpos + xofs - 160) * CleanXfac + screen->GetWidth() / 2, (mYpos + yofs - 100) * CleanYfac + screen->GetHeight() / 2, "\xd", @@ -332,7 +332,7 @@ void FListMenuItem::DrawSelector(int xofs, int yofs, FTexture *tex) } else { - DrawTexture (&twod, tex, mXpos + xofs, mYpos + yofs, DTA_Clean, true, TAG_DONE); + DrawTexture (twod, tex, mXpos + xofs, mYpos + yofs, DTA_Clean, true, TAG_DONE); } } @@ -417,13 +417,13 @@ void FListMenuItemStaticPatch::Drawer(DListMenu* menu, const DVector2& origin, b if (mYpos >= 0) { if (mCentered) x -= tex->GetWidth()/2; - DrawTexture (&twod, tex, x, mYpos, DTA_Clean, true, TAG_DONE); + DrawTexture (twod, tex, x, mYpos, DTA_Clean, true, TAG_DONE); } else { int x = (mXpos - 160) * CleanXfac + (screen->GetWidth()>>1); if (mCentered) x -= (tex->GetWidth()*CleanXfac)/2; - DrawTexture (&twod, tex, x, -mYpos*CleanYfac, DTA_CleanNoMove, true, TAG_DONE); + DrawTexture (twod, tex, x, -mYpos*CleanYfac, DTA_CleanNoMove, true, TAG_DONE); } } @@ -451,13 +451,13 @@ void FListMenuItemStaticText::Drawer(DListMenu* menu, const DVector2& origin, bo { int x = mXpos; if (mCentered) x -= mFont->StringWidth(text)/2; - DrawText(&twod, mFont, mColor, x, mYpos, text, DTA_Clean, true, TAG_DONE); + DrawText(twod, mFont, mColor, x, mYpos, text, DTA_Clean, true, TAG_DONE); } else { int x = (mXpos - 160) * CleanXfac + (screen->GetWidth()>>1); if (mCentered) x -= (mFont->StringWidth(text)*CleanXfac)/2; - DrawText (&twod, mFont, mColor, x, -mYpos*CleanYfac, text, DTA_CleanNoMove, true, TAG_DONE); + DrawText (twod, mFont, mColor, x, -mYpos*CleanYfac, text, DTA_CleanNoMove, true, TAG_DONE); } } } @@ -573,7 +573,7 @@ void FListMenuItemText::Drawer(DListMenu* menu, const DVector2& origin, bool sel const char *text = mText; if (mText.Len()) { - DrawText(&twod, mFont, selected ? mColorSelected : mColor, mXpos, mYpos, text, DTA_Clean, true, TAG_DONE); + DrawText(twod, mFont, selected ? mColorSelected : mColor, mXpos, mYpos, text, DTA_Clean, true, TAG_DONE); } } @@ -639,7 +639,7 @@ FListMenuItemPatch::FListMenuItemPatch(int x, int y, int height, int hotkey, FTe void FListMenuItemPatch::Drawer(DListMenu* menu, const DVector2& origin, bool selected) { - DrawTexture (&twod, mTexture, mXpos, mYpos, DTA_Clean, true, TAG_DONE); + DrawTexture (twod, mTexture, mXpos, mYpos, DTA_Clean, true, TAG_DONE); } int FListMenuItemPatch::GetWidth() diff --git a/source/common/menu/loadsavemenu.cpp b/source/common/menu/loadsavemenu.cpp index 590085281..73a6b6134 100644 --- a/source/common/menu/loadsavemenu.cpp +++ b/source/common/menu/loadsavemenu.cpp @@ -158,10 +158,10 @@ protected: PalEntry frameColor(255, 80, 80, 80); // todo: pick a proper color per game. PalEntry fillColor(160, 0, 0, 0); - DrawFrame(&twod, frameColor, savepicLeft, savepicTop, savepicWidth, savepicHeight, -1); + DrawFrame(twod, frameColor, savepicLeft, savepicTop, savepicWidth, savepicHeight, -1); if (!savegameManager.DrawSavePic(savepicLeft, savepicTop, savepicWidth, savepicHeight)) { - twod.AddColorOnlyQuad(savepicLeft, savepicTop, savepicWidth, savepicHeight, fillColor); + twod->AddColorOnlyQuad(savepicLeft, savepicTop, savepicWidth, savepicHeight, fillColor); if (savegameManager.SavegameCount() > 0) { @@ -169,33 +169,33 @@ protected: FString text = (Selected == -1 || !savegameManager.GetSavegame(Selected)->bOldVersion) ? GStrings("MNU_NOPICTURE") : GStrings("MNU_DIFFVERSION"); int textlen = NewSmallFont->StringWidth(text) * CleanXfac; - DrawText(&twod, NewSmallFont, CR_GOLD, savepicLeft + (savepicWidth - textlen) / 2, + DrawText(twod, NewSmallFont, CR_GOLD, savepicLeft + (savepicWidth - textlen) / 2, savepicTop + (savepicHeight - rowHeight) / 2, text, DTA_CleanNoMove, true, TAG_DONE); } } // Draw comment area - DrawFrame(&twod, frameColor, commentLeft, commentTop, commentWidth, commentHeight, -1); - twod.AddColorOnlyQuad(commentLeft, commentTop, commentWidth, commentHeight, fillColor); + DrawFrame(twod, frameColor, commentLeft, commentTop, commentWidth, commentHeight, -1); + twod->AddColorOnlyQuad(commentLeft, commentTop, commentWidth, commentHeight, fillColor); int numlinestoprint = std::min(commentRows, (int)BrokenSaveComment.Size()); for (int i = 0; i < numlinestoprint; i++) { - DrawText(&twod, NewConsoleFont, CR_ORANGE, commentLeft / FontScale, (commentTop + rowHeight * i) / FontScale, BrokenSaveComment[i].Text, + DrawText(twod, NewConsoleFont, CR_ORANGE, commentLeft / FontScale, (commentTop + rowHeight * i) / FontScale, BrokenSaveComment[i].Text, DTA_VirtualWidthF, screen->GetWidth() / FontScale, DTA_VirtualHeightF, screen->GetHeight() / FontScale, DTA_KeepRatio, true, TAG_DONE); } // Draw file area - DrawFrame(&twod, frameColor, listboxLeft, listboxTop, listboxWidth, listboxHeight, -1); - twod.AddColorOnlyQuad(listboxLeft, listboxTop, listboxWidth, listboxHeight, fillColor); + DrawFrame(twod, frameColor, listboxLeft, listboxTop, listboxWidth, listboxHeight, -1); + twod->AddColorOnlyQuad(listboxLeft, listboxTop, listboxWidth, listboxHeight, fillColor); if (savegameManager.SavegameCount() == 0) { FString text = GStrings("MNU_NOFILES"); int textlen = int(NewConsoleFont->StringWidth(text) * FontScale); - DrawText(&twod, NewConsoleFont, CR_GOLD, (listboxLeft + (listboxWidth - textlen) / 2) / FontScale, (listboxTop + (listboxHeight - rowHeight) / 2) / FontScale, text, + DrawText(twod, NewConsoleFont, CR_GOLD, (listboxLeft + (listboxWidth - textlen) / 2) / FontScale, (listboxTop + (listboxHeight - rowHeight) / 2) / FontScale, text, DTA_VirtualWidthF, screen->GetWidth() / FontScale, DTA_VirtualHeightF, screen->GetHeight() / FontScale, DTA_KeepRatio, true, TAG_DONE); return; } @@ -226,11 +226,11 @@ protected: if ((int)j == Selected) { - twod.AddColorOnlyQuad(listboxLeft, listboxTop + rowHeight * i, listboxWidth, rowHeight, mEntering ? PalEntry(255, 255, 0, 0) : PalEntry(255, 0, 0, 255)); + twod->AddColorOnlyQuad(listboxLeft, listboxTop + rowHeight * i, listboxWidth, rowHeight, mEntering ? PalEntry(255, 255, 0, 0) : PalEntry(255, 0, 0, 255)); didSeeSelected = true; if (!mEntering) { - DrawText(&twod, NewConsoleFont, colr, (listboxLeft + 1) / FontScale, (listboxTop + rowHeight * i + FontScale) / FontScale, node.SaveTitle, + DrawText(twod, NewConsoleFont, colr, (listboxLeft + 1) / FontScale, (listboxTop + rowHeight * i + FontScale) / FontScale, node.SaveTitle, DTA_VirtualWidthF, screen->GetWidth() / FontScale, DTA_VirtualHeightF, screen->GetHeight() / FontScale, DTA_KeepRatio, true, TAG_DONE); } else @@ -238,13 +238,13 @@ protected: FStringf s("%s%c", mInput->GetText(), NewConsoleFont->GetCursor()); int length = int(NewConsoleFont->StringWidth(s) * FontScale); int displacement = std::min(0, listboxWidth - 2 - length); - DrawText(&twod, NewConsoleFont, CR_WHITE, (listboxLeft + 1 + displacement) / FontScale, (listboxTop + rowHeight * i + FontScale) / FontScale, s, + DrawText(twod, NewConsoleFont, CR_WHITE, (listboxLeft + 1 + displacement) / FontScale, (listboxTop + rowHeight * i + FontScale) / FontScale, s, DTA_VirtualWidthF, screen->GetWidth() / FontScale, DTA_VirtualHeightF, screen->GetHeight() / FontScale, DTA_KeepRatio, true, TAG_DONE); } } else { - DrawText(&twod, NewConsoleFont, colr, (listboxLeft + 1) / FontScale, (listboxTop + rowHeight * i + FontScale) / FontScale, node.SaveTitle, + DrawText(twod, NewConsoleFont, colr, (listboxLeft + 1) / FontScale, (listboxTop + rowHeight * i + FontScale) / FontScale, node.SaveTitle, DTA_VirtualWidthF, screen->GetWidth() / FontScale, DTA_VirtualHeightF, screen->GetHeight() / FontScale, DTA_KeepRatio, true, TAG_DONE); } //screen->ClearClipRect(); diff --git a/source/common/menu/menu.cpp b/source/common/menu/menu.cpp index 1c5967ad2..347adc0a9 100644 --- a/source/common/menu/menu.cpp +++ b/source/common/menu/menu.cpp @@ -328,11 +328,11 @@ void DMenu::Drawer () int y = (!(m_show_backbutton&2))? 0:screen->GetHeight() - h; if (mBackbuttonSelected && (mMouseCapture || m_use_mouse == 1)) { - DrawTexture(&twod, tex, x, y, DTA_CleanNoMove, true, DTA_ColorOverlay, MAKEARGB(40, 255,255,255), TAG_DONE); + DrawTexture(twod, tex, x, y, DTA_CleanNoMove, true, DTA_ColorOverlay, MAKEARGB(40, 255,255,255), TAG_DONE); } else { - DrawTexture(&twod, tex, x, y, DTA_CleanNoMove, true, DTA_Alpha, BackbuttonAlpha, TAG_DONE); + DrawTexture(twod, tex, x, y, DTA_CleanNoMove, true, DTA_Alpha, BackbuttonAlpha, TAG_DONE); } } } @@ -879,7 +879,7 @@ void M_Drawer (void) if (DMenu::CurrentMenu != NULL && menuactive != MENU_Off) { - if (DMenu::CurrentMenu->DimAllowed() && fade && !DrawBackground) twod.AddColorOnlyQuad(0, 0, screen->GetWidth(), screen->GetHeight(), fade); + if (DMenu::CurrentMenu->DimAllowed() && fade && !DrawBackground) twod->AddColorOnlyQuad(0, 0, screen->GetWidth(), screen->GetHeight(), fade); bool going = false; if (transition.previous) diff --git a/source/common/menu/menuinput.cpp b/source/common/menu/menuinput.cpp index 95185c072..a0297eb85 100644 --- a/source/common/menu/menuinput.cpp +++ b/source/common/menu/menuinput.cpp @@ -307,7 +307,7 @@ void DTextEnterMenu::Drawer () // Darken the background behind the character grid. // Unless we frame it with a border, I think it looks better to extend the // background across the full width of the screen. - twod.AddColorOnlyQuad(0 /*screen->GetWidth()/2 - 13 * cell_width / 2*/, + twod->AddColorOnlyQuad(0 /*screen->GetWidth()/2 - 13 * cell_width / 2*/, screen->GetHeight() - INPUTGRID_HEIGHT * cell_height, screen->GetWidth() /*13 * cell_width*/, INPUTGRID_HEIGHT * cell_height, 0xc8000000); @@ -315,7 +315,7 @@ void DTextEnterMenu::Drawer () if (InputGridX >= 0 && InputGridY >= 0) { // Highlight the background behind the selected character. - twod.AddColorOnlyQuad( + twod->AddColorOnlyQuad( InputGridX * cell_width - INPUTGRID_WIDTH * cell_width / 2 + screen->GetWidth() / 2, InputGridY * cell_height - INPUTGRID_HEIGHT * cell_height + screen->GetHeight(), cell_width, cell_height, PalEntry(255, 255, 248, 220)); @@ -340,7 +340,7 @@ void DTextEnterMenu::Drawer () if (pic != NULL) { // Draw a normal character. - DrawTexture(&twod, pic, xx + cell_width/2 - width*CleanXfac_1/2, yy + top_padding, + DrawTexture(twod, pic, xx + cell_width/2 - width*CleanXfac_1/2, yy + top_padding, DTA_TranslationIndex, remap, DTA_CleanNoMove_1, true, TAG_DONE); @@ -353,16 +353,16 @@ void DTextEnterMenu::Drawer () const int y1 = yy + top_padding; const int y2 = y1 + displayFont->GetHeight() * CleanYfac_1; auto palcolor = PalEntry(255, 160, 160, 160); - twod.AddColorOnlyQuad(x1, y1, x2 - x1, CleanYfac_1, palcolor); // top - twod.AddColorOnlyQuad(x1, y2, x2 - x1, CleanYfac_1, palcolor); // bottom - twod.AddColorOnlyQuad(x1, y1+CleanYfac_1, CleanXfac_1, y2 - y1, palcolor); // left - twod.AddColorOnlyQuad(x2-CleanXfac_1, y1+CleanYfac_1, CleanXfac_1, CleanYfac_1, palcolor); // right + twod->AddColorOnlyQuad(x1, y1, x2 - x1, CleanYfac_1, palcolor); // top + twod->AddColorOnlyQuad(x1, y2, x2 - x1, CleanYfac_1, palcolor); // bottom + twod->AddColorOnlyQuad(x1, y1+CleanYfac_1, CleanXfac_1, y2 - y1, palcolor); // left + twod->AddColorOnlyQuad(x2-CleanXfac_1, y1+CleanYfac_1, CleanXfac_1, CleanYfac_1, palcolor); // right } else if (ch == '\b' || ch == 0) { // Draw the backspace and end "characters". const char *const str = ch == '\b' ? "BS" : "ED"; - DrawText(&twod, NewSmallFont, color, + DrawText(twod, NewSmallFont, color, xx + cell_width/2 - displayFont->StringWidth(str)*CleanXfac_1/2, yy + top_padding, str, DTA_CleanNoMove_1, true, TAG_DONE); } diff --git a/source/common/menu/messagebox.cpp b/source/common/menu/messagebox.cpp index c66a185b9..a39127471 100644 --- a/source/common/menu/messagebox.cpp +++ b/source/common/menu/messagebox.cpp @@ -193,7 +193,7 @@ void DMessageBoxMenu::Drawer() for (unsigned i = 0; i < mMessage.Size(); i++) { - DrawText(&twod, SmallFont, CR_UNTRANSLATED, 160 - mMessage[i].Width / 2, y, mMessage[i].Text, + DrawText(twod, SmallFont, CR_UNTRANSLATED, 160 - mMessage[i].Width / 2, y, mMessage[i].Text, DTA_Clean, true, TAG_DONE); y += fontheight; } @@ -203,10 +203,10 @@ void DMessageBoxMenu::Drawer() { y += fontheight; mMouseY = y; - DrawText(&twod, NewSmallFont, + DrawText(twod, NewSmallFont, messageSelection == 0 ? OptionSettings.mFontColorSelection : OptionSettings.mFontColor, 160, y, GStrings["TXT_YES"], DTA_Clean, true, TAG_DONE); - DrawText(&twod, NewSmallFont, + DrawText(twod, NewSmallFont, messageSelection == 1 ? OptionSettings.mFontColorSelection : OptionSettings.mFontColor, 160, y + fontheight + 1, GStrings["TXT_NO"], DTA_Clean, true, TAG_DONE); @@ -214,7 +214,7 @@ void DMessageBoxMenu::Drawer() { if (((DMenu::MenuTime >> 2) % 8) < 6) { - DrawText(&twod, NewSmallFont, OptionSettings.mFontColorSelection, + DrawText(twod, NewSmallFont, OptionSettings.mFontColorSelection, (150 - 160) * CleanXfac + screen->GetWidth() / 2, (y + (fontheight + 1) * messageSelection - 100 + fontheight / 2 - 5) * CleanYfac + screen->GetHeight() / 2, "\xd", @@ -227,7 +227,7 @@ void DMessageBoxMenu::Drawer() } else { - twod.AddColorOnlyQuad(0, 0, xdim, ydim, 0xa0000000); + twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xa0000000); gi->DrawCenteredTextScreen(origin, mFullMessage, 100, false); } } diff --git a/source/common/menu/optionmenu.cpp b/source/common/menu/optionmenu.cpp index c5e1d5f14..28a9e99d5 100644 --- a/source/common/menu/optionmenu.cpp +++ b/source/common/menu/optionmenu.cpp @@ -71,7 +71,7 @@ int OptionWidth(const char * s) void DrawOptionText(int x, int y, int color, const char *text, bool grayed) { PalEntry overlay = grayed? PalEntry(96,48,0,0) : PalEntry(0,0,0); - DrawText (&twod, OptionFont(), color, x, y, text, DTA_CleanNoMove_1, true, DTA_ColorOverlay, overlay, TAG_END); + DrawText (twod, OptionFont(), color, x, y, text, DTA_CleanNoMove_1, true, DTA_ColorOverlay, overlay, TAG_END); } //============================================================================= diff --git a/source/common/menu/optionmenuitems.h b/source/common/menu/optionmenuitems.h index 8df332b8f..6362de732 100644 --- a/source/common/menu/optionmenuitems.h +++ b/source/common/menu/optionmenuitems.h @@ -608,7 +608,7 @@ public: void DrawSliderElement (int color, int x, int y, const char * str) { - DrawText (&twod, ConFont, color, x, y, str, DTA_CellX, 16 * CleanXfac_1, DTA_CellY, 16 * CleanYfac_1, TAG_DONE); + DrawText (twod, ConFont, color, x, y, str, DTA_CellX, 16 * CleanXfac_1, DTA_CellY, 16 * CleanYfac_1, TAG_DONE); } void DrawSlider (int x, int y, double min, double max, double cur, int fracdigits, int indent) diff --git a/source/common/menu/savegamemanager.cpp b/source/common/menu/savegamemanager.cpp index ef575bb55..d57af7785 100644 --- a/source/common/menu/savegamemanager.cpp +++ b/source/common/menu/savegamemanager.cpp @@ -460,7 +460,7 @@ void FSavegameManager::ClearSaveStuff() bool FSavegameManager::DrawSavePic(int x, int y, int w, int h) { if (SavePic == nullptr) return false; - DrawTexture(&twod, SavePic, x, y, DTA_DestWidth, w, DTA_DestHeight, h, DTA_Masked, false, TAG_DONE); + DrawTexture(twod, SavePic, x, y, DTA_DestWidth, w, DTA_DestHeight, h, DTA_Masked, false, TAG_DONE); return true; } diff --git a/source/common/rendering/gl/system/gl_framebuffer.cpp b/source/common/rendering/gl/system/gl_framebuffer.cpp index cd7815670..848e49996 100644 --- a/source/common/rendering/gl/system/gl_framebuffer.cpp +++ b/source/common/rendering/gl/system/gl_framebuffer.cpp @@ -64,6 +64,8 @@ void gl_PrintStartupLog(); extern bool vid_hdr_active; +void DrawFullscreenBlends(); + namespace OpenGLRenderer { FGLRenderer *GLRenderer; @@ -405,7 +407,8 @@ void OpenGLFrameBuffer::Draw2D() if (GLRenderer != nullptr) { GLRenderer->mBuffers->BindCurrentFB(); - GLInterface.Draw2D(&twod); + ::DrawFullscreenBlends(); + GLInterface.Draw2D(&twodgen); } } @@ -416,3 +419,18 @@ void OpenGLFrameBuffer::PostProcessScene(int fixedcm, const std::functionmBuffers->BlitSceneToTexture(); // Copy the resulting scene to the current post process texture + screen->PostProcessScene(0, []() { + GLInterface.Draw2D(&twodpsp); // draws the weapon sprites + }); + screen->Update(); + // After finishing the frame, reset everything for the next frame. This needs to be done better. + screen->BeginFrame(); + OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(false); + twodpsp.Clear(); + twodgen.Clear(); +} + diff --git a/source/common/rendering/v_framebuffer.cpp b/source/common/rendering/v_framebuffer.cpp index 72adbc3d7..2b6218b15 100644 --- a/source/common/rendering/v_framebuffer.cpp +++ b/source/common/rendering/v_framebuffer.cpp @@ -137,8 +137,8 @@ void DFrameBuffer::DrawRateStuff () chars = snprintf (fpsbuff, countof(fpsbuff), "%2llu ms (%3llu fps)", (unsigned long long)howlong, (unsigned long long)LastCount); rate_x = Width / textScale - NewConsoleFont->StringWidth(&fpsbuff[0]); - twod.AddColorOnlyQuad(rate_x * textScale, 0, Width, NewConsoleFont->GetHeight() * textScale, 0); - DrawText (&twod, NewConsoleFont, CR_WHITE, rate_x, 0, (char *)&fpsbuff[0], + twod->AddColorOnlyQuad(rate_x * textScale, 0, Width, NewConsoleFont->GetHeight() * textScale, 0); + DrawText (twod, NewConsoleFont, CR_WHITE, rate_x, 0, (char *)&fpsbuff[0], DTA_VirtualWidth, screen->GetWidth() / textScale, DTA_VirtualHeight, screen->GetHeight() / textScale, DTA_KeepRatio, true, TAG_DONE); diff --git a/source/common/utility/stats.cpp b/source/common/utility/stats.cpp index 8ab7b407b..71f926269 100644 --- a/source/common/utility/stats.cpp +++ b/source/common/utility/stats.cpp @@ -116,7 +116,7 @@ void FStat::PrintStat () // Count number of linefeeds but ignore terminating ones. if (stattext[i] == '\n') y -= fontheight; } - DrawText(&twod, NewConsoleFont, CR_GREEN, 5 / textScale, y, stattext, + DrawText(twod, NewConsoleFont, CR_GREEN, 5 / textScale, y, stattext, DTA_VirtualWidth, screen->GetWidth() / textScale, DTA_VirtualHeight, screen->GetHeight() / textScale, DTA_KeepRatio, true, TAG_DONE); diff --git a/source/duke3d/src/screens.cpp b/source/duke3d/src/screens.cpp index 899235086..264412cd8 100644 --- a/source/duke3d/src/screens.cpp +++ b/source/duke3d/src/screens.cpp @@ -34,6 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "gamecvars.h" #include "menu/menu.h" #include "mapinfo.h" +#include "v_2ddrawer.h" BEGIN_DUKE_NS @@ -834,6 +835,7 @@ void G_DisplayRest(int32_t smoothratio) G_DrawCameraText(pp->newowner); else { + PspTwoDSetter set; P_DisplayWeapon(); #ifdef SPLITSCREEN_MOD_HACKS if (pp2) // HACK @@ -856,7 +858,7 @@ void G_DisplayRest(int32_t smoothratio) screenpeek = oscreenpeek; } #endif - } + } G_MoveClouds(); } diff --git a/source/exhumed/src/gun.cpp b/source/exhumed/src/gun.cpp index 78584be58..bac06a1d9 100644 --- a/source/exhumed/src/gun.cpp +++ b/source/exhumed/src/gun.cpp @@ -41,6 +41,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "object.h" #include #include +#include "v_2ddrawer.h" BEGIN_PS_NS @@ -936,6 +937,7 @@ void DrawWeapons(int smooth) if (nWeapon < -1) { return; } + PspTwoDSetter set; short var_34 = PlayerList[nLocalPlayer].field_3A; diff --git a/source/exhumed/src/view.cpp b/source/exhumed/src/view.cpp index cc064af5c..583b73079 100644 --- a/source/exhumed/src/view.cpp +++ b/source/exhumed/src/view.cpp @@ -380,7 +380,7 @@ void DrawView(int smoothRatio) bgpages--; } #else - FlushMessageLine(); + //FlushMessageLine(); RefreshBackground(); #endif diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 2f54a8072..6baf89807 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -170,18 +170,6 @@ void GLInstance::InitGLState(int fogmode, int multisample) OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(false); } -void videoShowFrame(int32_t w) -{ - OpenGLRenderer::GLRenderer->mBuffers->BlitSceneToTexture(); // Copy the resulting scene to the current post process texture - screen->PostProcessScene(0, nullptr); // at the moment this won't work because there's no guarantee that this is a clean buffer what we get here. - screen->Update(); - // After finishing the frame, reset everything for the next frame. This needs to be done better. - screen->BeginFrame(); - OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(false); -} - - - void GLInstance::Deinit() { #if 0 @@ -530,7 +518,7 @@ void GLInstance::DrawImGui(ImDrawData* data) void GLInstance::ClearScreen(PalEntry color) { - twod.Clear(); // Since we clear the entire screen, all previous draw operations become redundant, so delete them. + twod->Clear(); // Since we clear the entire screen, all previous draw operations become redundant, so delete them. #if 1 SetViewport(0, 0, xdim, ydim); @@ -540,7 +528,7 @@ void GLInstance::ClearScreen(PalEntry color) false); #else // This must be synchronized with the rest of the 2D operations. - twod.AddColorOnlyQuad(0, 0, xdim, ydim, ); + twod->AddColorOnlyQuad(0, 0, xdim, ydim, ); #endif } diff --git a/source/glbackend/hw_draw2d.cpp b/source/glbackend/hw_draw2d.cpp index cde0322ce..f51867de8 100644 --- a/source/glbackend/hw_draw2d.cpp +++ b/source/glbackend/hw_draw2d.cpp @@ -218,7 +218,6 @@ void GLInstance::Draw2D(F2DDrawer *drawer) SetColor(1, 1, 1); DisableScissor(); //drawer->mIsFirstPass = false; - twod.Clear(); EnableBlend(true); EnableMultisampling(true); } diff --git a/source/rr/src/screens.cpp b/source/rr/src/screens.cpp index f5523176a..b6b7a1a3e 100644 --- a/source/rr/src/screens.cpp +++ b/source/rr/src/screens.cpp @@ -34,6 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "gamecvars.h" #include "menu/menu.h" #include "mapinfo.h" +#include "v_2ddrawer.h" BEGIN_RR_NS @@ -854,6 +855,7 @@ void G_DisplayRest(int32_t smoothratio) G_DrawCameraText(pp->newowner); else { + PspTwoDSetter set; P_DisplayWeapon(); #ifdef SPLITSCREEN_MOD_HACKS if (pp2) // HACK @@ -876,7 +878,7 @@ void G_DisplayRest(int32_t smoothratio) screenpeek = oscreenpeek; } #endif - } + } if (!RR) G_MoveClouds(); } diff --git a/source/sw/src/panel.cpp b/source/sw/src/panel.cpp index cb1d31e6c..1c63a315d 100644 --- a/source/sw/src/panel.cpp +++ b/source/sw/src/panel.cpp @@ -41,6 +41,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "vis.h" #include "text.h" #include "player.h" +#include "v_2ddrawer.h" #include "weapon.h" #include "menu/menu.h" @@ -7334,7 +7335,9 @@ pDisplaySprites(PLAYERp pp) short ang; int flags; int x1,y1,x2,y2; + PspTwoDSetter set; + set.clear(); TRAVERSE(&pp->PanelSpriteList, psp, next) { ASSERT(ValidPtr(psp)); @@ -7470,6 +7473,7 @@ pDisplaySprites(PLAYERp pp) // if its a weapon sprite and the view is set to the outside don't draw the sprite if (TEST(psp->flags, PANF_WEAPON_SPRITE)) { + set.set(); SECT_USERp sectu = nullptr; int16_t floorshade = 0; if (pp->cursectnum >= 0) @@ -7512,6 +7516,7 @@ pDisplaySprites(PLAYERp pp) if (sectu && TEST(sectu->flags, SECTFU_DONT_COPY_PALETTE)) pal = 0; } + else set.clear(); //PANF_STATUS_AREA | PANF_SCREEN_CLIP | PANF_KILL_AFTER_SHOW,