- fixed: The new renderer still called the Polymost screen finish function.

This led to a second, redundant postprocessing step with incorrect matrix values.
It now calls screen->Update() directly without the unneeded stuff, but this required a bit of reordering in the game code to ensure that the renderer receives the weapon data to display.
This commit is contained in:
Christoph Oelckers 2022-01-08 12:09:04 +01:00
parent 5759bcc1a6
commit 70087ebc12
15 changed files with 73 additions and 56 deletions

View file

@ -394,6 +394,7 @@ static void GameTicker()
// Display // Display
// //
//========================================================================== //==========================================================================
EXTERN_CVAR(Bool, vid_renderer);
void Display() void Display()
{ {
@ -456,7 +457,8 @@ void Display()
} }
DrawRateStuff(); DrawRateStuff();
videoShowFrame(1); if (vid_renderer == 0) videoShowFrame(1);
else screen->Update();
} }
//========================================================================== //==========================================================================

View file

@ -57,6 +57,7 @@ EXTERN_CVAR(Bool, cl_capfps)
PalEntry GlobalMapFog; PalEntry GlobalMapFog;
float GlobalFogDensity = 350.f; float GlobalFogDensity = 350.f;
TArray<PortalDesc> allPortals; TArray<PortalDesc> allPortals;
void Draw2D(F2DDrawer* drawer, FRenderState& state);
#if 0 #if 0
@ -138,7 +139,7 @@ void RenderViewpoint(FRenderViewpoint& mainvp, IntRect* bounds, float fov, float
vp = mainvp; vp = mainvp;
di->Set3DViewport(RenderState); di->Set3DViewport(RenderState);
float flash = 1.f; float flash = 8.f / (r_scenebrightness + 8.f);
di->Viewpoint.FieldOfView = fov; // Set the real FOV for the current scene (it's not necessarily the same as the global setting in r_viewpoint) di->Viewpoint.FieldOfView = fov; // Set the real FOV for the current scene (it's not necessarily the same as the global setting in r_viewpoint)
// Stereo mode specific perspective projection // Stereo mode specific perspective projection
@ -160,7 +161,9 @@ void RenderViewpoint(FRenderViewpoint& mainvp, IntRect* bounds, float fov, float
RenderState.EnableDrawBuffers(1); RenderState.EnableDrawBuffers(1);
} }
screen->PostProcessScene(false, CM_DEFAULT, flash, [&]() { }); screen->PostProcessScene(false, CM_DEFAULT, flash, []() {
Draw2D(&twodpsp, *screen->RenderState()); // draws the weapon sprites
});
PostProcess.Unclock(); PostProcess.Unclock();
} }
di->EndDrawInfo(); di->EndDrawInfo();

View file

