Skip to content

Commit

Permalink
DX9: Simplify some expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jan 26, 2020
1 parent 118e927 commit 41a6b97
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions GPU/Directx9/ShaderManagerDX9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,18 @@ void ShaderManagerDX9::VSSetMatrix(int creg, const float* pMatrix) {
static void ConvertProjMatrixToD3D(Matrix4x4 &in, bool invertedX, bool invertedY) {
// Half pixel offset hack
float xoff = 1.0f / gstate_c.curRTRenderWidth;
xoff = gstate_c.vpXOffset + (invertedX ? xoff : -xoff);
float yoff = -1.0f / gstate_c.curRTRenderHeight;
yoff = gstate_c.vpYOffset + (invertedY ? yoff : -yoff);
if (invertedX) {
xoff = -gstate_c.vpXOffset - xoff;
} else {
xoff = gstate_c.vpXOffset - xoff;
}

if (invertedX)
xoff = -xoff;
if (invertedY)
yoff = -yoff;
float yoff = -1.0f / gstate_c.curRTRenderHeight;
if (invertedY) {
yoff = gstate_c.vpYOffset - yoff;
} else {
yoff = -gstate_c.vpYOffset - yoff;
}

const Vec3 trans(xoff, yoff, gstate_c.vpZOffset * 0.5f + 0.5f);
const Vec3 scale(gstate_c.vpWidthScale, gstate_c.vpHeightScale, gstate_c.vpDepthScale * 0.5f);
Expand Down

0 comments on commit 41a6b97

Please sign in to comment.