Skip to content
Snippets Groups Projects
Commit b404f8cc authored by Ali Can Demiralp's avatar Ali Can Demiralp
Browse files

Attempt incorporating changes by github.com/thodaker for adding quadbuffer...

Attempt incorporating changes by github.com/thodaker for adding quadbuffer stereo support on OpenGL.
parent d547f4a5
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,11 @@ FDisplayClusterDeviceQuadBufferStereoOpenGL::~FDisplayClusterDeviceQuadBufferSte
{
}
bool FDisplayClusterDeviceQuadBufferStereoOpenGL::ShouldUseSeparateRenderTarget() const
{
return true;
}
void FDisplayClusterDeviceQuadBufferStereoOpenGL::SetSwapSyncPolicy(EDisplayClusterSwapSyncPolicy policy)
{
FScopeLock lock(&InternalsSyncScope);
......@@ -99,11 +104,52 @@ bool FDisplayClusterDeviceQuadBufferStereoOpenGL::Present(int32& InOutSyncInterv
// Linux implementation
//////////////////////////////////////////////////////////////////////////////////////////////
#if PLATFORM_LINUX
//@todo: Implementation for Linux
bool FDisplayClusterDeviceQuadBufferStereoOpenGL::Present(int32& InOutSyncInterval)
{
// Forward to default implementation (should be a black screen)
return FDisplayClusterDeviceBase::Present(InOutSyncInterval);
UE_LOG(LogDisplayClusterRender, Verbose, TEXT("FDisplayClusterDeviceQuadBufferStereoOpenGL::Present"));
const int halfSizeX = BackBuffSize.X / 2;
const int dstX1 = 0;
const int dstX2 = halfSizeX;
// Convert to left bottom origin and flip Y
const int dstY1 = ViewportSize.Y;
const int dstY2 = 0;
FOpenGLViewport* pOglViewport = static_cast<FOpenGLViewport*>(CurrentViewport->GetViewportRHI().GetReference());
check(pOglViewport);
FPlatformOpenGLContext* const pContext = pOglViewport->GetGLContext();
check(pContext);
const FTexture2DRHIRef& renderTargetTexture = CurrentViewport->GetRenderTargetTexture();
check(IsValidRef(renderTargetTexture));
GLuint nativeRenderTargetTexture = *reinterpret_cast<GLuint*>(renderTargetTexture->GetNativeResource());
glFramebufferTexture(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, nativeRenderTargetTexture, 0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, pContext->ViewportFramebuffer);
glReadBuffer(GL_COLOR_ATTACHMENT0);
glDrawBuffer(GL_BACK_LEFT);
glBlitFramebuffer(
0, 0, halfSizeX, BackBuffSize.Y,
dstX1, dstY1, dstX2, dstY2,
GL_COLOR_BUFFER_BIT,
GL_NEAREST);
glDrawBuffer(GL_BACK_RIGHT);
glBlitFramebuffer(
halfSizeX, 0, BackBuffSize.X, BackBuffSize.Y,
dstX1, dstY1, dstX2, dstY2,
GL_COLOR_BUFFER_BIT,
GL_NEAREST);
// Perform buffers swap logic
SwapBuffers(pOglViewport, InOutSyncInterval);
REPORT_GL_END_BUFFER_EVENT_FOR_FRAME_DUMP();
return false;
}
#endif
......
......@@ -16,6 +16,7 @@ public:
virtual ~FDisplayClusterDeviceQuadBufferStereoOpenGL();
protected:
virtual bool ShouldUseSeparateRenderTarget() const override;
virtual void SetSwapSyncPolicy(EDisplayClusterSwapSyncPolicy policy);
virtual bool Present(int32& InOutSyncInterval) override;
void SwapBuffers(FOpenGLViewport* pOglViewport, int32& InOutSyncInterval);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment