mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- moved Set3DViewport to hwrenderer.
This commit is contained in:
parent
362ecacd52
commit
361bb688c8
6 changed files with 30 additions and 34 deletions
|
@ -94,7 +94,6 @@ public:
|
|||
sector_t *RenderView(player_t *player);
|
||||
void BeginFrame();
|
||||
|
||||
void Set3DViewport();
|
||||
sector_t *RenderViewpoint (FRenderViewpoint &mainvp, AActor * camera, IntRect * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen);
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -214,10 +186,11 @@ sector_t * FGLRenderer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * came
|
|||
gl_RenderState.Apply();
|
||||
}
|
||||
|
||||
Set3DViewport();
|
||||
|
||||
FDrawInfo *di = static_cast<FDrawInfo*>(HWDrawInfo::StartDrawInfo(mainvp, nullptr));
|
||||
auto &vp = di->Viewpoint;
|
||||
|
||||
di->Set3DViewport(gl_RenderState);
|
||||
di->SetViewArea();
|
||||
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)
|
||||
|
|
|
@ -645,3 +645,26 @@ void HWDrawInfo::DrawEndScene2D(sector_t * viewsector, FRenderState &state)
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -308,6 +308,7 @@ public:
|
|||
void RenderPortal(HWPortal *p, FRenderState &state, bool usestencil);
|
||||
void EndDrawScene(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 DoOneSectorLower(subsector_t * subsec, float planez, area_t in_area);
|
||||
|
|
|
@ -268,7 +268,7 @@ void HWPortal::RemoveStencil(HWDrawInfo *di, FRenderState &state, bool usestenci
|
|||
auto &vp = di->Viewpoint;
|
||||
if (vp.camera != nullptr) vp.camera->renderflags = (vp.camera->renderflags & ~RF_MAYBEINVISIBLE) | savedvisibility;
|
||||
|
||||
state.EnableDepthTest(true);
|
||||
state.EnableDepthTest(true);
|
||||
if (usestencil)
|
||||
{
|
||||
state.SetEffect(EFF_NONE);
|
||||
|
|
|
@ -14,9 +14,9 @@ class IIndexBuffer;
|
|||
|
||||
enum EClearTarget
|
||||
{
|
||||
CT_Depth,
|
||||
CT_Stencil,
|
||||
CT_Color
|
||||
CT_Depth = 1,
|
||||
CT_Stencil = 2,
|
||||
CT_Color = 4
|
||||
};
|
||||
|
||||
enum ERenderEffect
|
||||
|
|
Loading…
Reference in a new issue