mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
- moved all 'present' functions into FGLRenderer.
This list of functions contained half of the existing references to the global GLRenderer variable.
This commit is contained in:
parent
9f9d747a6b
commit
9b56f407dd
3 changed files with 76 additions and 62 deletions
|
@ -157,7 +157,7 @@ void FGLRenderer::Flush()
|
|||
FGLDebug::PushGroup("PresentEyes");
|
||||
// Note: This here is the ONLY place in the entire engine where the OpenGL dependent parts of the Stereo3D code need to be dealt with.
|
||||
// There's absolutely no need to create a overly complex class hierarchy for just this.
|
||||
GLRenderer->PresentStereo();
|
||||
PresentStereo();
|
||||
FGLDebug::PopGroup();
|
||||
}
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ void FGLRenderer::DrawPresentTexture(const IntRect &box, bool applyGamma)
|
|||
{
|
||||
glViewport(box.left, box.top, box.width, box.height);
|
||||
|
||||
GLRenderer->mBuffers->BindDitherTexture(1);
|
||||
mBuffers->BindDitherTexture(1);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
if (ViewportLinearScale())
|
||||
|
|
|
@ -37,6 +37,7 @@ class FCustomPostProcessShaders;
|
|||
class SWSceneDrawer;
|
||||
class GLViewpointBuffer;
|
||||
struct FRenderViewpoint;
|
||||
class FPresentShaderBase;
|
||||
#define NOQUEUE nullptr // just some token to be used as a placeholder
|
||||
|
||||
class FGLRenderer
|
||||
|
@ -106,6 +107,19 @@ public:
|
|||
void UpdateShadowMap();
|
||||
|
||||
void BindToFrameBuffer(FMaterial *mat);
|
||||
|
||||
private:
|
||||
|
||||
bool QuadStereoCheckInitialRenderContextState();
|
||||
void PresentAnaglyph(bool r, bool g, bool b);
|
||||
void PresentSideBySide();
|
||||
void PresentTopBottom();
|
||||
void prepareInterleavedPresent(FPresentShaderBase& shader);
|
||||
void PresentColumnInterleaved();
|
||||
void PresentRowInterleaved();
|
||||
void PresentCheckerInterleaved();
|
||||
void PresentQuadStereo();
|
||||
|
||||
};
|
||||
|
||||
#include "hwrenderer/scene/hw_fakeflat.h"
|
||||
|
|
|
@ -47,18 +47,18 @@ EXTERN_CVAR(Int, gl_dither_bpc)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void PresentAnaglyph(bool r, bool g, bool b)
|
||||
void FGLRenderer::PresentAnaglyph(bool r, bool g, bool b)
|
||||
{
|
||||
GLRenderer->mBuffers->BindOutputFB();
|
||||
GLRenderer->ClearBorders();
|
||||
mBuffers->BindOutputFB();
|
||||
ClearBorders();
|
||||
|
||||
glColorMask(r, g, b, 1);
|
||||
GLRenderer->mBuffers->BindEyeTexture(0, 0);
|
||||
GLRenderer->DrawPresentTexture(screen->mOutputLetterbox, true);
|
||||
mBuffers->BindEyeTexture(0, 0);
|
||||
DrawPresentTexture(screen->mOutputLetterbox, true);
|
||||
|
||||
glColorMask(!r, !g, !b, 1);
|
||||
GLRenderer->mBuffers->BindEyeTexture(1, 0);
|
||||
GLRenderer->DrawPresentTexture(screen->mOutputLetterbox, true);
|
||||
mBuffers->BindEyeTexture(1, 0);
|
||||
DrawPresentTexture(screen->mOutputLetterbox, true);
|
||||
|
||||
glColorMask(1, 1, 1, 1);
|
||||
}
|
||||
|
@ -69,10 +69,10 @@ static void PresentAnaglyph(bool r, bool g, bool b)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void PresentSideBySide()
|
||||
void FGLRenderer::PresentSideBySide()
|
||||
{
|
||||
GLRenderer->mBuffers->BindOutputFB();
|
||||
GLRenderer->ClearBorders();
|
||||
mBuffers->BindOutputFB();
|
||||
ClearBorders();
|
||||
|
||||
// Compute screen regions to use for left and right eye views
|
||||
int leftWidth = screen->mOutputLetterbox.width / 2;
|
||||
|
@ -83,11 +83,11 @@ static void PresentSideBySide()
|
|||
rightHalfScreen.width = rightWidth;
|
||||
rightHalfScreen.left += leftWidth;
|
||||
|
||||
GLRenderer->mBuffers->BindEyeTexture(0, 0);
|
||||
GLRenderer->DrawPresentTexture(leftHalfScreen, true);
|
||||
mBuffers->BindEyeTexture(0, 0);
|
||||
DrawPresentTexture(leftHalfScreen, true);
|
||||
|
||||
GLRenderer->mBuffers->BindEyeTexture(1, 0);
|
||||
GLRenderer->DrawPresentTexture(rightHalfScreen, true);
|
||||
mBuffers->BindEyeTexture(1, 0);
|
||||
DrawPresentTexture(rightHalfScreen, true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,10 +97,10 @@ static void PresentSideBySide()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void PresentTopBottom()
|
||||
void FGLRenderer::PresentTopBottom()
|
||||
{
|
||||
GLRenderer->mBuffers->BindOutputFB();
|
||||
GLRenderer->ClearBorders();
|
||||
mBuffers->BindOutputFB();
|
||||
ClearBorders();
|
||||
|
||||
// Compute screen regions to use for left and right eye views
|
||||
int topHeight = screen->mOutputLetterbox.height / 2;
|
||||
|
@ -112,11 +112,11 @@ static void PresentTopBottom()
|
|||
bottomHalfScreen.height = bottomHeight;
|
||||
bottomHalfScreen.top = 0;
|
||||
|
||||
GLRenderer->mBuffers->BindEyeTexture(0, 0);
|
||||
GLRenderer->DrawPresentTexture(topHalfScreen, true);
|
||||
mBuffers->BindEyeTexture(0, 0);
|
||||
DrawPresentTexture(topHalfScreen, true);
|
||||
|
||||
GLRenderer->mBuffers->BindEyeTexture(1, 0);
|
||||
GLRenderer->DrawPresentTexture(bottomHalfScreen, true);
|
||||
mBuffers->BindEyeTexture(1, 0);
|
||||
DrawPresentTexture(bottomHalfScreen, true);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -125,15 +125,15 @@ static void PresentTopBottom()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void prepareInterleavedPresent(FPresentShaderBase& shader)
|
||||
void FGLRenderer::prepareInterleavedPresent(FPresentShaderBase& shader)
|
||||
{
|
||||
GLRenderer->mBuffers->BindOutputFB();
|
||||
GLRenderer->ClearBorders();
|
||||
mBuffers->BindOutputFB();
|
||||
ClearBorders();
|
||||
|
||||
|
||||
// Bind each eye texture, for composition in the shader
|
||||
GLRenderer->mBuffers->BindEyeTexture(0, 0);
|
||||
GLRenderer->mBuffers->BindEyeTexture(1, 1);
|
||||
mBuffers->BindEyeTexture(0, 0);
|
||||
mBuffers->BindEyeTexture(1, 1);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
|
@ -148,7 +148,7 @@ static void prepareInterleavedPresent(FPresentShaderBase& shader)
|
|||
|
||||
shader.Bind(NOQUEUE);
|
||||
|
||||
if (GLRenderer->framebuffer->IsHWGammaActive())
|
||||
if (framebuffer->IsHWGammaActive())
|
||||
{
|
||||
shader.Uniforms->InvGamma = 1.0f;
|
||||
shader.Uniforms->Contrast = 1.0f;
|
||||
|
@ -165,8 +165,8 @@ static void prepareInterleavedPresent(FPresentShaderBase& shader)
|
|||
}
|
||||
shader.Uniforms->ColorScale = (gl_dither_bpc == -1) ? 255.0f : (float)((1 << gl_dither_bpc) - 1);
|
||||
shader.Uniforms->Scale = {
|
||||
screen->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(),
|
||||
screen->mScreenViewport.height / (float)GLRenderer->mBuffers->GetHeight()
|
||||
screen->mScreenViewport.width / (float)mBuffers->GetWidth(),
|
||||
screen->mScreenViewport.height / (float)mBuffers->GetHeight()
|
||||
};
|
||||
shader.Uniforms.Set();
|
||||
}
|
||||
|
@ -177,11 +177,11 @@ static void prepareInterleavedPresent(FPresentShaderBase& shader)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void PresentColumnInterleaved()
|
||||
void FGLRenderer::PresentColumnInterleaved()
|
||||
{
|
||||
FGLPostProcessState savedState;
|
||||
savedState.SaveTextureBindings(2);
|
||||
prepareInterleavedPresent(*GLRenderer->mPresent3dColumnShader);
|
||||
prepareInterleavedPresent(*mPresent3dColumnShader);
|
||||
|
||||
// Compute absolute offset from top of screen to top of current display window
|
||||
// because we need screen-relative, not window-relative, scan line parity
|
||||
|
@ -191,10 +191,10 @@ static void PresentColumnInterleaved()
|
|||
//auto windowHOffset = clientoffset.X % 2;
|
||||
int windowHOffset = 0;
|
||||
|
||||
GLRenderer->mPresent3dColumnShader->Uniforms->WindowPositionParity = windowHOffset;
|
||||
GLRenderer->mPresent3dColumnShader->Uniforms.Set();
|
||||
mPresent3dColumnShader->Uniforms->WindowPositionParity = windowHOffset;
|
||||
mPresent3dColumnShader->Uniforms.Set();
|
||||
|
||||
GLRenderer->RenderScreenQuad();
|
||||
RenderScreenQuad();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -203,24 +203,24 @@ static void PresentColumnInterleaved()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void PresentRowInterleaved()
|
||||
void FGLRenderer::PresentRowInterleaved()
|
||||
{
|
||||
FGLPostProcessState savedState;
|
||||
savedState.SaveTextureBindings(2);
|
||||
prepareInterleavedPresent(*GLRenderer->mPresent3dRowShader);
|
||||
prepareInterleavedPresent(*mPresent3dRowShader);
|
||||
|
||||
// Todo:
|
||||
//auto clientoffset = screen->GetClientOffset();
|
||||
//auto windowVOffset = clientoffset.Y % 2;
|
||||
int windowVOffset = 0;
|
||||
|
||||
GLRenderer->mPresent3dRowShader->Uniforms->WindowPositionParity =
|
||||
mPresent3dRowShader->Uniforms->WindowPositionParity =
|
||||
(windowVOffset
|
||||
+ screen->mOutputLetterbox.height + 1 // +1 because of origin at bottom
|
||||
) % 2;
|
||||
|
||||
GLRenderer->mPresent3dRowShader->Uniforms.Set();
|
||||
GLRenderer->RenderScreenQuad();
|
||||
mPresent3dRowShader->Uniforms.Set();
|
||||
RenderScreenQuad();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -229,11 +229,11 @@ static void PresentRowInterleaved()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void PresentCheckerInterleaved()
|
||||
void FGLRenderer::PresentCheckerInterleaved()
|
||||
{
|
||||
FGLPostProcessState savedState;
|
||||
savedState.SaveTextureBindings(2);
|
||||
prepareInterleavedPresent(*GLRenderer->mPresent3dCheckerShader);
|
||||
prepareInterleavedPresent(*mPresent3dCheckerShader);
|
||||
|
||||
// Compute absolute offset from top of screen to top of current display window
|
||||
// because we need screen-relative, not window-relative, scan line parity
|
||||
|
@ -244,14 +244,14 @@ static void PresentCheckerInterleaved()
|
|||
int windowHOffset = 0;
|
||||
int windowVOffset = 0;
|
||||
|
||||
GLRenderer->mPresent3dCheckerShader->Uniforms->WindowPositionParity =
|
||||
mPresent3dCheckerShader->Uniforms->WindowPositionParity =
|
||||
(windowVOffset
|
||||
+ windowHOffset
|
||||
+ screen->mOutputLetterbox.height + 1 // +1 because of origin at bottom
|
||||
) % 2; // because we want the top pixel offset, but gl_FragCoord.y is the bottom pixel offset
|
||||
|
||||
GLRenderer->mPresent3dCheckerShader->Uniforms.Set();
|
||||
GLRenderer->RenderScreenQuad();
|
||||
mPresent3dCheckerShader->Uniforms.Set();
|
||||
RenderScreenQuad();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -260,12 +260,12 @@ static void PresentCheckerInterleaved()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
bool QuadStereoCheckInitialRenderContextState()
|
||||
bool FGLRenderer::QuadStereoCheckInitialRenderContextState()
|
||||
{
|
||||
// Keep trying until we see at least one good OpenGL context to render to
|
||||
static bool bQuadStereoSupported = false;
|
||||
static bool bDecentContextWasFound = false;
|
||||
static int contextCheckCount = 0;
|
||||
bool bQuadStereoSupported = false;
|
||||
bool bDecentContextWasFound = false;
|
||||
int contextCheckCount = 0;
|
||||
if ((!bDecentContextWasFound) && (contextCheckCount < 200))
|
||||
{
|
||||
contextCheckCount += 1;
|
||||
|
@ -290,30 +290,30 @@ bool QuadStereoCheckInitialRenderContextState()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void PresentQuadStereo()
|
||||
void FGLRenderer::PresentQuadStereo()
|
||||
{
|
||||
if (QuadStereoCheckInitialRenderContextState())
|
||||
{
|
||||
GLRenderer->mBuffers->BindOutputFB();
|
||||
mBuffers->BindOutputFB();
|
||||
|
||||
glDrawBuffer(GL_BACK_LEFT);
|
||||
GLRenderer->ClearBorders();
|
||||
GLRenderer->mBuffers->BindEyeTexture(0, 0);
|
||||
GLRenderer->DrawPresentTexture(screen->mOutputLetterbox, true);
|
||||
ClearBorders();
|
||||
mBuffers->BindEyeTexture(0, 0);
|
||||
DrawPresentTexture(screen->mOutputLetterbox, true);
|
||||
|
||||
glDrawBuffer(GL_BACK_RIGHT);
|
||||
GLRenderer->ClearBorders();
|
||||
GLRenderer->mBuffers->BindEyeTexture(1, 0);
|
||||
GLRenderer->DrawPresentTexture(screen->mOutputLetterbox, true);
|
||||
ClearBorders();
|
||||
mBuffers->BindEyeTexture(1, 0);
|
||||
DrawPresentTexture(screen->mOutputLetterbox, true);
|
||||
|
||||
glDrawBuffer(GL_BACK);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLRenderer->mBuffers->BindOutputFB();
|
||||
GLRenderer->ClearBorders();
|
||||
GLRenderer->mBuffers->BindEyeTexture(0, 0);
|
||||
GLRenderer->DrawPresentTexture(screen->mOutputLetterbox, true);
|
||||
mBuffers->BindOutputFB();
|
||||
ClearBorders();
|
||||
mBuffers->BindEyeTexture(0, 0);
|
||||
DrawPresentTexture(screen->mOutputLetterbox, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue