mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
- moved several more functions from FGLRenderer to GLSceneDrawer.
This commit is contained in:
parent
90c42519b7
commit
e4d7d9de8b
6 changed files with 82 additions and 81 deletions
|
@ -47,6 +47,7 @@
|
||||||
#include "gl/system/gl_cvars.h"
|
#include "gl/system/gl_cvars.h"
|
||||||
#include "gl/renderer/gl_renderstate.h"
|
#include "gl/renderer/gl_renderstate.h"
|
||||||
#include "gl/scene/gl_drawinfo.h"
|
#include "gl/scene/gl_drawinfo.h"
|
||||||
|
#include "gl/scene/gl_scenedrawer.h"
|
||||||
#include "gl/data/gl_vertexbuffer.h"
|
#include "gl/data/gl_vertexbuffer.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -756,7 +757,7 @@ void GLWall::RenderLightsCompat(int pass)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void FGLRenderer::RenderMultipassStuff()
|
void GLSceneDrawer::RenderMultipassStuff()
|
||||||
{
|
{
|
||||||
// First pass: empty background with sector light only
|
// First pass: empty background with sector light only
|
||||||
|
|
||||||
|
@ -790,7 +791,7 @@ void FGLRenderer::RenderMultipassStuff()
|
||||||
|
|
||||||
// second pass: draw lights
|
// second pass: draw lights
|
||||||
glDepthMask(false);
|
glDepthMask(false);
|
||||||
if (mLightCount && !gl_fixedcolormap)
|
if (GLRenderer->mLightCount && !gl_fixedcolormap)
|
||||||
{
|
{
|
||||||
if (gl_SetupLightTexture())
|
if (gl_SetupLightTexture())
|
||||||
{
|
{
|
||||||
|
|
|
@ -158,21 +158,12 @@ public:
|
||||||
int ScreenToWindowX(int x);
|
int ScreenToWindowX(int x);
|
||||||
int ScreenToWindowY(int y);
|
int ScreenToWindowY(int y);
|
||||||
|
|
||||||
angle_t FrustumAngle();
|
|
||||||
void SetViewArea();
|
|
||||||
void Set3DViewport(bool mainview);
|
|
||||||
void Reset3DViewport();
|
void Reset3DViewport();
|
||||||
sector_t *RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen);
|
sector_t *RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen);
|
||||||
void RenderView(player_t *player);
|
void RenderView(player_t *player);
|
||||||
void SetViewAngle(DAngle viewangle);
|
|
||||||
void SetupView(float viewx, float viewy, float viewz, DAngle viewangle, bool mirror, bool planemirror);
|
|
||||||
|
|
||||||
void Initialize(int width, int height);
|
void Initialize(int width, int height);
|
||||||
|
|
||||||
void RenderMultipassStuff();
|
|
||||||
void RenderScene(int recursion);
|
|
||||||
void RenderTranslucent();
|
|
||||||
void DrawScene(int drawmode);
|
|
||||||
void DrawBlend(sector_t * viewsector);
|
void DrawBlend(sector_t * viewsector);
|
||||||
|
|
||||||
void DrawPSprite (player_t * player,DPSprite *psp,float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture);
|
void DrawPSprite (player_t * player,DPSprite *psp,float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture);
|
||||||
|
@ -208,10 +199,6 @@ public:
|
||||||
void DrawPresentTexture(const GL_IRECT &box, bool applyGamma);
|
void DrawPresentTexture(const GL_IRECT &box, bool applyGamma);
|
||||||
void Flush();
|
void Flush();
|
||||||
|
|
||||||
void SetProjection(float fov, float ratio, float fovratio);
|
|
||||||
void SetProjection(VSMatrix matrix); // raw matrix input from stereo 3d modes
|
|
||||||
void SetViewMatrix(float vx, float vy, float vz, bool mirror, bool planemirror);
|
|
||||||
void ProcessScene(bool toscreen = false);
|
|
||||||
|
|
||||||
bool StartOffscreen();
|
bool StartOffscreen();
|
||||||
void EndOffscreen();
|
void EndOffscreen();
|
||||||
|
|
|
@ -328,7 +328,7 @@ inline void GLPortal::ClearClipper()
|
||||||
}
|
}
|
||||||
|
|
||||||
// and finally clip it to the visible area
|
// and finally clip it to the visible area
|
||||||
angle_t a1 = GLRenderer->FrustumAngle();
|
angle_t a1 = drawer->FrustumAngle();
|
||||||
if (a1 < ANGLE_180) drawer->clipper.SafeAddClipRangeRealAngles(r_viewpoint.Angles.Yaw.BAMs() + a1, r_viewpoint.Angles.Yaw.BAMs() - a1);
|
if (a1 < ANGLE_180) drawer->clipper.SafeAddClipRangeRealAngles(r_viewpoint.Angles.Yaw.BAMs() + a1, r_viewpoint.Angles.Yaw.BAMs() - a1);
|
||||||
|
|
||||||
// lock the parts that have just been clipped out.
|
// lock the parts that have just been clipped out.
|
||||||
|
@ -363,7 +363,7 @@ void GLPortal::End(bool usestencil)
|
||||||
GLRenderer->mViewActor=savedviewactor;
|
GLRenderer->mViewActor=savedviewactor;
|
||||||
in_area=savedviewarea;
|
in_area=savedviewarea;
|
||||||
if (r_viewpoint.camera != nullptr) r_viewpoint.camera->renderflags = (r_viewpoint.camera->renderflags & ~RF_MAYBEINVISIBLE) | savedvisibility;
|
if (r_viewpoint.camera != nullptr) r_viewpoint.camera->renderflags = (r_viewpoint.camera->renderflags & ~RF_MAYBEINVISIBLE) | savedvisibility;
|
||||||
GLRenderer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
drawer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
||||||
|
|
||||||
{
|
{
|
||||||
ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0, 0, 0, 0); // no graphics
|
ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0, 0, 0, 0); // no graphics
|
||||||
|
@ -422,7 +422,7 @@ void GLPortal::End(bool usestencil)
|
||||||
GLRenderer->mViewActor=savedviewactor;
|
GLRenderer->mViewActor=savedviewactor;
|
||||||
in_area=savedviewarea;
|
in_area=savedviewarea;
|
||||||
if (r_viewpoint.camera != nullptr) r_viewpoint.camera->renderflags |= savedvisibility;
|
if (r_viewpoint.camera != nullptr) r_viewpoint.camera->renderflags |= savedvisibility;
|
||||||
GLRenderer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
drawer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||||
|
|
||||||
// This draws a valid z-buffer into the stencil's contents to ensure it
|
// This draws a valid z-buffer into the stencil's contents to ensure it
|
||||||
// doesn't get overwritten by the level's geometry.
|
// doesn't get overwritten by the level's geometry.
|
||||||
|
@ -648,8 +648,8 @@ void GLSkyboxPortal::DrawContents()
|
||||||
GLRenderer->mViewActor = origin;
|
GLRenderer->mViewActor = origin;
|
||||||
|
|
||||||
inskybox = true;
|
inskybox = true;
|
||||||
GLRenderer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
drawer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
||||||
GLRenderer->SetViewArea();
|
drawer->SetViewArea();
|
||||||
ClearClipper();
|
ClearClipper();
|
||||||
|
|
||||||
int mapsection = R_PointInSubsector(r_viewpoint.Pos)->mapsection;
|
int mapsection = R_PointInSubsector(r_viewpoint.Pos)->mapsection;
|
||||||
|
@ -657,7 +657,7 @@ void GLSkyboxPortal::DrawContents()
|
||||||
SaveMapSection();
|
SaveMapSection();
|
||||||
currentmapsection[mapsection >> 3] |= 1 << (mapsection & 7);
|
currentmapsection[mapsection >> 3] |= 1 << (mapsection & 7);
|
||||||
|
|
||||||
GLRenderer->DrawScene(DM_SKYPORTAL);
|
drawer->DrawScene(DM_SKYPORTAL);
|
||||||
portal->mFlags &= ~PORTSF_INSKYBOX;
|
portal->mFlags &= ~PORTSF_INSKYBOX;
|
||||||
inskybox = false;
|
inskybox = false;
|
||||||
gl_RenderState.SetDepthClamp(oldclamp);
|
gl_RenderState.SetDepthClamp(oldclamp);
|
||||||
|
@ -744,7 +744,7 @@ void GLSectorStackPortal::DrawContents()
|
||||||
// avoid recursions!
|
// avoid recursions!
|
||||||
if (origin->plane != -1) instack[origin->plane]++;
|
if (origin->plane != -1) instack[origin->plane]++;
|
||||||
|
|
||||||
GLRenderer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
drawer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||||
SaveMapSection();
|
SaveMapSection();
|
||||||
SetupCoverage();
|
SetupCoverage();
|
||||||
ClearClipper();
|
ClearClipper();
|
||||||
|
@ -758,7 +758,7 @@ void GLSectorStackPortal::DrawContents()
|
||||||
drawer->clipper.SetBlocked(true);
|
drawer->clipper.SetBlocked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLRenderer->DrawScene(DM_PORTAL);
|
drawer->DrawScene(DM_PORTAL);
|
||||||
RestoreMapSection();
|
RestoreMapSection();
|
||||||
|
|
||||||
if (origin->plane != -1) instack[origin->plane]--;
|
if (origin->plane != -1) instack[origin->plane]--;
|
||||||
|
@ -801,11 +801,11 @@ void GLPlaneMirrorPortal::DrawContents()
|
||||||
PlaneMirrorMode = origin->fC() < 0 ? -1 : 1;
|
PlaneMirrorMode = origin->fC() < 0 ? -1 : 1;
|
||||||
|
|
||||||
PlaneMirrorFlag++;
|
PlaneMirrorFlag++;
|
||||||
GLRenderer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
drawer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
||||||
ClearClipper();
|
ClearClipper();
|
||||||
|
|
||||||
gl_RenderState.SetClipHeight(planez, PlaneMirrorMode < 0 ? -1.f : 1.f);
|
gl_RenderState.SetClipHeight(planez, PlaneMirrorMode < 0 ? -1.f : 1.f);
|
||||||
GLRenderer->DrawScene(DM_PORTAL);
|
drawer->DrawScene(DM_PORTAL);
|
||||||
gl_RenderState.SetClipHeight(0.f, 0.f);
|
gl_RenderState.SetClipHeight(0.f, 0.f);
|
||||||
PlaneMirrorFlag--;
|
PlaneMirrorFlag--;
|
||||||
PlaneMirrorMode = old_pm;
|
PlaneMirrorMode = old_pm;
|
||||||
|
@ -967,11 +967,11 @@ void GLMirrorPortal::DrawContents()
|
||||||
GLRenderer->mViewActor = NULL;
|
GLRenderer->mViewActor = NULL;
|
||||||
|
|
||||||
MirrorFlag++;
|
MirrorFlag++;
|
||||||
GLRenderer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
drawer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||||
|
|
||||||
drawer->clipper.Clear();
|
drawer->clipper.Clear();
|
||||||
|
|
||||||
angle_t af = GLRenderer->FrustumAngle();
|
angle_t af = drawer->FrustumAngle();
|
||||||
if (af<ANGLE_180) drawer->clipper.SafeAddClipRangeRealAngles(r_viewpoint.Angles.Yaw.BAMs()+af, r_viewpoint.Angles.Yaw.BAMs()-af);
|
if (af<ANGLE_180) drawer->clipper.SafeAddClipRangeRealAngles(r_viewpoint.Angles.Yaw.BAMs()+af, r_viewpoint.Angles.Yaw.BAMs()-af);
|
||||||
|
|
||||||
angle_t a2 = linedef->v1->GetClipAngle();
|
angle_t a2 = linedef->v1->GetClipAngle();
|
||||||
|
@ -980,7 +980,7 @@ void GLMirrorPortal::DrawContents()
|
||||||
|
|
||||||
gl_RenderState.SetClipLine(linedef);
|
gl_RenderState.SetClipLine(linedef);
|
||||||
gl_RenderState.EnableClipLine(true);
|
gl_RenderState.EnableClipLine(true);
|
||||||
GLRenderer->DrawScene(DM_PORTAL);
|
drawer->DrawScene(DM_PORTAL);
|
||||||
gl_RenderState.EnableClipLine(false);
|
gl_RenderState.EnableClipLine(false);
|
||||||
|
|
||||||
MirrorFlag--;
|
MirrorFlag--;
|
||||||
|
@ -1049,12 +1049,12 @@ void GLLineToLinePortal::DrawContents()
|
||||||
}
|
}
|
||||||
|
|
||||||
GLRenderer->mViewActor = nullptr;
|
GLRenderer->mViewActor = nullptr;
|
||||||
GLRenderer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
drawer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||||
|
|
||||||
ClearClipper();
|
ClearClipper();
|
||||||
gl_RenderState.SetClipLine(glport->lines[0]->mDestination);
|
gl_RenderState.SetClipLine(glport->lines[0]->mDestination);
|
||||||
gl_RenderState.EnableClipLine(true);
|
gl_RenderState.EnableClipLine(true);
|
||||||
GLRenderer->DrawScene(DM_PORTAL);
|
drawer->DrawScene(DM_PORTAL);
|
||||||
gl_RenderState.EnableClipLine(false);
|
gl_RenderState.EnableClipLine(false);
|
||||||
RestoreMapSection();
|
RestoreMapSection();
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,18 +100,18 @@ void gl_ParseDefs();
|
||||||
// R_FrustumAngle
|
// R_FrustumAngle
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
angle_t FGLRenderer::FrustumAngle()
|
angle_t GLSceneDrawer::FrustumAngle()
|
||||||
{
|
{
|
||||||
float tilt= fabs(mAngles.Pitch.Degrees);
|
float tilt = fabs(GLRenderer->mAngles.Pitch.Degrees);
|
||||||
|
|
||||||
// If the pitch is larger than this you can look all around at a FOV of 90°
|
// If the pitch is larger than this you can look all around at a FOV of 90°
|
||||||
if (tilt>46.0f) return 0xffffffff;
|
if (tilt > 46.0f) return 0xffffffff;
|
||||||
|
|
||||||
// ok, this is a gross hack that barely works...
|
// ok, this is a gross hack that barely works...
|
||||||
// but at least it doesn't overestimate too much...
|
// but at least it doesn't overestimate too much...
|
||||||
double floatangle=2.0+(45.0+((tilt/1.9)))*mCurrentFoV*48.0/AspectMultiplier(r_viewwindow.WidescreenRatio)/90.0;
|
double floatangle = 2.0 + (45.0 + ((tilt / 1.9)))*GLRenderer->mCurrentFoV*48.0 / AspectMultiplier(r_viewwindow.WidescreenRatio) / 90.0;
|
||||||
angle_t a1 = DAngle(floatangle).BAMs();
|
angle_t a1 = DAngle(floatangle).BAMs();
|
||||||
if (a1>=ANGLE_180) return 0xffffffff;
|
if (a1 >= ANGLE_180) return 0xffffffff;
|
||||||
return a1;
|
return a1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ angle_t FGLRenderer::FrustumAngle()
|
||||||
// Sets the area the camera is in
|
// Sets the area the camera is in
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void FGLRenderer::SetViewArea()
|
void GLSceneDrawer::SetViewArea()
|
||||||
{
|
{
|
||||||
// The render_sector is better suited to represent the current position in GL
|
// The render_sector is better suited to represent the current position in GL
|
||||||
r_viewpoint.sector = R_PointInSubsector(r_viewpoint.Pos)->render_sector;
|
r_viewpoint.sector = R_PointInSubsector(r_viewpoint.Pos)->render_sector;
|
||||||
|
@ -155,12 +155,12 @@ void FGLRenderer::Reset3DViewport()
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void FGLRenderer::Set3DViewport(bool mainview)
|
void GLSceneDrawer::Set3DViewport(bool mainview)
|
||||||
{
|
{
|
||||||
if (mainview && mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height))
|
if (mainview && GLRenderer->mBuffers->Setup(GLRenderer->mScreenViewport.width, GLRenderer->mScreenViewport.height, GLRenderer->mSceneViewport.width, GLRenderer->mSceneViewport.height))
|
||||||
{
|
{
|
||||||
bool useSSAO = (gl_ssao != 0);
|
bool useSSAO = (gl_ssao != 0);
|
||||||
mBuffers->BindSceneFB(useSSAO);
|
GLRenderer->mBuffers->BindSceneFB(useSSAO);
|
||||||
gl_RenderState.SetPassType(useSSAO ? GBUFFER_PASS : NORMAL_PASS);
|
gl_RenderState.SetPassType(useSSAO ? GBUFFER_PASS : NORMAL_PASS);
|
||||||
gl_RenderState.EnableDrawBuffers(gl_RenderState.GetPassDrawBufferCount());
|
gl_RenderState.EnableDrawBuffers(gl_RenderState.GetPassDrawBufferCount());
|
||||||
gl_RenderState.Apply();
|
gl_RenderState.Apply();
|
||||||
|
@ -170,10 +170,10 @@ void FGLRenderer::Set3DViewport(bool mainview)
|
||||||
// This is faster on newer hardware because it allows the GPU to skip
|
// This is faster on newer hardware because it allows the GPU to skip
|
||||||
// reading from slower memory where the full buffers are stored.
|
// reading from slower memory where the full buffers are stored.
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
glClearColor(mSceneClearColor[0], mSceneClearColor[1], mSceneClearColor[2], 1.0f);
|
glClearColor(GLRenderer->mSceneClearColor[0], GLRenderer->mSceneClearColor[1], GLRenderer->mSceneClearColor[2], 1.0f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||||
|
|
||||||
const auto &bounds = mSceneViewport;
|
const auto &bounds = GLRenderer->mSceneViewport;
|
||||||
glViewport(bounds.left, bounds.top, bounds.width, bounds.height);
|
glViewport(bounds.left, bounds.top, bounds.width, bounds.height);
|
||||||
glScissor(bounds.left, bounds.top, bounds.width, bounds.height);
|
glScissor(bounds.left, bounds.top, bounds.width, bounds.height);
|
||||||
|
|
||||||
|
@ -192,12 +192,12 @@ void FGLRenderer::Set3DViewport(bool mainview)
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void FGLRenderer::SetViewAngle(DAngle viewangle)
|
void GLSceneDrawer::SetViewAngle(DAngle viewangle)
|
||||||
{
|
{
|
||||||
mAngles.Yaw = float(270.0-viewangle.Degrees);
|
GLRenderer->mAngles.Yaw = float(270.0-viewangle.Degrees);
|
||||||
DVector2 v = r_viewpoint.Angles.Yaw.ToVector();
|
DVector2 v = r_viewpoint.Angles.Yaw.ToVector();
|
||||||
mViewVector.X = v.X;
|
GLRenderer->mViewVector.X = v.X;
|
||||||
mViewVector.Y = v.Y;
|
GLRenderer->mViewVector.Y = v.Y;
|
||||||
|
|
||||||
R_SetViewAngle(r_viewpoint, r_viewwindow);
|
R_SetViewAngle(r_viewpoint, r_viewwindow);
|
||||||
}
|
}
|
||||||
|
@ -210,15 +210,7 @@ void FGLRenderer::SetViewAngle(DAngle viewangle)
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void FGLRenderer::SetProjection(float fov, float ratio, float fovratio)
|
void GLSceneDrawer::SetProjection(VSMatrix matrix)
|
||||||
{
|
|
||||||
|
|
||||||
float fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovratio));
|
|
||||||
gl_RenderState.mProjectionMatrix.perspective(fovy, ratio, GetZNear(), GetZFar());
|
|
||||||
}
|
|
||||||
|
|
||||||
// raw matrix input from stereo 3d modes
|
|
||||||
void FGLRenderer::SetProjection(VSMatrix matrix)
|
|
||||||
{
|
{
|
||||||
gl_RenderState.mProjectionMatrix.loadIdentity();
|
gl_RenderState.mProjectionMatrix.loadIdentity();
|
||||||
gl_RenderState.mProjectionMatrix.multMatrix(matrix);
|
gl_RenderState.mProjectionMatrix.multMatrix(matrix);
|
||||||
|
@ -230,7 +222,7 @@ void FGLRenderer::SetProjection(VSMatrix matrix)
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void FGLRenderer::SetViewMatrix(float vx, float vy, float vz, bool mirror, bool planemirror)
|
void GLSceneDrawer::SetViewMatrix(float vx, float vy, float vz, bool mirror, bool planemirror)
|
||||||
{
|
{
|
||||||
float mult = mirror? -1:1;
|
float mult = mirror? -1:1;
|
||||||
float planemult = planemirror? -glset.pixelstretch : glset.pixelstretch;
|
float planemult = planemirror? -glset.pixelstretch : glset.pixelstretch;
|
||||||
|
@ -250,7 +242,7 @@ void FGLRenderer::SetViewMatrix(float vx, float vy, float vz, bool mirror, bool
|
||||||
// Setup the view rotation matrix for the given viewpoint
|
// Setup the view rotation matrix for the given viewpoint
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void FGLRenderer::SetupView(float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror)
|
void GLSceneDrawer::SetupView(float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror)
|
||||||
{
|
{
|
||||||
SetViewAngle(va);
|
SetViewAngle(va);
|
||||||
SetViewMatrix(vx, vy, vz, mirror, planemirror);
|
SetViewMatrix(vx, vy, vz, mirror, planemirror);
|
||||||
|
@ -267,9 +259,8 @@ void FGLRenderer::SetupView(float vx, float vy, float vz, DAngle va, bool mirror
|
||||||
|
|
||||||
void GLSceneDrawer::CreateScene()
|
void GLSceneDrawer::CreateScene()
|
||||||
{
|
{
|
||||||
angle_t a1 = GLRenderer->FrustumAngle();
|
angle_t a1 = FrustumAngle();
|
||||||
InitClipper(r_viewpoint.Angles.Yaw.BAMs() + a1, r_viewpoint.Angles.Yaw.BAMs() - a1);
|
InitClipper(r_viewpoint.Angles.Yaw.BAMs() + a1, r_viewpoint.Angles.Yaw.BAMs() - a1);
|
||||||
GLPortal::drawer = this;
|
|
||||||
|
|
||||||
// reset the portal manager
|
// reset the portal manager
|
||||||
GLPortal::StartFrame();
|
GLPortal::StartFrame();
|
||||||
|
@ -306,7 +297,7 @@ void GLSceneDrawer::CreateScene()
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void FGLRenderer::RenderScene(int recursion)
|
void GLSceneDrawer::RenderScene(int recursion)
|
||||||
{
|
{
|
||||||
RenderAll.Clock();
|
RenderAll.Clock();
|
||||||
|
|
||||||
|
@ -329,7 +320,7 @@ void FGLRenderer::RenderScene(int recursion)
|
||||||
|
|
||||||
// if we don't have a persistently mapped buffer, we have to process all the dynamic lights up front,
|
// if we don't have a persistently mapped buffer, we have to process all the dynamic lights up front,
|
||||||
// so that we don't have to do repeated map/unmap calls on the buffer.
|
// so that we don't have to do repeated map/unmap calls on the buffer.
|
||||||
bool haslights = mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights;
|
bool haslights = GLRenderer->mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights;
|
||||||
if (gl.lightmethod == LM_DEFERRED && haslights)
|
if (gl.lightmethod == LM_DEFERRED && haslights)
|
||||||
{
|
{
|
||||||
GLRenderer->mLights->Begin();
|
GLRenderer->mLights->Begin();
|
||||||
|
@ -358,7 +349,7 @@ void FGLRenderer::RenderScene(int recursion)
|
||||||
{
|
{
|
||||||
pass = GLPASS_ALL;
|
pass = GLPASS_ALL;
|
||||||
}
|
}
|
||||||
else
|
else // GL 2.x legacy mode
|
||||||
{
|
{
|
||||||
// process everything that needs to handle textured dynamic lights.
|
// process everything that needs to handle textured dynamic lights.
|
||||||
if (haslights) RenderMultipassStuff();
|
if (haslights) RenderMultipassStuff();
|
||||||
|
@ -445,7 +436,7 @@ void FGLRenderer::RenderScene(int recursion)
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void FGLRenderer::RenderTranslucent()
|
void GLSceneDrawer::RenderTranslucent()
|
||||||
{
|
{
|
||||||
RenderAll.Clock();
|
RenderAll.Clock();
|
||||||
|
|
||||||
|
@ -477,7 +468,7 @@ void FGLRenderer::RenderTranslucent()
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void FGLRenderer::DrawScene(int drawmode)
|
void GLSceneDrawer::DrawScene(int drawmode)
|
||||||
{
|
{
|
||||||
static int recursion=0;
|
static int recursion=0;
|
||||||
static int ssao_portals_available = 0;
|
static int ssao_portals_available = 0;
|
||||||
|
@ -498,17 +489,15 @@ void FGLRenderer::DrawScene(int drawmode)
|
||||||
ssao_portals_available--;
|
ssao_portals_available--;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLSceneDrawer drawer;
|
|
||||||
|
|
||||||
if (r_viewpoint.camera != nullptr)
|
if (r_viewpoint.camera != nullptr)
|
||||||
{
|
{
|
||||||
ActorRenderFlags savedflags = r_viewpoint.camera->renderflags;
|
ActorRenderFlags savedflags = r_viewpoint.camera->renderflags;
|
||||||
drawer.CreateScene();
|
CreateScene();
|
||||||
r_viewpoint.camera->renderflags = savedflags;
|
r_viewpoint.camera->renderflags = savedflags;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
drawer.CreateScene();
|
CreateScene();
|
||||||
}
|
}
|
||||||
GLRenderer->mClipPortal = NULL; // this must be reset before any portal recursion takes place.
|
GLRenderer->mClipPortal = NULL; // this must be reset before any portal recursion takes place.
|
||||||
|
|
||||||
|
@ -517,8 +506,8 @@ void FGLRenderer::DrawScene(int drawmode)
|
||||||
if (applySSAO && gl_RenderState.GetPassType() == GBUFFER_PASS)
|
if (applySSAO && gl_RenderState.GetPassType() == GBUFFER_PASS)
|
||||||
{
|
{
|
||||||
gl_RenderState.EnableDrawBuffers(1);
|
gl_RenderState.EnableDrawBuffers(1);
|
||||||
AmbientOccludeScene();
|
GLRenderer->AmbientOccludeScene();
|
||||||
mBuffers->BindSceneFB(true);
|
GLRenderer->mBuffers->BindSceneFB(true);
|
||||||
gl_RenderState.EnableDrawBuffers(gl_RenderState.GetPassDrawBufferCount());
|
gl_RenderState.EnableDrawBuffers(gl_RenderState.GetPassDrawBufferCount());
|
||||||
gl_RenderState.Apply();
|
gl_RenderState.Apply();
|
||||||
gl_RenderState.ApplyMatrices();
|
gl_RenderState.ApplyMatrices();
|
||||||
|
@ -732,7 +721,7 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector)
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void FGLRenderer::ProcessScene(bool toscreen)
|
void GLSceneDrawer::ProcessScene(bool toscreen)
|
||||||
{
|
{
|
||||||
FDrawInfo::StartDrawInfo();
|
FDrawInfo::StartDrawInfo();
|
||||||
iter_dlightf = iter_dlight = draw_dlight = draw_dlightf = 0;
|
iter_dlightf = iter_dlight = draw_dlight = draw_dlightf = 0;
|
||||||
|
@ -800,12 +789,14 @@ void FGLRenderer::SetFixedColormap (player_t *player)
|
||||||
|
|
||||||
sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen)
|
sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen)
|
||||||
{
|
{
|
||||||
|
GLSceneDrawer drawer;
|
||||||
|
|
||||||
sector_t * lviewsector;
|
sector_t * lviewsector;
|
||||||
mSceneClearColor[0] = 0.0f;
|
mSceneClearColor[0] = 0.0f;
|
||||||
mSceneClearColor[1] = 0.0f;
|
mSceneClearColor[1] = 0.0f;
|
||||||
mSceneClearColor[2] = 0.0f;
|
mSceneClearColor[2] = 0.0f;
|
||||||
R_SetupFrame (r_viewpoint, r_viewwindow, camera);
|
R_SetupFrame (r_viewpoint, r_viewwindow, camera);
|
||||||
SetViewArea();
|
drawer.SetViewArea();
|
||||||
|
|
||||||
// We have to scale the pitch to account for the pixel stretching, because the playsim doesn't know about this and treats it as 1:1.
|
// We have to scale the pitch to account for the pixel stretching, because the playsim doesn't know about this and treats it as 1:1.
|
||||||
double radPitch = r_viewpoint.Angles.Pitch.Normalized180().Radians();
|
double radPitch = r_viewpoint.Angles.Pitch.Normalized180().Radians();
|
||||||
|
@ -844,20 +835,20 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo
|
||||||
const s3d::EyePose * eye = stereo3dMode.getEyePose(eye_ix);
|
const s3d::EyePose * eye = stereo3dMode.getEyePose(eye_ix);
|
||||||
eye->SetUp();
|
eye->SetUp();
|
||||||
SetOutputViewport(bounds);
|
SetOutputViewport(bounds);
|
||||||
Set3DViewport(mainview);
|
drawer.Set3DViewport(mainview);
|
||||||
mDrawingScene2D = true;
|
mDrawingScene2D = true;
|
||||||
mCurrentFoV = fov;
|
mCurrentFoV = fov;
|
||||||
// Stereo mode specific perspective projection
|
// Stereo mode specific perspective projection
|
||||||
SetProjection( eye->GetProjection(fov, ratio, fovratio) );
|
drawer.SetProjection( eye->GetProjection(fov, ratio, fovratio) );
|
||||||
// SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper
|
// SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper
|
||||||
SetViewAngle(r_viewpoint.Angles.Yaw);
|
drawer.SetViewAngle(r_viewpoint.Angles.Yaw);
|
||||||
// Stereo mode specific viewpoint adjustment - temporarily shifts global ViewPos
|
// Stereo mode specific viewpoint adjustment - temporarily shifts global ViewPos
|
||||||
eye->GetViewShift(GLRenderer->mAngles.Yaw.Degrees, viewShift);
|
eye->GetViewShift(GLRenderer->mAngles.Yaw.Degrees, viewShift);
|
||||||
s3d::ScopedViewShifter viewShifter(viewShift);
|
s3d::ScopedViewShifter viewShifter(viewShift);
|
||||||
SetViewMatrix(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, false, false);
|
drawer.SetViewMatrix(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, false, false);
|
||||||
gl_RenderState.ApplyMatrices();
|
gl_RenderState.ApplyMatrices();
|
||||||
|
|
||||||
ProcessScene(toscreen);
|
drawer.ProcessScene(toscreen);
|
||||||
if (mainview && toscreen) EndDrawScene(lviewsector); // do not call this for camera textures.
|
if (mainview && toscreen) EndDrawScene(lviewsector); // do not call this for camera textures.
|
||||||
if (mainview && FGLRenderBuffers::IsEnabled())
|
if (mainview && FGLRenderBuffers::IsEnabled())
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "r_defs.h"
|
#include "r_defs.h"
|
||||||
#include "m_fixed.h"
|
#include "m_fixed.h"
|
||||||
#include "gl_clipper.h"
|
#include "gl_clipper.h"
|
||||||
|
#include "gl_portal.h"
|
||||||
|
|
||||||
class GLSceneDrawer
|
class GLSceneDrawer
|
||||||
{
|
{
|
||||||
|
@ -10,7 +11,9 @@ class GLSceneDrawer
|
||||||
|
|
||||||
subsector_t *currentsubsector; // used by the line processing code.
|
subsector_t *currentsubsector; // used by the line processing code.
|
||||||
sector_t *currentsector;
|
sector_t *currentsector;
|
||||||
|
|
||||||
|
void RenderMultipassStuff();
|
||||||
|
|
||||||
void UnclipSubsector(subsector_t *sub);
|
void UnclipSubsector(subsector_t *sub);
|
||||||
void AddLine (seg_t *seg, bool portalclip);
|
void AddLine (seg_t *seg, bool portalclip);
|
||||||
void PolySubsector(subsector_t * sub);
|
void PolySubsector(subsector_t * sub);
|
||||||
|
@ -22,11 +25,29 @@ class GLSceneDrawer
|
||||||
void DoSubsector(subsector_t * sub);
|
void DoSubsector(subsector_t * sub);
|
||||||
void RenderBSPNode(void *node);
|
void RenderBSPNode(void *node);
|
||||||
|
|
||||||
public:
|
void RenderScene(int recursion);
|
||||||
Clipper clipper;
|
void RenderTranslucent();
|
||||||
|
|
||||||
void CreateScene();
|
void CreateScene();
|
||||||
|
|
||||||
|
public:
|
||||||
|
GLSceneDrawer()
|
||||||
|
{
|
||||||
|
GLPortal::drawer = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Clipper clipper;
|
||||||
|
|
||||||
|
angle_t FrustumAngle();
|
||||||
|
void SetViewMatrix(float vx, float vy, float vz, bool mirror, bool planemirror);
|
||||||
|
void SetViewArea();
|
||||||
|
void SetupView(float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror);
|
||||||
|
void SetViewAngle(DAngle viewangle);
|
||||||
|
void SetProjection(VSMatrix matrix);
|
||||||
|
void Set3DViewport(bool mainview);
|
||||||
|
void DrawScene(int drawmode);
|
||||||
|
void ProcessScene(bool toscreen = false);
|
||||||
|
|
||||||
void InitClipper(angle_t a1, angle_t a2)
|
void InitClipper(angle_t a1, angle_t a2)
|
||||||
{
|
{
|
||||||
clipper.SafeAddClipRangeRealAngles(a1, a2);
|
clipper.SafeAddClipRangeRealAngles(a1, a2);
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
#include "gl/renderer/gl_lightdata.h"
|
#include "gl/renderer/gl_lightdata.h"
|
||||||
#include "gl/renderer/gl_renderstate.h"
|
#include "gl/renderer/gl_renderstate.h"
|
||||||
#include "gl/scene/gl_drawinfo.h"
|
#include "gl/scene/gl_drawinfo.h"
|
||||||
|
#include "gl/scene/gl_scenedrawer.h"
|
||||||
#include "gl/scene/gl_portal.h"
|
#include "gl/scene/gl_portal.h"
|
||||||
#include "gl/shaders/gl_shader.h"
|
#include "gl/shaders/gl_shader.h"
|
||||||
#include "gl/textures/gl_bitmap.h"
|
#include "gl/textures/gl_bitmap.h"
|
||||||
|
@ -519,7 +520,7 @@ void GLSkyPortal::DrawContents()
|
||||||
bool oldClamp = gl_RenderState.SetDepthClamp(true);
|
bool oldClamp = gl_RenderState.SetDepthClamp(true);
|
||||||
|
|
||||||
gl_MatrixStack.Push(gl_RenderState.mViewMatrix);
|
gl_MatrixStack.Push(gl_RenderState.mViewMatrix);
|
||||||
GLRenderer->SetupView(0, 0, 0, r_viewpoint.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
drawer->SetupView(0, 0, 0, r_viewpoint.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
||||||
|
|
||||||
gl_RenderState.SetVertexBuffer(GLRenderer->mSkyVBO);
|
gl_RenderState.SetVertexBuffer(GLRenderer->mSkyVBO);
|
||||||
if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox)
|
if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox)
|
||||||
|
|
Loading…
Reference in a new issue