mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 15:22:16 +00:00
Detach poly renderer from r_main
This commit is contained in:
parent
fdbf2ab5e9
commit
1bed6feadc
4 changed files with 102 additions and 30 deletions
|
@ -59,18 +59,9 @@
|
|||
#include "v_font.h"
|
||||
#include "r_data/colormaps.h"
|
||||
#include "p_maputl.h"
|
||||
#include "r_poly.h"
|
||||
#include "p_setup.h"
|
||||
#include "version.h"
|
||||
|
||||
CUSTOM_CVAR(Bool, r_polyrenderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||
{
|
||||
if (self == 1 && !hasglnodes)
|
||||
{
|
||||
Printf("No GL BSP detected. You must restart the map before rendering will be correct\n");
|
||||
}
|
||||
}
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
|
@ -915,14 +906,7 @@ void R_RenderActorView (AActor *actor, bool dontmaplines)
|
|||
// Link the polyobjects right before drawing the scene to reduce the amounts of calls to this function
|
||||
PO_LinkToSubsectors();
|
||||
InSubsector = NULL;
|
||||
if (!r_polyrenderer)
|
||||
{
|
||||
R_RenderBSPNode(nodes + numnodes - 1); // The head node is the last node output.
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderPolyScene::Instance()->Render();
|
||||
}
|
||||
R_RenderBSPNode(nodes + numnodes - 1); // The head node is the last node output.
|
||||
R_3D_ResetClip(); // reset clips (floor/ceiling)
|
||||
camera->renderflags = savedflags;
|
||||
WallCycles.Unclock();
|
||||
|
@ -932,11 +916,8 @@ void R_RenderActorView (AActor *actor, bool dontmaplines)
|
|||
if (viewactive)
|
||||
{
|
||||
PlaneCycles.Clock();
|
||||
if (!r_polyrenderer)
|
||||
{
|
||||
R_DrawPlanes();
|
||||
R_DrawPortals();
|
||||
}
|
||||
R_DrawPlanes();
|
||||
R_DrawPortals();
|
||||
PlaneCycles.Unclock();
|
||||
|
||||
// [RH] Walk through mirrors
|
||||
|
@ -953,8 +934,7 @@ void R_RenderActorView (AActor *actor, bool dontmaplines)
|
|||
NetUpdate ();
|
||||
|
||||
MaskedCycles.Clock();
|
||||
if (!r_polyrenderer)
|
||||
R_DrawMasked ();
|
||||
R_DrawMasked ();
|
||||
MaskedCycles.Unclock();
|
||||
|
||||
NetUpdate ();
|
||||
|
|
|
@ -25,11 +25,15 @@
|
|||
#include "doomdef.h"
|
||||
#include "sbar.h"
|
||||
#include "r_data/r_translate.h"
|
||||
#include "r_data/r_interpolate.h"
|
||||
#include "r_poly.h"
|
||||
#include "gl/data/gl_data.h"
|
||||
#include "d_net.h"
|
||||
#include "po_man.h"
|
||||
|
||||
EXTERN_CVAR(Int, screenblocks)
|
||||
void InitGLRMapinfoData();
|
||||
extern bool r_showviewer;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -39,8 +43,50 @@ RenderPolyScene *RenderPolyScene::Instance()
|
|||
return &scene;
|
||||
}
|
||||
|
||||
void RenderPolyScene::Render()
|
||||
void RenderPolyScene::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines)
|
||||
{
|
||||
const bool savedviewactive = viewactive;
|
||||
const bool savedoutputformat = r_swtruecolor;
|
||||
|
||||
viewwidth = width;
|
||||
RenderTarget = canvas;
|
||||
bRenderingToCanvas = true;
|
||||
R_SetWindow(12, width, height, height, true);
|
||||
viewwindowx = x;
|
||||
viewwindowy = y;
|
||||
viewactive = true;
|
||||
r_swtruecolor = canvas->IsBgra();
|
||||
|
||||
canvas->Lock(true);
|
||||
|
||||
RenderActorView(actor, dontmaplines);
|
||||
|
||||
canvas->Unlock();
|
||||
|
||||
RenderTarget = screen;
|
||||
bRenderingToCanvas = false;
|
||||
R_ExecuteSetViewSize();
|
||||
viewactive = savedviewactive;
|
||||
r_swtruecolor = savedoutputformat;
|
||||
}
|
||||
|
||||
void RenderPolyScene::RenderActorView(AActor *actor, bool dontmaplines)
|
||||
{
|
||||
NetUpdate();
|
||||
|
||||
r_dontmaplines = dontmaplines;
|
||||
|
||||
P_FindParticleSubsectors();
|
||||
PO_LinkToSubsectors();
|
||||
R_SetupFrame(actor);
|
||||
|
||||
ActorRenderFlags savedflags = camera->renderflags;
|
||||
// Never draw the player unless in chasecam mode
|
||||
if (!r_showviewer)
|
||||
camera->renderflags |= RF_INVISIBLE;
|
||||
|
||||
R_BeginDrawerCommands();
|
||||
|
||||
ClearBuffers();
|
||||
SetSceneViewport();
|
||||
SetupPerspectiveMatrix();
|
||||
|
@ -50,7 +96,14 @@ void RenderPolyScene::Render()
|
|||
MainPortal.RenderTranslucent(0);
|
||||
PlayerSprites.Render();
|
||||
|
||||
DrawerCommandQueue::WaitForWorkers();
|
||||
camera->renderflags = savedflags;
|
||||
interpolator.RestoreInterpolations ();
|
||||
|
||||
NetUpdate();
|
||||
|
||||
R_EndDrawerCommands();
|
||||
|
||||
NetUpdate();
|
||||
}
|
||||
|
||||
void RenderPolyScene::RenderRemainingPlayerSprites()
|
||||
|
|
|
@ -33,11 +33,15 @@
|
|||
#include "r_poly_playersprite.h"
|
||||
#include "r_poly_sky.h"
|
||||
|
||||
class AActor;
|
||||
class DCanvas;
|
||||
|
||||
// Renders a scene
|
||||
class RenderPolyScene
|
||||
{
|
||||
public:
|
||||
void Render();
|
||||
void RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines);
|
||||
void RenderActorView(AActor *actor, bool dontmaplines);
|
||||
void RenderRemainingPlayerSprites();
|
||||
|
||||
static RenderPolyScene *Instance();
|
||||
|
|
|
@ -45,11 +45,19 @@
|
|||
#include "r_draw_rgba.h"
|
||||
#include "r_drawers.h"
|
||||
#include "r_poly.h"
|
||||
#include "p_setup.h"
|
||||
|
||||
EXTERN_CVAR(Bool, r_shadercolormaps)
|
||||
EXTERN_CVAR(Bool, r_polyrenderer) // [SP] dpJudas's new renderer
|
||||
EXTERN_CVAR(Float, maxviewpitch) // [SP] CVAR from GZDoom
|
||||
|
||||
CUSTOM_CVAR(Bool, r_polyrenderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||
{
|
||||
if (self == 1 && !hasglnodes)
|
||||
{
|
||||
Printf("No GL BSP detected. You must restart the map before rendering will be correct\n");
|
||||
}
|
||||
}
|
||||
|
||||
void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio);
|
||||
void R_SetupColormap(player_t *);
|
||||
void R_SetupFreelook();
|
||||
|
@ -175,6 +183,27 @@ void FSoftwareRenderer::Precache(BYTE *texhitlist, TMap<PClassActor*, bool> &act
|
|||
|
||||
void FSoftwareRenderer::RenderView(player_t *player)
|
||||
{
|
||||
if (r_polyrenderer)
|
||||
{
|
||||
bool saved_swtruecolor = r_swtruecolor;
|
||||
r_swtruecolor = screen->IsBgra();
|
||||
|
||||
RenderPolyScene::Instance()->RenderActorView(player->mo, false);
|
||||
FCanvasTextureInfo::UpdateAll();
|
||||
|
||||
// Apply special colormap if the target cannot do it
|
||||
if (realfixedcolormap && r_swtruecolor && !(r_shadercolormaps && screen->Accel2D))
|
||||
{
|
||||
R_BeginDrawerCommands();
|
||||
DrawerCommandQueue::QueueCommand<ApplySpecialColormapRGBACommand>(realfixedcolormap, screen);
|
||||
R_EndDrawerCommands();
|
||||
}
|
||||
|
||||
r_swtruecolor = saved_swtruecolor;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (r_swtruecolor != screen->IsBgra())
|
||||
{
|
||||
r_swtruecolor = screen->IsBgra();
|
||||
|
@ -223,7 +252,10 @@ void FSoftwareRenderer::WriteSavePic (player_t *player, FileWriter *file, int wi
|
|||
// Take a snapshot of the player's view
|
||||
pic->ObjectFlags |= OF_Fixed;
|
||||
pic->Lock ();
|
||||
R_RenderViewToCanvas (player->mo, pic, 0, 0, width, height);
|
||||
if (r_polyrenderer)
|
||||
RenderPolyScene::Instance()->RenderViewToCanvas(player->mo, pic, 0, 0, width, height, true);
|
||||
else
|
||||
R_RenderViewToCanvas (player->mo, pic, 0, 0, width, height);
|
||||
screen->GetFlashedPalette (palette);
|
||||
M_CreatePNG (file, pic->GetBuffer(), palette, SS_PAL, width, height, pic->GetPitch());
|
||||
pic->Unlock ();
|
||||
|
@ -373,7 +405,10 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin
|
|||
|
||||
DAngle savedfov = FieldOfView;
|
||||
R_SetFOV ((double)fov);
|
||||
R_RenderViewToCanvas (viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate);
|
||||
if (r_polyrenderer)
|
||||
RenderPolyScene::Instance()->RenderViewToCanvas(viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate);
|
||||
else
|
||||
R_RenderViewToCanvas (viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate);
|
||||
R_SetFOV (savedfov);
|
||||
|
||||
if (Canvas->IsBgra())
|
||||
|
|
Loading…
Reference in a new issue