mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 15:22:15 +00:00
- moved DrawScene to GLRenderer and call it through std::function.
This was the last remaining virtual override of HWDrawInfo. With it removed this type is now fully API independent.
This commit is contained in:
parent
325d2126ec
commit
893e08df70
9 changed files with 28 additions and 31 deletions
|
@ -19,7 +19,6 @@ class FCanvasTexture;
|
|||
class FFlatVertexBuffer;
|
||||
class FSkyVertexBuffer;
|
||||
class OpenGLFrameBuffer;
|
||||
struct FDrawInfo;
|
||||
class FShaderManager;
|
||||
class HWPortal;
|
||||
class FLightBuffer;
|
||||
|
@ -105,6 +104,7 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
void DrawScene(HWDrawInfo *di, int drawmode);
|
||||
bool QuadStereoCheckInitialRenderContextState();
|
||||
void PresentAnaglyph(bool r, bool g, bool b);
|
||||
void PresentSideBySide();
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/*
|
||||
#ifndef __GL_DRAWINFO_H
|
||||
#define __GL_DRAWINFO_H
|
||||
|
||||
|
@ -13,6 +14,6 @@
|
|||
|
||||
struct FDrawInfo : public HWDrawInfo
|
||||
{
|
||||
void DrawScene(int drawmode) override;
|
||||
};
|
||||
#endif
|
||||
*/
|
|
@ -83,11 +83,11 @@ EXTERN_CVAR (Bool, r_drawvoxels)
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FDrawInfo::DrawScene(int drawmode)
|
||||
void FGLRenderer::DrawScene(HWDrawInfo *di, int drawmode)
|
||||
{
|
||||
static int recursion=0;
|
||||
static int ssao_portals_available = 0;
|
||||
const auto &vp = Viewpoint;
|
||||
const auto &vp = di->Viewpoint;
|
||||
|
||||
bool applySSAO = false;
|
||||
if (drawmode == DM_MAINVIEW)
|
||||
|
@ -108,36 +108,36 @@ void FDrawInfo::DrawScene(int drawmode)
|
|||
if (vp.camera != nullptr)
|
||||
{
|
||||
ActorRenderFlags savedflags = vp.camera->renderflags;
|
||||
CreateScene();
|
||||
di->CreateScene();
|
||||
vp.camera->renderflags = savedflags;
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateScene();
|
||||
di->CreateScene();
|
||||
}
|
||||
|
||||
glDepthMask(true);
|
||||
if (!gl_no_skyclear) screen->mPortalState->RenderFirstSkyPortal(recursion, this, gl_RenderState);
|
||||
if (!gl_no_skyclear) screen->mPortalState->RenderFirstSkyPortal(recursion, di, gl_RenderState);
|
||||
|
||||
RenderScene(gl_RenderState);
|
||||
di->RenderScene(gl_RenderState);
|
||||
|
||||
if (applySSAO && gl_RenderState.GetPassType() == GBUFFER_PASS)
|
||||
{
|
||||
gl_RenderState.EnableDrawBuffers(1);
|
||||
GLRenderer->AmbientOccludeScene(VPUniforms.mProjectionMatrix.get()[5]);
|
||||
GLRenderer->AmbientOccludeScene(di->VPUniforms.mProjectionMatrix.get()[5]);
|
||||
glViewport(screen->mSceneViewport.left, screen->mSceneViewport.top, screen->mSceneViewport.width, screen->mSceneViewport.height);
|
||||
GLRenderer->mBuffers->BindSceneFB(true);
|
||||
gl_RenderState.EnableDrawBuffers(gl_RenderState.GetPassDrawBufferCount());
|
||||
gl_RenderState.Apply();
|
||||
screen->mViewpoints->Bind(gl_RenderState, vpIndex);
|
||||
screen->mViewpoints->Bind(gl_RenderState, di->vpIndex);
|
||||
}
|
||||
|
||||
// Handle all portals after rendering the opaque objects but before
|
||||
// doing all translucent stuff
|
||||
recursion++;
|
||||
screen->mPortalState->EndFrame(this, gl_RenderState);
|
||||
screen->mPortalState->EndFrame(di, gl_RenderState);
|
||||
recursion--;
|
||||
RenderTranslucent(gl_RenderState);
|
||||
di->RenderTranslucent(gl_RenderState);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -170,7 +170,7 @@ sector_t * FGLRenderer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * came
|
|||
}
|
||||
|
||||
|
||||
FDrawInfo *di = static_cast<FDrawInfo*>(HWDrawInfo::StartDrawInfo(nullptr, mainvp, nullptr));
|
||||
auto di = HWDrawInfo::StartDrawInfo(nullptr, mainvp, nullptr);
|
||||
auto &vp = di->Viewpoint;
|
||||
|
||||
di->Set3DViewport(gl_RenderState);
|
||||
|
@ -184,7 +184,10 @@ sector_t * FGLRenderer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * came
|
|||
vp.Pos += eye.GetViewShift(vp.HWAngles.Yaw.Degrees);
|
||||
di->SetupView(gl_RenderState, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, false, false);
|
||||
|
||||
di->ProcessScene(toscreen);
|
||||
// std::function until this can be done better in a cross-API fashion.
|
||||
di->ProcessScene(toscreen, [&](HWDrawInfo *di, int mode) {
|
||||
DrawScene(di, mode);
|
||||
});
|
||||
|
||||
if (mainview)
|
||||
{
|
||||
|
|
|
@ -379,11 +379,6 @@ IDataBuffer *OpenGLFrameBuffer::CreateDataBuffer(int bindingpoint, bool ssbo)
|
|||
return new GLDataBuffer(bindingpoint, ssbo);
|
||||
}
|
||||
|
||||
HWDrawInfo *OpenGLFrameBuffer::CreateDrawInfo()
|
||||
{
|
||||
return new FDrawInfo;
|
||||
}
|
||||
|
||||
void OpenGLFrameBuffer::TextureFilterChanged()
|
||||
{
|
||||
if (GLRenderer != NULL && GLRenderer->mSamplerManager != NULL) GLRenderer->mSamplerManager->SetTextureFilterMode();
|
||||
|
|
|
@ -43,7 +43,6 @@ public:
|
|||
IVertexBuffer *CreateVertexBuffer() override;
|
||||
IIndexBuffer *CreateIndexBuffer() override;
|
||||
IDataBuffer *CreateDataBuffer(int bindingpoint, bool ssbo) override;
|
||||
HWDrawInfo *CreateDrawInfo() override;
|
||||
|
||||
// Retrieves a buffer containing image data for a screenshot.
|
||||
// Hint: Pitch can be negative for upside-down images, in which case buffer
|
||||
|
|
|
@ -97,11 +97,12 @@ HWDrawInfo *FDrawInfoList::GetNew()
|
|||
mList.Pop(di);
|
||||
return di;
|
||||
}
|
||||
return screen->CreateDrawInfo();
|
||||
return new HWDrawInfo;
|
||||
}
|
||||
|
||||
void FDrawInfoList::Release(HWDrawInfo * di)
|
||||
{
|
||||
di->DrawScene = nullptr;
|
||||
di->ClearBuffers();
|
||||
mList.Push(di);
|
||||
}
|
||||
|
@ -115,6 +116,7 @@ void FDrawInfoList::Release(HWDrawInfo * di)
|
|||
HWDrawInfo *HWDrawInfo::StartDrawInfo(HWDrawInfo *parent, FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms)
|
||||
{
|
||||
HWDrawInfo *di = di_list.GetNew();
|
||||
if (parent) di->DrawScene = parent->DrawScene;
|
||||
di->StartScene(parentvp, uniforms);
|
||||
return di;
|
||||
}
|
||||
|
@ -674,14 +676,13 @@ void HWDrawInfo::Set3DViewport(FRenderState &state)
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HWDrawInfo::ProcessScene(bool toscreen)
|
||||
void HWDrawInfo::ProcessScene(bool toscreen, const std::function<void(HWDrawInfo *,int)> &drawScene)
|
||||
{
|
||||
screen->mPortalState->BeginScene();
|
||||
|
||||
int mapsection = R_PointInSubsector(Viewpoint.Pos)->mapsection;
|
||||
CurrentMapSections.Set(mapsection);
|
||||
DrawScene(toscreen ? DM_MAINVIEW : DM_OFFSCREEN);
|
||||
DrawScene = drawScene;
|
||||
DrawScene(this, toscreen ? DM_MAINVIEW : DM_OFFSCREEN);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include "vectors.h"
|
||||
#include "r_defs.h"
|
||||
#include "r_utility.h"
|
||||
|
@ -178,6 +179,7 @@ struct HWDrawInfo
|
|||
area_t in_area;
|
||||
fixed_t viewx, viewy; // since the nodes are still fixed point, keeping the view position also fixed point for node traversal is faster.
|
||||
|
||||
std::function<void(HWDrawInfo *, int)> DrawScene = nullptr;
|
||||
|
||||
private:
|
||||
// For ProcessLowerMiniseg
|
||||
|
@ -190,7 +192,6 @@ private:
|
|||
|
||||
sector_t fakesec; // this is a struct member because it gets used in recursively called functions so it cannot be put on the stack.
|
||||
|
||||
|
||||
void UnclipSubsector(subsector_t *sub);
|
||||
void AddLine(seg_t *seg, bool portalclip);
|
||||
void PolySubsector(subsector_t * sub);
|
||||
|
@ -271,7 +272,7 @@ public:
|
|||
void EndDrawScene(sector_t * viewsector, FRenderState &state);
|
||||
void DrawEndScene2D(sector_t * viewsector, FRenderState &state);
|
||||
void Set3DViewport(FRenderState &state);
|
||||
void ProcessScene(bool toscreen);
|
||||
void ProcessScene(bool toscreen, const std::function<void(HWDrawInfo *, int)> &drawScene);
|
||||
|
||||
bool DoOneSectorUpper(subsector_t * subsec, float planez, area_t in_area);
|
||||
bool DoOneSectorLower(subsector_t * subsec, float planez, area_t in_area);
|
||||
|
@ -329,7 +330,5 @@ public:
|
|||
|
||||
|
||||
GLDecal *AddDecal(bool onmirror);
|
||||
|
||||
virtual void DrawScene(int drawmode) = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -328,7 +328,7 @@ public:
|
|||
{
|
||||
if (mScene->Setup(di, state, di->mClipper))
|
||||
{
|
||||
di->DrawScene(DM_PORTAL);
|
||||
di->DrawScene(di, DM_PORTAL);
|
||||
mScene->Shutdown(di, state);
|
||||
}
|
||||
else state.ClearScreen();
|
||||
|
|
|
@ -469,7 +469,6 @@ public:
|
|||
virtual IVertexBuffer *CreateVertexBuffer() { return nullptr; }
|
||||
virtual IIndexBuffer *CreateIndexBuffer() { return nullptr; }
|
||||
virtual IDataBuffer *CreateDataBuffer(int bindingpoint, bool ssbo) { return nullptr; }
|
||||
virtual HWDrawInfo *CreateDrawInfo() { return nullptr; }
|
||||
bool BuffersArePersistent() { return !!(hwcaps & RFL_BUFFER_STORAGE); }
|
||||
|
||||
// Begin/End 2D drawing operations.
|
||||
|
|
Loading…
Reference in a new issue