@ -108,8 +108,6 @@ void hudDraw(PLAYER* gView, sectortype* pSector, double bobx, double boby, doubl
{ {
double look_anghalf = gView->angle.look_anghalf(smoothratio); double look_anghalf = gView->angle.look_anghalf(smoothratio);
DrawCrosshair(kCrosshairTile, gView->actor->xspr.health >> 4, -look_anghalf, 0, 2);
if (gViewPos == 0) if (gViewPos == 0)
{ {
double looking_arc = gView->angle.looking_arc(smoothratio); double looking_arc = gView->angle.looking_arc(smoothratio);
@ -174,16 +172,6 @@ void hudDraw(PLAYER* gView, sectortype* pSector, double bobx, double boby, doubl
drawElement(0, 237, 2358, 1, 0, 1, -1); drawElement(0, 237, 2358, 1, 0, 1, -1);
drawElement(320, 237, 2358, 1, 1, 1, 1); drawElement(320, 237, 2358, 1, 1, 1, 1);
} }
#if 0 // This currently does not work. May have to be redone as a hardware effect.
if (v4 && gNetPlayers > 1)
{
DoLensEffect();
viewingRange = viewingrange;
r otatesprite(IntToFixed(280), IntToFixed(35), 53248, 512, 4077, v10, v14, 512 + 6, gViewX0, gViewY0, gViewX1, gViewY1);
r otatesprite(IntToFixed(280), IntToFixed(35), 53248, 0, 1683, v10, 0, 512 + 35, gViewX0, gViewY0, gViewX1, gViewY1);
}
#endif
} }
END_BLD_NS END_BLD_NS

View file

@ -768,6 +768,7 @@ void viewDrawScreen(bool sceneonly)
if (vid_renderer) if (vid_renderer)
{ {
if (!sceneonly) hudDraw(gView, pSector, shakeX, shakeY, zDelta, basepal, gInterpolate);
fixedhoriz deliriumPitchI = q16horiz(interpolatedvalue(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate)); fixedhoriz deliriumPitchI = q16horiz(interpolatedvalue(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate));
auto bakCstat = gView->actor->spr.cstat; auto bakCstat = gView->actor->spr.cstat;
gView->actor->spr.cstat |= (gViewPos == 0) ? CSTAT_SPRITE_INVISIBLE : CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP; gView->actor->spr.cstat |= (gViewPos == 0) ? CSTAT_SPRITE_INVISIBLE : CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP;
@ -778,6 +779,7 @@ void viewDrawScreen(bool sceneonly)
{ {
renderSetRollAngle((float)rotscrnang.asbuildf()); renderSetRollAngle((float)rotscrnang.asbuildf());
render3DViewPolymost(sectnum(pSector), cX, cY, cZ, cA, cH); render3DViewPolymost(sectnum(pSector), cX, cY, cZ, cA, cH);
if (!sceneonly) hudDraw(gView, pSector, shakeX, shakeY, zDelta, basepal, gInterpolate);
} }
bDeliriumOld = bDelirium && gDeliriumBlur; bDeliriumOld = bDelirium && gDeliriumBlur;
@ -786,6 +788,18 @@ void viewDrawScreen(bool sceneonly)
Collision c1, c2; Collision c1, c2;
GetZRange(gView->actor, &vf4, &c1, &vec, &c2, nClipDist, 0); GetZRange(gView->actor, &vf4, &c1, &vec, &c2, nClipDist, 0);
if (sceneonly) return; if (sceneonly) return;
double look_anghalf = gView->angle.look_anghalf(gInterpolate);
DrawCrosshair(kCrosshairTile, gView->actor->xspr.health >> 4, -look_anghalf, 0, 2);
#if 0 // This currently does not work. May have to be redone as a hardware effect.
if (v4 && gNetPlayers > 1)
{
DoLensEffect();
viewingRange = viewingrange;
r otatesprite(IntToFixed(280), IntToFixed(35), 53248, 512, 4077, v10, v14, 512 + 6, gViewX0, gViewY0, gViewX1, gViewY1);
r otatesprite(IntToFixed(280), IntToFixed(35), 53248, 0, 1683, v10, 0, 512 + 35, gViewX0, gViewY0, gViewX1, gViewY1);
}
#endif
#if 0 #if 0
int tmpSect = nSectnum; int tmpSect = nSectnum;
if ((vf0 & 0xc000) == 0x4000) if ((vf0 & 0xc000) == 0x4000)
@ -806,7 +820,6 @@ void viewDrawScreen(bool sceneonly)
} }
} }
#endif #endif
hudDraw(gView, pSector, shakeX, shakeY, zDelta, basepal, gInterpolate);
} }
UpdateDacs(0, true); // keep the view palette active only for the actual 3D view and its overlays. UpdateDacs(0, true); // keep the view palette active only for the actual 3D view and its overlays.
if (automapMode != am_off) if (automapMode != am_off)

View file

