- moved Set3DViewport to hwrenderer.

This commit is contained in:
Christoph Oelckers 2018-10-29 10:21:52 +01:00
parent 362ecacd52
commit 361bb688c8
6 changed files with 30 additions and 34 deletions

View file

@ -94,7 +94,6 @@ public:
sector_t *RenderView(player_t *player); sector_t *RenderView(player_t *player);
void BeginFrame(); void BeginFrame();
void Set3DViewport();
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);

View file

@ -157,34 +157,6 @@ void FDrawInfo::ProcessScene(bool toscreen)
} }
//-----------------------------------------------------------------------------
//
// sets 3D viewport and initial state
//
//-----------------------------------------------------------------------------
void FGLRenderer::Set3DViewport()
{
// Always clear all buffers with scissor test disabled.
// This is faster on newer hardware because it allows the GPU to skip
// reading from slower memory where the full buffers are stored.
glDisable(GL_SCISSOR_TEST);
glClearColor(screen->mSceneClearColor[0], screen->mSceneClearColor[1], screen->mSceneClearColor[2], screen->mSceneClearColor[3]);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
const auto &bounds = screen->mSceneViewport;
glViewport(bounds.left, bounds.top, bounds.width, bounds.height);
glScissor(bounds.left, bounds.top, bounds.width, bounds.height);
glEnable(GL_SCISSOR_TEST);
glEnable(GL_MULTISAMPLE);
glEnable(GL_DEPTH_TEST);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS,0,~0); // default stencil
glStencilOp(GL_KEEP,GL_KEEP,GL_REPLACE);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// //
// Renders one viewpoint in a scene // Renders one viewpoint in a scene
@ -214,10 +186,11 @@ sector_t * FGLRenderer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * came
gl_RenderState.Apply(); gl_RenderState.Apply();
} }
Set3DViewport();
FDrawInfo *di = static_cast<FDrawInfo*>(HWDrawInfo::StartDrawInfo(mainvp, nullptr)); FDrawInfo *di = static_cast<FDrawInfo*>(HWDrawInfo::StartDrawInfo(mainvp, nullptr));
auto &vp = di->Viewpoint; auto &vp = di->Viewpoint;
di->Set3DViewport(gl_RenderState);
di->SetViewArea(); di->SetViewArea();
auto cm = di->SetFullbrightFlags(mainview ? vp.camera->player : nullptr); auto cm = di->SetFullbrightFlags(mainview ? vp.camera->player : nullptr);
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)

View file

@ -645,3 +645,26 @@ void HWDrawInfo::DrawEndScene2D(sector_t * viewsector, FRenderState &state)
state.SetScissor(0, 0, -1, -1); state.SetScissor(0, 0, -1, -1);
} }
//-----------------------------------------------------------------------------
//
// sets 3D viewport and initial state
//
//-----------------------------------------------------------------------------
void HWDrawInfo::Set3DViewport(FRenderState &state)
{
// Always clear all buffers with scissor test disabled.
// This is faster on newer hardware because it allows the GPU to skip
// reading from slower memory where the full buffers are stored.
state.SetScissor(0, 0, -1, -1);
state.Clear(CT_Color | CT_Depth | CT_Stencil);
const auto &bounds = screen->mSceneViewport;
state.SetViewport(bounds.left, bounds.top, bounds.width, bounds.height);
state.SetScissor(bounds.left, bounds.top, bounds.width, bounds.height);
state.EnableMultisampling(true);
state.EnableDepthTest(true);
state.EnableStencil(true);
state.SetStencil(0, SOP_Keep, SF_AllOn);
}

View file

@ -308,6 +308,7 @@ public:
void RenderPortal(HWPortal *p, FRenderState &state, bool usestencil); void RenderPortal(HWPortal *p, FRenderState &state, bool usestencil);
void EndDrawScene(sector_t * viewsector, FRenderState &state); void EndDrawScene(sector_t * viewsector, FRenderState &state);
void DrawEndScene2D(sector_t * viewsector, FRenderState &state); void DrawEndScene2D(sector_t * viewsector, FRenderState &state);
void Set3DViewport(FRenderState &state);
bool DoOneSectorUpper(subsector_t * subsec, float planez, area_t in_area); bool DoOneSectorUpper(subsector_t * subsec, float planez, area_t in_area);
bool DoOneSectorLower(subsector_t * subsec, float planez, area_t in_area); bool DoOneSectorLower(subsector_t * subsec, float planez, area_t in_area);

View file

@ -14,9 +14,9 @@ class IIndexBuffer;
enum EClearTarget enum EClearTarget
{ {
CT_Depth, CT_Depth = 1,
CT_Stencil, CT_Stencil = 2,
CT_Color CT_Color = 4
}; };
enum ERenderEffect enum ERenderEffect