From 79046580d586df604aa30be88c0d3efc1ccc7e2d Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Tue, 27 Sep 2016 19:49:24 -0400 Subject: [PATCH] Partial implementation of row interlaced mode. --- src/gl/renderer/gl_renderbuffers.cpp | 20 ++++++++++++++++++++ src/gl/renderer/gl_renderbuffers.h | 2 ++ src/gl/stereo3d/gl_interleaved3d.cpp | 13 +++++-------- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index b2471e4b91..31fc36832f 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -576,6 +576,26 @@ void FGLRenderBuffers::BlitToEyeTexture(int eye) glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); } +void FGLRenderBuffers::BlitFromEyeTexture(int eye, GL_IRECT* box) +{ + glBindFramebuffer(GL_READ_FRAMEBUFFER, mEyeFBs[eye]); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mOutputFB); + if (box == nullptr) + box = &GLRenderer->mOutputLetterbox; + glBlitFramebuffer(0, 0, mWidth, mHeight, + box->left, box->top, box->width + box->left, box->height + box->top, + GL_COLOR_BUFFER_BIT, GL_NEAREST); + + if ((gl.flags & RFL_INVALIDATE_BUFFER) != 0) + { + GLenum attachments[2] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_STENCIL_ATTACHMENT }; + glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, 2, attachments); + } + + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); +} + void FGLRenderBuffers::BindEyeTexture(int eye, int texunit) { CreateEyeBuffers(eye); diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 4477718f4b..043cb88526 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -2,6 +2,7 @@ #define __GL_RENDERBUFFERS_H #include "gl/shaders/gl_shader.h" +#include "gl/renderer/gl_renderer.h" class FGLBloomTextureLevel { @@ -42,6 +43,7 @@ public: void BindOutputFB(); void BlitToEyeTexture(int eye); + void BlitFromEyeTexture(int eye, GL_IRECT* box); void BindEyeTexture(int eye, int texunit); void BindEyeFB(int eye, bool readBuffer = false); diff --git a/src/gl/stereo3d/gl_interleaved3d.cpp b/src/gl/stereo3d/gl_interleaved3d.cpp index c811e0d216..085efae51c 100644 --- a/src/gl/stereo3d/gl_interleaved3d.cpp +++ b/src/gl/stereo3d/gl_interleaved3d.cpp @@ -53,18 +53,15 @@ void RowInterleaved3D::Present() const // Compute screen regions to use for left and right eye views int topHeight = GLRenderer->mOutputLetterbox.height / 2; - int bottomHeight = GLRenderer->mOutputLetterbox.height - topHeight; GL_IRECT topHalfScreen = GLRenderer->mOutputLetterbox; topHalfScreen.height = topHeight; + topHalfScreen.top = topHeight; GL_IRECT bottomHalfScreen = GLRenderer->mOutputLetterbox; - bottomHalfScreen.height = bottomHeight; - bottomHalfScreen.top += topHeight; + bottomHalfScreen.height = topHeight; + bottomHalfScreen.top = 0; - GLRenderer->mBuffers->BindEyeTexture(0, 0); - GLRenderer->DrawPresentTexture(topHalfScreen, true); - - GLRenderer->mBuffers->BindEyeTexture(1, 0); - GLRenderer->DrawPresentTexture(bottomHalfScreen, true); + GLRenderer->mBuffers->BlitFromEyeTexture(0, &topHalfScreen); + GLRenderer->mBuffers->BlitFromEyeTexture(1, &bottomHalfScreen); }