Skip to content

Commit

Permalink
Fixed|Cleanup: Other eye missing in anaglyph stereo mode
Browse files Browse the repository at this point in the history
GameWidget needs to be aware when rendering two views per frame
so that game view texture gets redrawn when the eye changes.
  • Loading branch information
skyjake committed Oct 2, 2016
1 parent 5bce3e7 commit ff53cf3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 31 deletions.
19 changes: 0 additions & 19 deletions doomsday/apps/client/src/ui/viewcompositor.cpp
Expand Up @@ -183,7 +183,6 @@ GLTextureFramebuffer const &ViewCompositor::gameView() const

void ViewCompositor::drawCompositedLayers()
{
//Rectanglei const conRect = R_ConsoleRect(d->playerNum);
Rectanglei const view3D = R_Console3DViewRect(d->playerNum);
auto const oldDisplayPlayer = displayPlayer;

Expand All @@ -192,31 +191,13 @@ void ViewCompositor::drawCompositedLayers()

R_UseViewPort(d->playerNum);

//ClientWindow::main().transform().

/*Rectangleui(de::max<duint>(0, conRect.left()),
de::max<duint>(0, conRect.top()),
conRect.width(),
conRect.height()) */
GLState::push()
.setAlphaTest(false)
.setBlend (false)
.setDepthTest(false)
.setCull (gl::None);
//.setViewport ();

// 3D world view (using the previously rendered texture).
//if (d->frameDrawable.isReady())
//{
// Set up the appropriate post-processing shader.

/*
d->uFrameTex = d->viewFramebuf.colorTexture();
d->uMvpMatrix = ClientWindow::main().root().projMatrix2D() *
Matrix4f::scaleThenTranslate(view3D.size(), view3D.topLeft);
d->frameDrawable.draw();*/
// }

d->postProcessing.update();
d->postProcessing.draw(ClientWindow::main().root().projMatrix2D() *
Matrix4f::scaleThenTranslate(view3D.size(), view3D.topLeft),
Expand Down
19 changes: 8 additions & 11 deletions doomsday/apps/client/src/ui/widgets/gamewidget.cpp
Expand Up @@ -50,6 +50,7 @@
#include <doomsday/console/exec.h>
#include <de/GLState>
#include <de/GLTextureFramebuffer>
#include <de/VRconfig>

/**
* Maximum number of milliseconds spent uploading textures at the beginning
Expand All @@ -63,6 +64,7 @@ using namespace de;
DENG2_PIMPL(GameWidget)
{
bool needFrames = true; // Rendering a new frame is necessary.
VRConfig::Eye lastFrameEye = VRConfig::NeitherEye;

Impl(Public *i) : Base(i) {}

Expand All @@ -73,6 +75,8 @@ DENG2_PIMPL(GameWidget)
*/
void renderGameViews()
{
lastFrameEye = ClientApp::vr().currentEye();

ClientApp::forLocalPlayers([] (ClientPlayer &player)
{
player.viewCompositor().renderGameView([] (int playerNum) {
Expand Down Expand Up @@ -106,15 +110,11 @@ DENG2_PIMPL(GameWidget)

void draw()
{
//bool cannotDraw = (self.isDisabled() || !GL_IsFullyInited());

/*if (renderWireframe || cannotDraw)
// If the eye changes, we will need to redraw the view.
if (ClientApp::vr().currentEye() != lastFrameEye)
{
// When rendering is wireframe mode, we must clear the screen
// before rendering a frame.
LIBGUI_GL.glClear(GL_COLOR_BUFFER_BIT);
}*/
//if (cannotDraw) return;
needFrames = true;
}

if (needFrames)
{
Expand All @@ -126,9 +126,6 @@ DENG2_PIMPL(GameWidget)
// and effects.
renderGameViews();

//R_RenderViewPorts(Player3DViewLayer);
//R_RenderViewPorts(ViewBorderLayer);

// End any open DGL sequence.
DGL_End();

Expand Down
2 changes: 2 additions & 0 deletions doomsday/sdk/libappfw/include/de/vr/vrconfig.h
Expand Up @@ -115,6 +115,8 @@ class LIBAPPFW_PUBLIC VRConfig
*/
void setCurrentEye(Eye eye);

Eye currentEye() const;

/**
* Enables or disables projection frustum shifting.
*
Expand Down
9 changes: 8 additions & 1 deletion doomsday/sdk/libappfw/src/vr/vrconfig.cpp
Expand Up @@ -14,7 +14,7 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
* http://www.gnu.org/licenses</small>
*/

#include "de/VRConfig"
Expand All @@ -25,6 +25,7 @@ namespace de {
DENG2_PIMPL(VRConfig)
{
StereoMode mode;
Eye currentEye = NeitherEye;
de::OculusRift ovr;
float screenDistance;
float ipd;
Expand Down Expand Up @@ -95,13 +96,19 @@ void VRConfig::setCurrentEye(Eye eye)
{
float eyePos = (eye == NeitherEye? 0 : eye == LeftEye? -1 : 1);

d->currentEye = eye;
d->eyeShift = d->mapUnitsPerMeter() * (eyePos - d->dominantEye) * 0.5 * d->ipd;
if (d->swapEyes)
{
d->eyeShift *= -1;
}
}

VRConfig::Eye VRConfig::currentEye() const
{
return d->currentEye;
}

void VRConfig::enableFrustumShift(bool enable)
{
d->frustumShift = enable;
Expand Down

0 comments on commit ff53cf3

Please sign in to comment.