Swap front face culling for GL model drawer (CCW should be the default).

Added mirroring handling to software models.
This commit is contained in:
Marisa Kirisame 2018-06-03 02:27:28 +02:00 committed by Christoph Oelckers
parent a186677092
commit dea1d0259d
3 changed files with 10 additions and 2 deletions

View file

@ -65,7 +65,7 @@ void FGLModelRenderer::BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, con
if (!(actor->RenderStyle == LegacyRenderStyles[STYLE_Normal]) && !(smf->flags & MDL_DONTCULLBACKFACES)) if (!(actor->RenderStyle == LegacyRenderStyles[STYLE_Normal]) && !(smf->flags & MDL_DONTCULLBACKFACES))
{ {
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glFrontFace((mirrored ^ GLPortal::isMirrored()) ? GL_CW : GL_CCW); glFrontFace((mirrored ^ GLPortal::isMirrored()) ? GL_CCW : GL_CW);
} }
gl_RenderState.mModelMatrix = objectToWorldMatrix; gl_RenderState.mModelMatrix = objectToWorldMatrix;
@ -91,7 +91,7 @@ void FGLModelRenderer::BeginDrawHUDModel(AActor *actor, const VSMatrix &objectTo
if (!(actor->RenderStyle == LegacyRenderStyles[STYLE_Normal])) if (!(actor->RenderStyle == LegacyRenderStyles[STYLE_Normal]))
{ {
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glFrontFace((mirrored ^ GLPortal::isMirrored()) ? GL_CW : GL_CCW); glFrontFace((mirrored ^ GLPortal::isMirrored()) ? GL_CCW : GL_CW);
} }
gl_RenderState.mModelMatrix = objectToWorldMatrix; gl_RenderState.mModelMatrix = objectToWorldMatrix;

View file

@ -59,12 +59,14 @@ void PolyModelRenderer::BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, co
if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] || !!(smf->flags & MDL_DONTCULLBACKFACES)) if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] || !!(smf->flags & MDL_DONTCULLBACKFACES))
PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, true); PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, true);
PolyTriangleDrawer::SetCullCCW(Thread->DrawQueue, !mirrored);
} }
void PolyModelRenderer::EndDrawModel(AActor *actor, FSpriteModelFrame *smf) void PolyModelRenderer::EndDrawModel(AActor *actor, FSpriteModelFrame *smf)
{ {
if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] || !!(smf->flags & MDL_DONTCULLBACKFACES)) if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] || !!(smf->flags & MDL_DONTCULLBACKFACES))
PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, false); PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, false);
PolyTriangleDrawer::SetCullCCW(Thread->DrawQueue, true);
ModelActor = nullptr; ModelActor = nullptr;
} }
@ -107,6 +109,7 @@ void PolyModelRenderer::BeginDrawHUDModel(AActor *actor, const VSMatrix &objectT
if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal]) if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal])
PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, true); PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, true);
PolyTriangleDrawer::SetCullCCW(Thread->DrawQueue, !mirrored);
} }
void PolyModelRenderer::EndDrawHUDModel(AActor *actor) void PolyModelRenderer::EndDrawHUDModel(AActor *actor)
@ -116,6 +119,7 @@ void PolyModelRenderer::EndDrawHUDModel(AActor *actor)
if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal]) if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal])
PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, false); PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, false);
PolyTriangleDrawer::SetCullCCW(Thread->DrawQueue, true);
} }
void PolyModelRenderer::SetInterpolation(double interpolation) void PolyModelRenderer::SetInterpolation(double interpolation)

View file

@ -123,12 +123,14 @@ namespace swrenderer
if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] || !!(smf->flags & MDL_DONTCULLBACKFACES)) if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] || !!(smf->flags & MDL_DONTCULLBACKFACES))
PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, true); PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, true);
PolyTriangleDrawer::SetCullCCW(Thread->DrawQueue, !mirrored);
} }
void SWModelRenderer::EndDrawModel(AActor *actor, FSpriteModelFrame *smf) void SWModelRenderer::EndDrawModel(AActor *actor, FSpriteModelFrame *smf)
{ {
if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] || !!(smf->flags & MDL_DONTCULLBACKFACES)) if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] || !!(smf->flags & MDL_DONTCULLBACKFACES))
PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, false); PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, false);
PolyTriangleDrawer::SetCullCCW(Thread->DrawQueue, true);
ModelActor = nullptr; ModelActor = nullptr;
} }
@ -192,6 +194,7 @@ namespace swrenderer
if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal]) if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal])
PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, true); PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, true);
PolyTriangleDrawer::SetCullCCW(Thread->DrawQueue, !mirrored);
} }
void SWModelRenderer::EndDrawHUDModel(AActor *actor) void SWModelRenderer::EndDrawHUDModel(AActor *actor)
@ -201,6 +204,7 @@ namespace swrenderer
if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal]) if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal])
PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, false); PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, false);
PolyTriangleDrawer::SetCullCCW(Thread->DrawQueue, true);
} }
void SWModelRenderer::SetInterpolation(double interpolation) void SWModelRenderer::SetInterpolation(double interpolation)