Skip to content

Commit

Permalink
- fixed calculation of projection matrix for weapon sprites.
Browse files Browse the repository at this point in the history
- fixed color mask for green/magenta.
- fixed crash when initializing video, because it was accessing 'screen' before it was set from within the framebuffer's constructor.
  • Loading branch information
coelckers committed Jun 24, 2018
1 parent c3d5b96 commit 491898f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/gl/renderer/gl_stereo3d.cpp
Expand Up @@ -324,7 +324,7 @@ void FGLRenderer::PresentStereo()
return;

case VR_GREENMAGENTA:
PresentAnaglyph(false, true, true);
PresentAnaglyph(false, true, false);
break;

case VR_REDCYAN:
Expand Down
2 changes: 1 addition & 1 deletion src/gl/system/gl_framebuffer.cpp
Expand Up @@ -377,7 +377,7 @@ void OpenGLFrameBuffer::SetViewportRects(IntRect *bounds)
if (!bounds)
{
auto vrmode = VRMode::GetVRMode(true);
vrmode->AdjustViewport();
vrmode->AdjustViewport(this);
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/hwrenderer/utility/hw_vrmodes.cpp
Expand Up @@ -93,7 +93,7 @@ const VRMode *VRMode::GetVRMode(bool toscreen)
}
}

void VRMode::AdjustViewport() const
void VRMode::AdjustViewport(DFrameBuffer *screen) const
{
screen->mSceneViewport.height = (int)(screen->mSceneViewport.height * mVerticalViewportScale);
screen->mSceneViewport.top = (int)(screen->mSceneViewport.top * mVerticalViewportScale);
Expand All @@ -109,11 +109,11 @@ void VRMode::AdjustViewport() const
VSMatrix VRMode::GetHUDSpriteProjection() const
{
VSMatrix mat;
int w = screen->mScreenViewport.width;
int h = screen->mScreenViewport.height;
float scaled_w = w * mWeaponProjectionScale;
float left_ofs = (scaled_w - w) / 2.f;
mat.ortho(left_ofs, left_ofs + w, (float)h, 0, -1.0f, 1.0f);
int w = screen->GetWidth();
int h = screen->GetHeight();
float scaled_w = w / mWeaponProjectionScale;
float left_ofs = (w - scaled_w) / 2.f;
mat.ortho(left_ofs, left_ofs + scaled_w, (float)h, 0, -1.0f, 1.0f);
return mat;
}

Expand Down
3 changes: 2 additions & 1 deletion src/hwrenderer/utility/hw_vrmodes.h
Expand Up @@ -2,6 +2,7 @@

#include "r_data/matrix.h"

class DFrameBuffer;

enum
{
Expand Down Expand Up @@ -41,6 +42,6 @@ struct VRMode
VREyeInfo mEyes[2];

static const VRMode *GetVRMode(bool toscreen = true);
void AdjustViewport() const;
void AdjustViewport(DFrameBuffer *fb) const;
VSMatrix GetHUDSpriteProjection() const;
};

0 comments on commit 491898f

Please sign in to comment.