Use flag to avoid second eye stereo color problem

This commit is contained in:
Christopher Bruns 2019-02-24 15:05:19 -08:00 committed by Christoph Oelckers
parent e83092a7eb
commit 051145b2c8
3 changed files with 14 additions and 9 deletions

View file

@ -674,4 +674,5 @@ void F2DDrawer::Clear()
mVertices.Clear();
mIndices.Clear();
mData.Clear();
mIsFirstPass = true;
}

View file

@ -144,6 +144,8 @@ public:
void AddPixel(int x1, int y1, int palcolor, uint32_t color);
void Clear();
bool mIsFirstPass = true;
};

View file

@ -102,9 +102,9 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state)
state.EnableMultisampling(false);
state.EnableLineSmooth(gl_aalines);
auto const &verticesBgra = drawer->mVertices;
auto const &indices = drawer->mIndices;
auto const &commands = drawer->mData;
auto &vertices = drawer->mVertices;
auto &indices = drawer->mIndices;
auto &commands = drawer->mData;
if (commands.Size() == 0)
{
@ -112,15 +112,16 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state)
return;
}
// copy vertices before modifying them, to avoid stereo 3d eye mismatch
auto verticesRgba = verticesBgra;
for (auto &v : verticesRgba)
if (drawer->mIsFirstPass)
{
// Change from BGRA to RGBA
std::swap(v.color0.r, v.color0.b);
for (auto &v : vertices)
{
// Change from BGRA to RGBA
std::swap(v.color0.r, v.color0.b);
}
}
F2DVertexBuffer vb;
vb.UploadData(&verticesRgba[0], verticesRgba.Size(), &indices[0], indices.Size());
vb.UploadData(&vertices[0], vertices.Size(), &indices[0], indices.Size());
state.SetVertexBuffer(&vb);
state.EnableFog(false);
@ -219,5 +220,6 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state)
state.SetTextureMode(TM_NORMAL);
state.EnableFog(false);
state.ResetColor();
drawer->mIsFirstPass = false;
twoD.Unclock();
}