mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-13 16:07:45 +00:00
- safety commit. To finalize we need a better vertex buffer interface.
This commit is contained in:
parent
3940f17980
commit
cead0194bd
9 changed files with 129 additions and 126 deletions
|
@ -64,7 +64,7 @@ void FGLModelRenderer::BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, con
|
||||||
if (!(actor->RenderStyle == LegacyRenderStyles[STYLE_Normal]) && !(smf->flags & MDL_DONTCULLBACKFACES))
|
if (!(actor->RenderStyle == LegacyRenderStyles[STYLE_Normal]) && !(smf->flags & MDL_DONTCULLBACKFACES))
|
||||||
{
|
{
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
glFrontFace((mirrored ^ GLRenderer->mPortalState.isMirrored()) ? GL_CCW : GL_CW);
|
glFrontFace((mirrored ^ screen->mPortalState->isMirrored()) ? GL_CCW : GL_CW);
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_RenderState.mModelMatrix = objectToWorldMatrix;
|
gl_RenderState.mModelMatrix = objectToWorldMatrix;
|
||||||
|
@ -90,7 +90,7 @@ void FGLModelRenderer::BeginDrawHUDModel(AActor *actor, const VSMatrix &objectTo
|
||||||
if (!(actor->RenderStyle == LegacyRenderStyles[STYLE_Normal]))
|
if (!(actor->RenderStyle == LegacyRenderStyles[STYLE_Normal]))
|
||||||
{
|
{
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
glFrontFace((mirrored ^ GLRenderer->mPortalState.isMirrored()) ? GL_CW : GL_CCW);
|
glFrontFace((mirrored ^ screen->mPortalState->isMirrored()) ? GL_CW : GL_CCW);
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_RenderState.mModelMatrix = objectToWorldMatrix;
|
gl_RenderState.mModelMatrix = objectToWorldMatrix;
|
||||||
|
|
|
@ -75,8 +75,6 @@ public:
|
||||||
GLViewpointBuffer *mViewpoints = nullptr;
|
GLViewpointBuffer *mViewpoints = nullptr;
|
||||||
SWSceneDrawer *swdrawer = nullptr;
|
SWSceneDrawer *swdrawer = nullptr;
|
||||||
|
|
||||||
FPortalSceneState mPortalState;
|
|
||||||
|
|
||||||
float mSceneClearColor[3];
|
float mSceneClearColor[3];
|
||||||
|
|
||||||
FGLRenderer(OpenGLFrameBuffer *fb);
|
FGLRenderer(OpenGLFrameBuffer *fb);
|
||||||
|
|
|
@ -242,7 +242,7 @@ void FDrawInfo::AddSubsectorToPortal(FSectorPortalGroup *ptg, subsector_t *sub)
|
||||||
auto portal = FindPortal(ptg);
|
auto portal = FindPortal(ptg);
|
||||||
if (!portal)
|
if (!portal)
|
||||||
{
|
{
|
||||||
portal = new HWScenePortal(&GLRenderer->mPortalState, new HWSectorStackPortal(ptg));
|
portal = new HWScenePortal(screen->mPortalState, new HWSectorStackPortal(ptg));
|
||||||
Portals.Push(portal);
|
Portals.Push(portal);
|
||||||
}
|
}
|
||||||
auto ptl = static_cast<HWSectorStackPortal*>(static_cast<HWScenePortal*>(portal)->mScene);
|
auto ptl = static_cast<HWSectorStackPortal*>(static_cast<HWScenePortal*>(portal)->mScene);
|
||||||
|
|
|
@ -95,7 +95,7 @@ void FDrawInfo::CreateScene()
|
||||||
mClipper->SafeAddClipRangeRealAngles(vp.Angles.Yaw.BAMs() + a1, vp.Angles.Yaw.BAMs() - a1);
|
mClipper->SafeAddClipRangeRealAngles(vp.Angles.Yaw.BAMs() + a1, vp.Angles.Yaw.BAMs() - a1);
|
||||||
|
|
||||||
// reset the portal manager
|
// reset the portal manager
|
||||||
GLRenderer->mPortalState.StartFrame();
|
screen->mPortalState->StartFrame();
|
||||||
PO_LinkToSubsectors();
|
PO_LinkToSubsectors();
|
||||||
|
|
||||||
ProcessAll.Clock();
|
ProcessAll.Clock();
|
||||||
|
@ -149,7 +149,7 @@ void FDrawInfo::RenderScene(int recursion)
|
||||||
RenderAll.Clock();
|
RenderAll.Clock();
|
||||||
|
|
||||||
glDepthMask(true);
|
glDepthMask(true);
|
||||||
if (!gl_no_skyclear) GLRenderer->mPortalState.RenderFirstSkyPortal(recursion, this);
|
if (!gl_no_skyclear) screen->mPortalState->RenderFirstSkyPortal(recursion, this);
|
||||||
|
|
||||||
gl_RenderState.EnableFog(true);
|
gl_RenderState.EnableFog(true);
|
||||||
gl_RenderState.SetRenderStyle(STYLE_Source);
|
gl_RenderState.SetRenderStyle(STYLE_Source);
|
||||||
|
@ -284,7 +284,7 @@ void FDrawInfo::DrawScene(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++;
|
||||||
GLRenderer->mPortalState.EndFrame(this);
|
screen->mPortalState->EndFrame(this);
|
||||||
recursion--;
|
recursion--;
|
||||||
RenderTranslucent();
|
RenderTranslucent();
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ void FDrawInfo::DrawEndScene2D(sector_t * viewsector)
|
||||||
void FDrawInfo::ProcessScene(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;
|
||||||
GLRenderer->mPortalState.BeginScene();
|
screen->mPortalState->BeginScene();
|
||||||
|
|
||||||
int mapsection = R_PointInSubsector(Viewpoint.Pos)->mapsection;
|
int mapsection = R_PointInSubsector(Viewpoint.Pos)->mapsection;
|
||||||
CurrentMapSections.Set(mapsection);
|
CurrentMapSections.Set(mapsection);
|
||||||
|
|
|
@ -91,114 +91,3 @@ void FDrawInfo::AddMirrorSurface(GLWall *w)
|
||||||
newwall->ProcessDecals(this);
|
newwall->ProcessDecals(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
void FDrawInfo::AddPortal(GLWall *wall, int ptype)
|
|
||||||
{
|
|
||||||
auto &pstate = GLRenderer->mPortalState;
|
|
||||||
HWPortal * portal;
|
|
||||||
|
|
||||||
wall->MakeVertices(this, false);
|
|
||||||
switch (ptype)
|
|
||||||
{
|
|
||||||
// portals don't go into the draw list.
|
|
||||||
// Instead they are added to the portal manager
|
|
||||||
case PORTALTYPE_HORIZON:
|
|
||||||
wall->horizon = pstate.UniqueHorizons.Get(wall->horizon);
|
|
||||||
portal = FindPortal(wall->horizon);
|
|
||||||
if (!portal)
|
|
||||||
{
|
|
||||||
portal = new HWHorizonPortal(&pstate, wall->horizon, Viewpoint, this);
|
|
||||||
Portals.Push(portal);
|
|
||||||
}
|
|
||||||
portal->AddLine(wall);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PORTALTYPE_SKYBOX:
|
|
||||||
portal = FindPortal(wall->secportal);
|
|
||||||
if (!portal)
|
|
||||||
{
|
|
||||||
// either a regular skybox or an Eternity-style horizon
|
|
||||||
if (wall->secportal->mType != PORTS_SKYVIEWPOINT) portal = new HWEEHorizonPortal(&pstate, wall->secportal, this);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
portal = new HWScenePortal(&pstate, new HWSkyboxPortal(wall->secportal));
|
|
||||||
Portals.Push(portal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
portal->AddLine(wall);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PORTALTYPE_SECTORSTACK:
|
|
||||||
portal = FindPortal(wall->portal);
|
|
||||||
if (!portal)
|
|
||||||
{
|
|
||||||
portal = new HWScenePortal(&pstate, new HWSectorStackPortal(wall->portal));
|
|
||||||
Portals.Push(portal);
|
|
||||||
}
|
|
||||||
portal->AddLine(wall);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PORTALTYPE_PLANEMIRROR:
|
|
||||||
if (pstate.PlaneMirrorMode * wall->planemirror->fC() <= 0)
|
|
||||||
{
|
|
||||||
//@sync-portal
|
|
||||||
wall->planemirror = pstate.UniquePlaneMirrors.Get(wall->planemirror);
|
|
||||||
portal = FindPortal(wall->planemirror);
|
|
||||||
if (!portal)
|
|
||||||
{
|
|
||||||
portal = new HWScenePortal(&pstate, new HWPlaneMirrorPortal(wall->planemirror));
|
|
||||||
Portals.Push(portal);
|
|
||||||
}
|
|
||||||
portal->AddLine(wall);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PORTALTYPE_MIRROR:
|
|
||||||
portal = FindPortal(wall->seg->linedef);
|
|
||||||
if (!portal)
|
|
||||||
{
|
|
||||||
portal = new HWScenePortal(&pstate, new HWMirrorPortal(wall->seg->linedef));
|
|
||||||
Portals.Push(portal);
|
|
||||||
}
|
|
||||||
portal->AddLine(wall);
|
|
||||||
if (gl_mirror_envmap)
|
|
||||||
{
|
|
||||||
// draw a reflective layer over the mirror
|
|
||||||
AddMirrorSurface(wall);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PORTALTYPE_LINETOLINE:
|
|
||||||
portal = FindPortal(wall->lineportal);
|
|
||||||
if (!portal)
|
|
||||||
{
|
|
||||||
line_t *otherside = wall->lineportal->lines[0]->mDestination;
|
|
||||||
if (otherside != nullptr && otherside->portalindex < level.linePortals.Size())
|
|
||||||
{
|
|
||||||
ProcessActorsInPortal(otherside->getPortal()->mGroup, in_area);
|
|
||||||
}
|
|
||||||
portal = new HWScenePortal(&pstate, new HWLineToLinePortal(wall->lineportal));
|
|
||||||
Portals.Push(portal);
|
|
||||||
}
|
|
||||||
portal->AddLine(wall);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PORTALTYPE_SKY:
|
|
||||||
wall->sky = pstate.UniqueSkies.Get(wall->sky);
|
|
||||||
portal = FindPortal(wall->sky);
|
|
||||||
if (!portal)
|
|
||||||
{
|
|
||||||
portal = new HWSkyPortal(GLRenderer->mSkyVBO, &pstate, wall->sky);
|
|
||||||
Portals.Push(portal);
|
|
||||||
}
|
|
||||||
portal->AddLine(wall);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
wall->vertcount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include "hw_renderstate.h"
|
#include "hw_renderstate.h"
|
||||||
#include "hw_drawstructs.h"
|
#include "hw_drawstructs.h"
|
||||||
|
#include "hw_portal.h"
|
||||||
#include "hwrenderer/utility/hw_lighting.h"
|
#include "hwrenderer/utility/hw_lighting.h"
|
||||||
#include "hwrenderer/utility/hw_cvars.h"
|
#include "hwrenderer/utility/hw_cvars.h"
|
||||||
|
|
||||||
|
@ -115,7 +116,7 @@ void FRenderState::SetFog(int lightlevel, int rellight, bool fullbright, const F
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make fog a little denser when inside a skybox
|
// Make fog a little denser when inside a skybox
|
||||||
//if (GLRenderer->mPortalState.inskybox) fogdensity += fogdensity / 2;
|
if (screen->mPortalState->inskybox) fogdensity += fogdensity / 2;
|
||||||
|
|
||||||
|
|
||||||
// no fog in enhanced vision modes!
|
// no fog in enhanced vision modes!
|
||||||
|
|
|
@ -427,9 +427,115 @@ void GLWall::PutWall(HWDrawInfo *di, bool translucent)
|
||||||
flags &= ~GLWF_TRANSLUCENT;
|
flags &= ~GLWF_TRANSLUCENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
void GLWall::PutPortal(HWDrawInfo *di, int ptype)
|
void GLWall::PutPortal(HWDrawInfo *di, int ptype)
|
||||||
{
|
{
|
||||||
di->AddPortal(this, ptype);
|
auto pstate = screen->mPortalState;
|
||||||
|
HWPortal * portal;
|
||||||
|
|
||||||
|
MakeVertices(di, false);
|
||||||
|
switch (ptype)
|
||||||
|
{
|
||||||
|
// portals don't go into the draw list.
|
||||||
|
// Instead they are added to the portal manager
|
||||||
|
case PORTALTYPE_HORIZON:
|
||||||
|
horizon = pstate->UniqueHorizons.Get(horizon);
|
||||||
|
portal = di->FindPortal(horizon);
|
||||||
|
if (!portal)
|
||||||
|
{
|
||||||
|
portal = new HWHorizonPortal(pstate, horizon, di->Viewpoint, di);
|
||||||
|
di->Portals.Push(portal);
|
||||||
|
}
|
||||||
|
portal->AddLine(this);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PORTALTYPE_SKYBOX:
|
||||||
|
portal = di->FindPortal(secportal);
|
||||||
|
if (!portal)
|
||||||
|
{
|
||||||
|
// either a regular skybox or an Eternity-style horizon
|
||||||
|
if (secportal->mType != PORTS_SKYVIEWPOINT) portal = new HWEEHorizonPortal(pstate, secportal, di);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
portal = new HWScenePortal(pstate, new HWSkyboxPortal(secportal));
|
||||||
|
di->Portals.Push(portal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
portal->AddLine(this);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PORTALTYPE_SECTORSTACK:
|
||||||
|
portal = di->FindPortal(portal);
|
||||||
|
if (!portal)
|
||||||
|
{
|
||||||
|
portal = new HWScenePortal(pstate, new HWSectorStackPortal(this->portal));
|
||||||
|
di->Portals.Push(portal);
|
||||||
|
}
|
||||||
|
portal->AddLine(this);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PORTALTYPE_PLANEMIRROR:
|
||||||
|
if (pstate->PlaneMirrorMode * planemirror->fC() <= 0)
|
||||||
|
{
|
||||||
|
//@sync-portal
|
||||||
|
planemirror = pstate->UniquePlaneMirrors.Get(planemirror);
|
||||||
|
portal = di->FindPortal(planemirror);
|
||||||
|
if (!portal)
|
||||||
|
{
|
||||||
|
portal = new HWScenePortal(pstate, new HWPlaneMirrorPortal(planemirror));
|
||||||
|
di->Portals.Push(portal);
|
||||||
|
}
|
||||||
|
portal->AddLine(this);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PORTALTYPE_MIRROR:
|
||||||
|
portal = di->FindPortal(seg->linedef);
|
||||||
|
if (!portal)
|
||||||
|
{
|
||||||
|
portal = new HWScenePortal(pstate, new HWMirrorPortal(seg->linedef));
|
||||||
|
di->Portals.Push(portal);
|
||||||
|
}
|
||||||
|
portal->AddLine(this);
|
||||||
|
if (gl_mirror_envmap)
|
||||||
|
{
|
||||||
|
// draw a reflective layer over the mirror
|
||||||
|
di->AddMirrorSurface(this);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PORTALTYPE_LINETOLINE:
|
||||||
|
portal = di->FindPortal(lineportal);
|
||||||
|
if (!portal)
|
||||||
|
{
|
||||||
|
line_t *otherside = lineportal->lines[0]->mDestination;
|
||||||
|
if (otherside != nullptr && otherside->portalindex < level.linePortals.Size())
|
||||||
|
{
|
||||||
|
di->ProcessActorsInPortal(otherside->getPortal()->mGroup, di->in_area);
|
||||||
|
}
|
||||||
|
portal = new HWScenePortal(pstate, new HWLineToLinePortal(lineportal));
|
||||||
|
di->Portals.Push(portal);
|
||||||
|
}
|
||||||
|
portal->AddLine(this);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PORTALTYPE_SKY:
|
||||||
|
sky = pstate->UniqueSkies.Get(sky);
|
||||||
|
portal = di->FindPortal(sky);
|
||||||
|
if (!portal)
|
||||||
|
{
|
||||||
|
portal = new HWSkyPortal(GLRenderer->mSkyVBO, &pstate, sky);
|
||||||
|
di->Portals.Push(portal);
|
||||||
|
}
|
||||||
|
portal->AddLine(this);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
vertcount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
#include "r_videoscale.h"
|
#include "r_videoscale.h"
|
||||||
#include "i_time.h"
|
#include "i_time.h"
|
||||||
|
#include "hwrenderer/scene/hw_portal.h"
|
||||||
|
|
||||||
|
|
||||||
CVAR(Bool, gl_scale_viewport, true, CVAR_ARCHIVE);
|
CVAR(Bool, gl_scale_viewport, true, CVAR_ARCHIVE);
|
||||||
|
@ -172,6 +173,12 @@ DSimpleCanvas::~DSimpleCanvas ()
|
||||||
DFrameBuffer::DFrameBuffer (int width, int height)
|
DFrameBuffer::DFrameBuffer (int width, int height)
|
||||||
{
|
{
|
||||||
SetSize(width, height);
|
SetSize(width, height);
|
||||||
|
mPortalState = new FPortalSceneState;
|
||||||
|
}
|
||||||
|
|
||||||
|
DFrameBuffer::~DFrameBuffer()
|
||||||
|
{
|
||||||
|
delete mPortalState;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DFrameBuffer::SetSize(int width, int height)
|
void DFrameBuffer::SetSize(int width, int height)
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
struct sector_t;
|
struct sector_t;
|
||||||
class IShaderProgram;
|
class IShaderProgram;
|
||||||
class FTexture;
|
class FTexture;
|
||||||
|
struct FPortalSceneState;
|
||||||
|
|
||||||
enum EHWCaps
|
enum EHWCaps
|
||||||
{
|
{
|
||||||
|
@ -362,10 +363,11 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int hwcaps = 0;
|
int hwcaps = 0;
|
||||||
float glslversion = 0; // This is here so that the differences between old OpenGL and new OpenGL/Vulkan can be handled by platform independent code.
|
float glslversion = 0; // This is here so that the differences between old OpenGL and new OpenGL/Vulkan can be handled by platform independent code.
|
||||||
int instack[2] = { 0,0 }; // this is globally maintained state for portal recursion avoidance.
|
int instack[2] = { 0,0 }; // this is globally maintained state for portal recursion avoidance.
|
||||||
int stencilValue = 0; // Global stencil test value
|
int stencilValue = 0; // Global stencil test value
|
||||||
bool enable_quadbuffered = false;
|
bool enable_quadbuffered = false;
|
||||||
|
FPortalSceneState *mPortalState; // global portal state.
|
||||||
|
|
||||||
IntRect mScreenViewport;
|
IntRect mScreenViewport;
|
||||||
IntRect mSceneViewport;
|
IntRect mSceneViewport;
|
||||||
|
@ -373,7 +375,7 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DFrameBuffer (int width=1, int height=1);
|
DFrameBuffer (int width=1, int height=1);
|
||||||
virtual ~DFrameBuffer() {}
|
virtual ~DFrameBuffer();
|
||||||
virtual void InitializeState() = 0; // For stuff that needs 'screen' set.
|
virtual void InitializeState() = 0; // For stuff that needs 'screen' set.
|
||||||
|
|
||||||
void SetSize(int width, int height);
|
void SetSize(int width, int height);
|
||||||
|
|
Loading…
Reference in a new issue