More code from GLSceneDrawer to FDrawInfo

This commit is contained in:
Christoph Oelckers 2018-06-20 11:38:45 +02:00
parent b244fa2c8b
commit 3a80160ca0
3 changed files with 23 additions and 36 deletions

View File

@ -108,6 +108,10 @@ struct FDrawInfo : public HWDrawInfo
void CreateScene(); void CreateScene();
void RenderScene(int recursion); void RenderScene(int recursion);
void RenderTranslucent(); void RenderTranslucent();
void DrawScene(int drawmode);
void ProcessScene(bool toscreen = false);
void EndDrawScene(sector_t * viewsector);
void DrawEndScene2D(sector_t * viewsector);
static FDrawInfo *StartDrawInfo(GLSceneDrawer *drawer, FRenderViewpoint &parentvp); static FDrawInfo *StartDrawInfo(GLSceneDrawer *drawer, FRenderViewpoint &parentvp);
FDrawInfo *EndDrawInfo(); FDrawInfo *EndDrawInfo();

View File

@ -72,17 +72,6 @@ EXTERN_CVAR (Bool, r_deathcamera)
EXTERN_CVAR (Float, r_visibility) EXTERN_CVAR (Float, r_visibility)
EXTERN_CVAR (Bool, r_drawvoxels) EXTERN_CVAR (Bool, r_drawvoxels)
//-----------------------------------------------------------------------------
//
// resets the 3D viewport
//
//-----------------------------------------------------------------------------
void GLSceneDrawer::Reset3DViewport()
{
glViewport(screen->mScreenViewport.left, screen->mScreenViewport.top, screen->mScreenViewport.width, screen->mScreenViewport.height);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// //
// sets 3D viewport and initial state // sets 3D viewport and initial state
@ -375,11 +364,11 @@ void FDrawInfo::RenderTranslucent()
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void GLSceneDrawer::DrawScene(FDrawInfo *di, int drawmode) void FDrawInfo::DrawScene(int drawmode)
{ {
static int recursion=0; static int recursion=0;
static int ssao_portals_available = 0; static int ssao_portals_available = 0;
const auto &vp = di->Viewpoint; const auto &vp = Viewpoint;
bool applySSAO = false; bool applySSAO = false;
if (drawmode == DM_MAINVIEW) if (drawmode == DM_MAINVIEW)
@ -400,15 +389,15 @@ void GLSceneDrawer::DrawScene(FDrawInfo *di, int drawmode)
if (vp.camera != nullptr) if (vp.camera != nullptr)
{ {
ActorRenderFlags savedflags = vp.camera->renderflags; ActorRenderFlags savedflags = vp.camera->renderflags;
di->CreateScene(); CreateScene();
vp.camera->renderflags = savedflags; vp.camera->renderflags = savedflags;
} }
else else
{ {
di->CreateScene(); CreateScene();
} }
di->RenderScene(recursion); RenderScene(recursion);
if (applySSAO && gl_RenderState.GetPassType() == GBUFFER_PASS) if (applySSAO && gl_RenderState.GetPassType() == GBUFFER_PASS)
{ {
@ -423,9 +412,9 @@ void GLSceneDrawer::DrawScene(FDrawInfo *di, int drawmode)
// Handle all portals after rendering the opaque objects but before // Handle all portals after rendering the opaque objects but before
// doing all translucent stuff // doing all translucent stuff
recursion++; recursion++;
GLPortal::EndFrame(di); GLPortal::EndFrame(this);
recursion--; recursion--;
di->RenderTranslucent(); RenderTranslucent();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -435,7 +424,7 @@ void GLSceneDrawer::DrawScene(FDrawInfo *di, int drawmode)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void GLSceneDrawer::EndDrawScene(FDrawInfo *di, sector_t * viewsector) void FDrawInfo::EndDrawScene(sector_t * viewsector)
{ {
gl_RenderState.EnableFog(false); gl_RenderState.EnableFog(false);
@ -445,12 +434,11 @@ void GLSceneDrawer::EndDrawScene(FDrawInfo *di, sector_t * viewsector)
{ {
// [BB] The HUD model should be drawn over everything else already drawn. // [BB] The HUD model should be drawn over everything else already drawn.
glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);
di->DrawPlayerSprites(true); DrawPlayerSprites(true);
} }
glDisable(GL_STENCIL_TEST); glDisable(GL_STENCIL_TEST);
glViewport(screen->mScreenViewport.left, screen->mScreenViewport.top, screen->mScreenViewport.width, screen->mScreenViewport.height);
Reset3DViewport();
// Restore standard rendering state // Restore standard rendering state
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -459,7 +447,7 @@ void GLSceneDrawer::EndDrawScene(FDrawInfo *di, sector_t * viewsector)
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);
} }
void GLSceneDrawer::DrawEndScene2D(FDrawInfo *di, sector_t * viewsector) void FDrawInfo::DrawEndScene2D(sector_t * viewsector)
{ {
const bool renderHUDModel = IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player); const bool renderHUDModel = IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player);
@ -471,7 +459,7 @@ void GLSceneDrawer::DrawEndScene2D(FDrawInfo *di, sector_t * viewsector)
glDisable(GL_MULTISAMPLE); glDisable(GL_MULTISAMPLE);
di->DrawPlayerSprites(false); DrawPlayerSprites(false);
gl_RenderState.SetSoftLightLevel(-1); gl_RenderState.SetSoftLightLevel(-1);
@ -488,15 +476,15 @@ void GLSceneDrawer::DrawEndScene2D(FDrawInfo *di, sector_t * viewsector)
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void GLSceneDrawer::ProcessScene(FDrawInfo *di, bool toscreen) void FDrawInfo::ProcessScene(bool toscreen)
{ {
iter_dlightf = iter_dlight = draw_dlight = draw_dlightf = 0; iter_dlightf = iter_dlight = draw_dlight = draw_dlightf = 0;
GLPortal::BeginScene(); GLPortal::BeginScene();
int mapsection = R_PointInSubsector(di->Viewpoint.Pos)->mapsection; int mapsection = R_PointInSubsector(Viewpoint.Pos)->mapsection;
di->CurrentMapSections.Set(mapsection); CurrentMapSections.Set(mapsection);
GLRenderer->mCurrentPortal = nullptr; GLRenderer->mCurrentPortal = nullptr;
DrawScene(di, toscreen ? DM_MAINVIEW : DM_OFFSCREEN); DrawScene(toscreen ? DM_MAINVIEW : DM_OFFSCREEN);
} }
@ -540,12 +528,12 @@ sector_t * GLSceneDrawer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * ca
SetViewMatrix(vp.HWAngles, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, false, false); SetViewMatrix(vp.HWAngles, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, false, false);
gl_RenderState.ApplyMatrices(); gl_RenderState.ApplyMatrices();
ProcessScene(di, toscreen); di->ProcessScene(toscreen);
if (mainview) if (mainview)
{ {
if (toscreen) EndDrawScene(di, mainvp.sector); // do not call this for camera textures. if (toscreen) di->EndDrawScene(mainvp.sector); // do not call this for camera textures.
GLRenderer->PostProcessScene(cm, [&]() { DrawEndScene2D(di, mainvp.sector); }); GLRenderer->PostProcessScene(cm, [&]() { di->DrawEndScene2D(mainvp.sector); });
// This should be done after postprocessing, not before. // This should be done after postprocessing, not before.
GLRenderer->mBuffers->BindCurrentFB(); GLRenderer->mBuffers->BindCurrentFB();

View File

@ -23,11 +23,6 @@ public:
void SetupView(FRenderViewpoint &vp, float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror); void SetupView(FRenderViewpoint &vp, float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror);
void SetProjection(VSMatrix matrix); void SetProjection(VSMatrix matrix);
void Set3DViewport(bool mainview); void Set3DViewport(bool mainview);
void Reset3DViewport();
void DrawScene(FDrawInfo *di, int drawmode);
void ProcessScene(FDrawInfo *di, bool toscreen = false);
void EndDrawScene(FDrawInfo *di, sector_t * viewsector);
void DrawEndScene2D(FDrawInfo *di, sector_t * viewsector);
sector_t *RenderViewpoint(FRenderViewpoint &mainvp, AActor * camera, IntRect * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen); sector_t *RenderViewpoint(FRenderViewpoint &mainvp, AActor * camera, IntRect * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen);
sector_t *RenderView(player_t *player); sector_t *RenderView(player_t *player);