diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 7a8fb8b2c8..f442c882cc 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -42,6 +42,7 @@ #include "gl_load/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "hwrenderer/utility/hw_cvars.h" +#include "gl/scene/gl_portal.h" #include "gl/system/gl_debug.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_lightdata.h" @@ -49,7 +50,6 @@ #include "gl/renderer/gl_renderbuffers.h" #include "gl/data/gl_vertexbuffer.h" #include "gl/scene/gl_drawinfo.h" -#include "gl/scene/gl_scenedrawer.h" #include "hwrenderer/postprocessing/hw_ambientshader.h" #include "hwrenderer/postprocessing/hw_bloomshader.h" #include "hwrenderer/postprocessing/hw_blurshader.h" diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index b7a7afc0e2..2d3f1ae33c 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -48,8 +48,8 @@ class FGL2DDrawer; class FHardwareTexture; class FShadowMapShader; class FCustomPostProcessShaders; -class GLSceneDrawer; class SWSceneDrawer; +struct FRenderViewpoint; #define NOQUEUE nullptr // just some token to be used as a placeholder enum diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 11ae0b8254..20d8160234 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -37,8 +37,8 @@ #include "gl/data/gl_vertexbuffer.h" #include "gl/scene/gl_drawinfo.h" +#include "hwrenderer/scene/hw_clipper.h" #include "gl/scene/gl_portal.h" -#include "gl/scene/gl_scenedrawer.h" #include "gl/renderer/gl_renderstate.h" #include "gl/stereo3d/scoped_color_mask.h" #include "gl/renderer/gl_quaddrawer.h" @@ -190,10 +190,9 @@ FDrawInfo::~FDrawInfo() // OpenGL has no use for multiple clippers so use the same one for all DrawInfos. static Clipper staticClipper; -FDrawInfo *FDrawInfo::StartDrawInfo(GLSceneDrawer *drawer, FRenderViewpoint &parentvp) +FDrawInfo *FDrawInfo::StartDrawInfo(FRenderViewpoint &parentvp) { FDrawInfo *di=di_list.GetNew(); - di->mDrawer = drawer; di->mVBO = GLRenderer->mVBO; di->mClipper = &staticClipper; di->Viewpoint = parentvp; diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index fb13b32248..ec84e711d1 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -9,8 +9,6 @@ #pragma warning(disable:4244) #endif -class GLSceneDrawer; - enum DrawListType { GLDL_PLAINWALLS, @@ -36,8 +34,6 @@ enum Drawpasses struct FDrawInfo : public HWDrawInfo { - GLSceneDrawer *mDrawer; - FDrawInfo * next; HWDrawList drawlists[GLDL_TYPES]; TArray hudsprites; // These may just be stored by value. @@ -112,8 +108,14 @@ struct FDrawInfo : public HWDrawInfo void ProcessScene(bool toscreen = false); void EndDrawScene(sector_t * viewsector); void DrawEndScene2D(sector_t * viewsector); + + // These should go into hwrenderer later. + void SetProjection(VSMatrix matrix); + void SetViewMatrix(const FRotator &angles, float vx, float vy, float vz, bool mirror, bool planemirror); + void SetupView(FRenderViewpoint &vp, float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror); - static FDrawInfo *StartDrawInfo(GLSceneDrawer *drawer, FRenderViewpoint &parentvp); + + static FDrawInfo *StartDrawInfo(FRenderViewpoint &parentvp); FDrawInfo *EndDrawInfo(); gl_subsectorrendernode * GetOtherFloorPlanes(unsigned int sector) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 6438593f75..f7b0729f10 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -45,7 +45,6 @@ #include "gl/data/gl_vertexbuffer.h" #include "gl/dynlights/gl_lightbuffer.h" #include "gl/scene/gl_drawinfo.h" -#include "gl/scene/gl_scenedrawer.h" #include "gl/renderer/gl_quaddrawer.h" //========================================================================== diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index afdfc3c14f..c531ca308c 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -42,7 +42,6 @@ #include "gl/data/gl_vertexbuffer.h" #include "hwrenderer/scene/hw_clipper.h" #include "gl/scene/gl_portal.h" -#include "gl/scene/gl_scenedrawer.h" #include "gl/stereo3d/scoped_color_mask.h" //----------------------------------------------------------------------------- @@ -59,7 +58,6 @@ EXTERN_CVAR(Bool, gl_portals) EXTERN_CVAR(Bool, gl_noquery) EXTERN_CVAR(Int, r_mirror_recursions) -GLSceneDrawer *GLPortal::drawer; TArray GLPortal::portals; TArray GLPortal::planestack; int GLPortal::recursion; @@ -228,7 +226,7 @@ bool GLPortal::Start(bool usestencil, bool doquery, FDrawInfo *outer_di, FDrawIn return false; } } - *pDi = FDrawInfo::StartDrawInfo(drawer, outer_di->Viewpoint); + *pDi = FDrawInfo::StartDrawInfo(outer_di->Viewpoint); } else { @@ -257,7 +255,7 @@ bool GLPortal::Start(bool usestencil, bool doquery, FDrawInfo *outer_di, FDrawIn { if (NeedDepthBuffer()) { - *pDi = FDrawInfo::StartDrawInfo(drawer, outer_di->Viewpoint); + *pDi = FDrawInfo::StartDrawInfo(outer_di->Viewpoint); } else { @@ -327,7 +325,7 @@ void GLPortal::End(FDrawInfo *di, bool usestencil) // Restore the old view if (vp.camera != nullptr) vp.camera->renderflags = (vp.camera->renderflags & ~RF_MAYBEINVISIBLE) | savedvisibility; - drawer->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); + di->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); { ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0, 0, 0, 0); // no graphics @@ -382,7 +380,7 @@ void GLPortal::End(FDrawInfo *di, bool usestencil) // Restore the old view if (vp.camera != nullptr) vp.camera->renderflags = (vp.camera->renderflags & ~RF_MAYBEINVISIBLE) | savedvisibility; - drawer->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); + di->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); // This draws a valid z-buffer into the stencil's contents to ensure it // doesn't get overwritten by the level's geometry. @@ -589,13 +587,13 @@ void GLSkyboxPortal::DrawContents(FDrawInfo *di) vp.ViewActor = origin; inskybox = true; - drawer->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); + di->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); di->SetViewArea(); ClearClipper(di); di->UpdateCurrentMapSection(); - drawer->DrawScene(di, DM_SKYPORTAL); + di->DrawScene(DM_SKYPORTAL); portal->mFlags &= ~PORTSF_INSKYBOX; inskybox = false; gl_RenderState.SetDepthClamp(oldclamp); @@ -696,7 +694,7 @@ void GLSectorStackPortal::DrawContents(FDrawInfo *di) // avoid recursions! if (origin->plane != -1) screen->instack[origin->plane]++; - drawer->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + di->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); SetupCoverage(di); ClearClipper(di); @@ -709,7 +707,7 @@ void GLSectorStackPortal::DrawContents(FDrawInfo *di) di->mClipper->SetBlocked(true); } - drawer->DrawScene(di, DM_PORTAL); + di->DrawScene(DM_PORTAL); if (origin->plane != -1) screen->instack[origin->plane]--; } @@ -752,13 +750,13 @@ void GLPlaneMirrorPortal::DrawContents(FDrawInfo *di) PlaneMirrorMode = origin->fC() < 0 ? -1 : 1; PlaneMirrorFlag++; - drawer->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); + di->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); ClearClipper(di); di->UpdateCurrentMapSection(); gl_RenderState.SetClipHeight(planez, PlaneMirrorMode < 0 ? -1.f : 1.f); - drawer->DrawScene(di, DM_PORTAL); + di->DrawScene(DM_PORTAL); gl_RenderState.SetClipHeight(0.f, 0.f); PlaneMirrorFlag--; PlaneMirrorMode = old_pm; @@ -923,7 +921,7 @@ void GLMirrorPortal::DrawContents(FDrawInfo *di) vp.ViewActor = nullptr; MirrorFlag++; - drawer->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + di->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); di->mClipper->Clear(); @@ -934,7 +932,7 @@ void GLMirrorPortal::DrawContents(FDrawInfo *di) gl_RenderState.SetClipLine(linedef); gl_RenderState.EnableClipLine(true); - drawer->DrawScene(di, DM_PORTAL); + di->DrawScene(DM_PORTAL); gl_RenderState.EnableClipLine(false); MirrorFlag--; @@ -1000,12 +998,12 @@ void GLLineToLinePortal::DrawContents(FDrawInfo *di) } vp.ViewActor = nullptr; - drawer->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + di->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); ClearClipper(di); gl_RenderState.SetClipLine(glport->lines[0]->mDestination); gl_RenderState.EnableClipLine(true); - drawer->DrawScene(di, DM_PORTAL); + di->DrawScene(DM_PORTAL); gl_RenderState.EnableClipLine(false); } diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index cc5b5d09d9..cb05fb3795 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -48,7 +48,6 @@ extern UniqueList UniqueSkies; extern UniqueList UniqueHorizons; extern UniqueList UniquePlaneMirrors; struct GLEEHorizonPortal; -class GLSceneDrawer; class GLPortal : public IPortal { @@ -62,7 +61,6 @@ protected: static int renderdepth; public: - static GLSceneDrawer *drawer; static int PlaneMirrorMode; static int inupperstack; static bool inskybox; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 0fca4eeaff..27d5172263 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -52,7 +52,6 @@ #include "hwrenderer/scene/hw_clipper.h" #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" -#include "gl/scene/gl_scenedrawer.h" #include "gl/stereo3d/gl_stereo3d.h" #include "hwrenderer/utility/scoped_view_shifter.h" @@ -79,7 +78,7 @@ EXTERN_CVAR (Bool, r_drawvoxels) // //----------------------------------------------------------------------------- -void SetProjection(VSMatrix matrix) +void FDrawInfo::SetProjection(VSMatrix matrix) { gl_RenderState.mProjectionMatrix.loadIdentity(); gl_RenderState.mProjectionMatrix.multMatrix(matrix); @@ -91,7 +90,7 @@ void SetProjection(VSMatrix matrix) // //----------------------------------------------------------------------------- -void SetViewMatrix(const FRotator &angles, float vx, float vy, float vz, bool mirror, bool planemirror) +void FDrawInfo::SetViewMatrix(const FRotator &angles, float vx, float vy, float vz, bool mirror, bool planemirror) { float mult = mirror? -1:1; float planemult = planemirror? -level.info->pixelstretch : level.info->pixelstretch; @@ -111,7 +110,7 @@ void SetViewMatrix(const FRotator &angles, float vx, float vy, float vz, bool mi // Setup the view rotation matrix for the given viewpoint // //----------------------------------------------------------------------------- -void GLSceneDrawer::SetupView(FRenderViewpoint &vp, float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror) +void FDrawInfo::SetupView(FRenderViewpoint &vp, float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror) { vp.SetViewAngle(r_viewwindow); SetViewMatrix(vp.HWAngles, vx, vy, vz, mirror, planemirror); @@ -511,19 +510,19 @@ sector_t * FGLRenderer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * came screen->SetViewportRects(bounds); Set3DViewport(mainview); - FDrawInfo *di = FDrawInfo::StartDrawInfo(nullptr, mainvp); + FDrawInfo *di = FDrawInfo::StartDrawInfo(mainvp); auto vp = di->Viewpoint; 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) // Stereo mode specific perspective projection - SetProjection( eye->GetProjection(fov, ratio, fovratio) ); + di->SetProjection( eye->GetProjection(fov, ratio, fovratio) ); vp.SetViewAngle(r_viewwindow); // Stereo mode specific viewpoint adjustment - temporarily shifts global ViewPos eye->GetViewShift(vp.HWAngles.Yaw.Degrees, viewShift); ScopedViewShifter viewShifter(vp.Pos, viewShift); - SetViewMatrix(vp.HWAngles, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, false, false); + di->SetViewMatrix(vp.HWAngles, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, false, false); gl_RenderState.ApplyMatrices(); di->ProcessScene(toscreen); diff --git a/src/gl/scene/gl_scenedrawer.h b/src/gl/scene/gl_scenedrawer.h deleted file mode 100644 index 219c5c0be0..0000000000 --- a/src/gl/scene/gl_scenedrawer.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "r_defs.h" -#include "m_fixed.h" -#include "hwrenderer/scene/hw_clipper.h" -#include "gl_portal.h" -#include "gl/renderer/gl_lightdata.h" -#include "gl/renderer/gl_renderer.h" -#include "r_utility.h" -#include "c_cvars.h" - -struct HUDSprite; - -class GLSceneDrawer -{ -public: - GLSceneDrawer() - { - GLPortal::drawer = this; - } - - void SetupView(FRenderViewpoint &vp, float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror); - - sector_t *RenderView(player_t *player); -}; diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index a916c535ac..59165ae317 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -32,9 +32,10 @@ #include "gl_load/gl_interface.h" #include "gl/data/gl_vertexbuffer.h" #include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderstate.h" #include "gl/scene/gl_drawinfo.h" -#include "gl/scene/gl_scenedrawer.h" +#include "gl/scene/gl_portal.h" #include "gl/shaders/gl_shader.h" @@ -230,7 +231,7 @@ void GLSkyPortal::DrawContents(FDrawInfo *di) bool oldClamp = gl_RenderState.SetDepthClamp(true); gl_MatrixStack.Push(gl_RenderState.mViewMatrix); - drawer->SetupView(vp, 0, 0, 0, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); + di->SetupView(vp, 0, 0, 0, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); gl_RenderState.SetVertexBuffer(GLRenderer->mSkyVBO); if (origin->texture[0] && origin->texture[0]->tex->bSkybox) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 1a417c5774..68765d91d9 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -47,7 +47,6 @@ #include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_renderer.h" #include "gl/scene/gl_drawinfo.h" -#include "gl/scene/gl_scenedrawer.h" #include "gl/models/gl_models.h" #include "gl/renderer/gl_quaddrawer.h" #include "gl/dynlights/gl_lightbuffer.h" diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 117c428232..83f9aa2df1 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -37,7 +37,6 @@ #include "gl/dynlights/gl_lightbuffer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" -#include "gl/scene/gl_scenedrawer.h" EXTERN_CVAR(Bool, gl_seamless) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 8fe07eb004..5f44bf363c 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -37,7 +37,6 @@ #include "gl/renderer/gl_renderstate.h" #include "gl/data/gl_vertexbuffer.h" #include "gl/scene/gl_drawinfo.h" -#include "gl/scene/gl_scenedrawer.h" #include "gl/models/gl_models.h" #include "gl/stereo3d/gl_stereo3d.h" #include "gl/dynlights/gl_lightbuffer.h"