@ -218,9 +218,10 @@ void OffBoat(player_struct *pl);
void cameratext(DDukeActor* i); void cameratext(DDukeActor* i);
void dobonus(int bonusonly, const CompletionFunc& completion); void dobonus(int bonusonly, const CompletionFunc& completion);
void drawweapon(double smoothratio);
void drawoverlays(double smoothratio); void drawoverlays(double smoothratio);
void drawbackground(void); void drawbackground(void);
void displayrooms(int32_t playerNum, double smoothratio); void displayrooms(int32_t playerNum, double smoothratio, bool sceneonly);
void setgamepalette(int palid); void setgamepalette(int palid);
void resetmys(); void resetmys();
void resettimevars(); void resettimevars();

View file

@ -207,6 +207,26 @@ void V_AddBlend (float r, float g, float b, float a, float v_blend[4])
videoSetPalette(palid); videoSetPalette(palid);
} }
//---------------------------------------------------------------------------
//
// draws the weapon sprite and other 2D content that's part of the scene.
//
//---------------------------------------------------------------------------
void drawweapon(double smoothratio)
{
auto pp = &ps[screenpeek];
if (!isRR() && pp->newOwner != nullptr)
cameratext(pp->newOwner);
else
{
fi.displayweapon(screenpeek, smoothratio);
if (pp->over_shoulder_on == 0)
fi.displaymasks(screenpeek, pp->GetActor()->spr.pal == 1 || !pp->insector() ? 1 : pp->cursector->floorpal, smoothratio);
}
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// draws everything not part of the 3D scene and its weapon sprite. // draws everything not part of the 3D scene and its weapon sprite.
@ -242,20 +262,6 @@ void drawoverlays(double smoothratio)
if (ud.cameraactor == nullptr) if (ud.cameraactor == nullptr)
{ {
if (automapMode != am_full)
{
if (!isRR() && pp->newOwner != nullptr)
cameratext(pp->newOwner);
else
{
fi.displayweapon(screenpeek, smoothratio);
if (pp->over_shoulder_on == 0)
fi.displaymasks(screenpeek, pp->GetActor()->spr.pal == 1 || !pp->insector() ? 1 : pp->cursector->floorpal, smoothratio);
}
if (!isRR())
moveclouds(smoothratio);
}
if (automapMode != am_off) if (automapMode != am_off)
{ {
DoInterpolations(smoothratio / 65536.); DoInterpolations(smoothratio / 65536.);

View file

@ -127,9 +127,13 @@ void GameInterface::Render()
{ {
drawtime.Reset(); drawtime.Reset();
drawtime.Clock(); drawtime.Clock();
videoSetBrightness(thunder_brightness); videoSetBrightness(thunder_brightness);
double const smoothRatio = !playrunning() || !cl_interpolate || cl_capfps ? MaxSmoothRatio : I_GetTimeFrac() * MaxSmoothRatio; double const smoothRatio = !playrunning() || !cl_interpolate || cl_capfps ? MaxSmoothRatio : I_GetTimeFrac() * MaxSmoothRatio;
displayrooms(screenpeek, smoothRatio); if (!isRR())
moveclouds(smoothRatio);
displayrooms(screenpeek, smoothRatio, false);
drawoverlays(smoothRatio); drawoverlays(smoothRatio);
drawtime.Unclock(); drawtime.Unclock();
} }

View file

@ -64,7 +64,7 @@ BEGIN_DUKE_NS
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void renderView(DDukeActor* playersprite, sectortype* sect, int x, int y, int z, binangle a, fixedhoriz h, binangle rotscrnang, int smoothratio) void renderView(DDukeActor* playersprite, sectortype* sect, int x, int y, int z, binangle a, fixedhoriz h, binangle rotscrnang, double smoothratio, bool sceneonly)
{ {
if (!vid_renderer) if (!vid_renderer)
{ {
@ -75,10 +75,12 @@ void renderView(DDukeActor* playersprite, sectortype* sect, int x, int y, int z,
renderMirror(x, y, z, a, h, smoothratio); renderMirror(x, y, z, a, h, smoothratio);
renderDrawRoomsQ16(x, y, z, a.asq16(), h.asq16(), sect, false); renderDrawRoomsQ16(x, y, z, a.asq16(), h.asq16(), sect, false);
fi.animatesprites(pm_tsprite, pm_spritesortcnt, x, y, a.asbuild(), smoothratio); fi.animatesprites(pm_tsprite, pm_spritesortcnt, x, y, a.asbuild(), smoothratio);
if (!sceneonly) drawweapon(smoothratio);
renderDrawMasks(); renderDrawMasks();
} }
else else
{ {
if (!sceneonly) drawweapon(smoothratio);
render_drawrooms(playersprite, { x, y, z }, sectnum(sect), a, h, rotscrnang, smoothratio); render_drawrooms(playersprite, { x, y, z }, sectnum(sect), a, h, rotscrnang, smoothratio);
} }
} }
@ -250,7 +252,7 @@ static int getdrugmode(player_struct *p, int oyrepeat)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void displayrooms(int snum, double smoothratio) void displayrooms(int snum, double smoothratio, bool sceneonly)
{ {
int cposx, cposy, cposz, fz, cz; int cposx, cposy, cposz, fz, cz;
binangle cang, rotscrnang; binangle cang, rotscrnang;
@ -295,7 +297,7 @@ void displayrooms(int snum, double smoothratio)
auto bh = buildhoriz(act->spr.yvel); auto bh = buildhoriz(act->spr.yvel);
auto cstat = act->spr.cstat; auto cstat = act->spr.cstat;
act->spr.cstat = CSTAT_SPRITE_INVISIBLE; act->spr.cstat = CSTAT_SPRITE_INVISIBLE;
renderView(act, act->sector(), act->spr.pos.X, act->spr.pos.Y, act->spr.pos.Z - (4 << 8), cang, bh, buildang(0), (int)smoothratio); renderView(act, act->sector(), act->spr.pos.X, act->spr.pos.Y, act->spr.pos.Z - (4 << 8), cang, bh, buildang(0), smoothratio, sceneonly);
act->spr.cstat = cstat; act->spr.cstat = cstat;
} }
@ -419,7 +421,7 @@ void displayrooms(int snum, double smoothratio)
} }
else else
{ {
renderView(viewer, sect, cposx, cposy, cposz, cang, choriz, rotscrnang, (int)smoothratio); renderView(viewer, sect, cposx, cposy, cposz, cang, choriz, rotscrnang, smoothratio, sceneonly);
} }
viewer->spr.cstat = cstat; viewer->spr.cstat = cstat;
} }
@ -439,7 +441,7 @@ void displayrooms(int snum, double smoothratio)
bool GameInterface::GenerateSavePic() bool GameInterface::GenerateSavePic()
{ {
displayrooms(myconnectindex, MaxSmoothRatio); displayrooms(myconnectindex, MaxSmoothRatio, true);
return true; return true;
} }

View file

@ -225,6 +225,7 @@ struct GameInterface : public ::GameInterface
void Ticker() override; void Ticker() override;
void DrawBackground() override; void DrawBackground() override;
void Render() override; void Render() override;
//void DrawWeapons() override;
void GetInput(ControlInfo* const hidInput, double const scaleAdjust, InputPacket* packet = nullptr) override; void GetInput(ControlInfo* const hidInput, double const scaleAdjust, InputPacket* packet = nullptr) override;
void Startup() override; void Startup() override;
const char* GenericCheat(int player, int cheat) override; const char* GenericCheat(int player, int cheat) override;

View file

@ -363,9 +363,13 @@ void DrawView(double smoothRatio, bool sceneonly)
renderDrawRoomsQ16(nCamerax, nCameray, viewz, nCameraa.asq16(), nCamerapan.asq16(), sectnum(pSector), false); renderDrawRoomsQ16(nCamerax, nCameray, viewz, nCameraa.asq16(), nCamerapan.asq16(), sectnum(pSector), false);
analyzesprites(pm_tsprite, pm_spritesortcnt, nCamerax, nCameray, viewz, smoothRatio); analyzesprites(pm_tsprite, pm_spritesortcnt, nCamerax, nCameray, viewz, smoothRatio);
renderDrawMasks(); renderDrawMasks();
if (!nFreeze && !sceneonly)
DrawWeapons(smoothRatio);
} }
else else
{ {
if (!nFreeze && !sceneonly)
DrawWeapons(smoothRatio);
render_drawrooms(nullptr, { nCamerax, nCameray, viewz }, sectnum(pSector), nCameraa, nCamerapan, rotscrnang, smoothRatio); render_drawrooms(nullptr, { nCamerax, nCameray, viewz }, sectnum(pSector), nCameraa, nCamerapan, rotscrnang, smoothRatio);
} }
@ -432,7 +436,6 @@ void DrawView(double smoothRatio, bool sceneonly)
{ {
if (nSnakeCam < 0) if (nSnakeCam < 0)
{ {
DrawWeapons(smoothRatio);
DrawMap(smoothRatio); DrawMap(smoothRatio);
} }
else else

View file

@ -148,7 +148,7 @@ void polymost_drawscreen(PLAYER* pp, int tx, int ty, int tz, binangle tang, fixe
DrawOverlapRoom(tx, ty, tz, tang.asq16(), thoriz.asq16(), tsect); DrawOverlapRoom(tx, ty, tz, tang.asq16(), thoriz.asq16(), tsect);
OverlapDraw = false; OverlapDraw = false;
if (automapMode != am_full)// && !ScreenSavePic) if (automapMode != am_full)
{ {
// TEST this! Changed to camerapp // TEST this! Changed to camerapp
//JS_DrawMirrors(camerapp, tx, ty, tz, tang.asq16(), thoriz.asq16()); //JS_DrawMirrors(camerapp, tx, ty, tz, tang.asq16(), thoriz.asq16());

View file

@ -1283,8 +1283,6 @@ void PreDrawStackedWater(void)
} }
short ScreenSavePic = false;
void DoPlayerDiveMeter(PLAYER* pp); void DoPlayerDiveMeter(PLAYER* pp);
void polymost_drawscreen(PLAYER* pp, int tx, int ty, int tz, binangle tang, fixedhoriz thoriz, sectortype* tsect); void polymost_drawscreen(PLAYER* pp, int tx, int ty, int tz, binangle tang, fixedhoriz thoriz, sectortype* tsect);
@ -1372,7 +1370,7 @@ void RestorePortalState()
} }
} }
void drawscreen(PLAYER* pp, double smoothratio) void drawscreen(PLAYER* pp, double smoothratio, bool sceneonly)
{ {
extern bool CameraTestMode; extern bool CameraTestMode;
int tx, ty, tz; int tx, ty, tz;
@ -1395,7 +1393,7 @@ void drawscreen(PLAYER* pp, double smoothratio)
int sr = (int)smoothratio; int sr = (int)smoothratio;
pm_smoothratio = sr; pm_smoothratio = sr;
if (!ScreenSavePic) if (!sceneonly)
{ {
DoInterpolations(smoothratio / 65536.); // Stick at beginning of drawscreen DoInterpolations(smoothratio / 65536.); // Stick at beginning of drawscreen
if (cl_sointerpolation) if (cl_sointerpolation)
@ -1499,7 +1497,7 @@ void drawscreen(PLAYER* pp, double smoothratio)
thoriz = q16horiz(clamp(thoriz.asq16() + interpolatedvalue(pp->recoil_ohorizoff, pp->recoil_horizoff, smoothratio), gi->playerHorizMin(), gi->playerHorizMax())); thoriz = q16horiz(clamp(thoriz.asq16() + interpolatedvalue(pp->recoil_ohorizoff, pp->recoil_horizoff, smoothratio), gi->playerHorizMin(), gi->playerHorizMax()));
} }
if (automapMode != am_full)// && !ScreenSavePic) if (automapMode != am_full)
{ {
// Cameras must be done before the main loop. // Cameras must be done before the main loop.
if (!vid_renderer) JS_DrawCameras(pp, tx, ty, tz, smoothratio); if (!vid_renderer) JS_DrawCameras(pp, tx, ty, tz, smoothratio);
@ -1510,24 +1508,24 @@ void drawscreen(PLAYER* pp, double smoothratio)
{ {
renderSetRollAngle((float)trotscrnang.asbuildf()); renderSetRollAngle((float)trotscrnang.asbuildf());
polymost_drawscreen(pp, tx, ty, tz, tang, thoriz, tsect); polymost_drawscreen(pp, tx, ty, tz, tang, thoriz, tsect);
if (!sceneonly) UpdatePanel(smoothratio);
} }
else else
{ {
if (!sceneonly) UpdatePanel(smoothratio);
UpdateWallPortalState(); UpdateWallPortalState();
render_drawrooms(pp->actor, { tx, ty, tz }, sectnum(tsect), tang, thoriz, trotscrnang, smoothratio); render_drawrooms(pp->actor, { tx, ty, tz }, sectnum(tsect), tang, thoriz, trotscrnang, smoothratio);
RestorePortalState(); RestorePortalState();
} }
if (sceneonly)
if (!ScreenSavePic) UpdatePanel(smoothratio);
// if doing a screen save don't need to process the rest
if (ScreenSavePic)
{ {
DrawScreen = false; DrawScreen = false;
return; return;
} }
// if doing a screen save don't need to process the rest
MarkSectorSeen(pp->cursector); MarkSectorSeen(pp->cursector);
@ -1601,9 +1599,7 @@ void drawscreen(PLAYER* pp, double smoothratio)
bool GameInterface::GenerateSavePic() bool GameInterface::GenerateSavePic()
{ {
ScreenSavePic = true; drawscreen(Player + myconnectindex, 65536, true);
drawscreen(Player + myconnectindex, 65536);
ScreenSavePic = false;
return true; return true;
} }

View file

@ -713,7 +713,7 @@ void GameInterface::Render()
drawtime.Reset(); drawtime.Reset();
drawtime.Clock(); drawtime.Clock();
drawscreen(Player + screenpeek, smoothratio); drawscreen(Player + screenpeek, smoothratio, false);
drawtime.Unclock(); drawtime.Unclock();
} }

View file

@ -1806,7 +1806,6 @@ void DebugWriteString(char *string); // game.c
void getsyncstat(void); // sync.c void getsyncstat(void); // sync.c
void SyncStatMessage(void); // sync.c void SyncStatMessage(void); // sync.c
void drawscreen(PLAYER* pp, double smoothratio); // draw.c
int COVERsetgamemode(int mode, int xdim, int ydim, int bpp); // draw.c int COVERsetgamemode(int mode, int xdim, int ydim, int bpp); // draw.c
void ScreenCaptureKeys(void); // draw.c void ScreenCaptureKeys(void); // draw.c
@ -1908,6 +1907,7 @@ struct GameInterface : public ::GameInterface
void DrawBackground(void) override; void DrawBackground(void) override;
void Ticker(void) override; void Ticker(void) override;
void Render() override; void Render() override;
//void DrawWeapons() override;
void Startup() override; void Startup() override;
const char *CheckCheatMode() override; const char *CheckCheatMode() override;
const char* GenericCheat(int player, int cheat) override; const char* GenericCheat(int player, int cheat) override;

View file

@ -437,8 +437,6 @@ void videoShowFrame(int32_t w)
screen->mVertexData->Reset(); screen->mVertexData->Reset();
screen->mViewpoints->Clear(); screen->mViewpoints->Clear();
videoSetBrightness(0); // immediately reset this after rendering so that the value doesn't stick around in the backend.
// After finishing the frame, reset everything for the next frame. This needs to be done better. // After finishing the frame, reset everything for the next frame. This needs to be done better.
if (!w) if (!w)
{ {