From 4a23c4704d689a3cf262e8381fab88457786b74d Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Fri, 29 Dec 2017 14:50:16 -0500 Subject: [PATCH] Rendering fixes ahoy! - Fix squished sky in Software 3P/4P - Fix reversed sky in OpenGL Mirror Mode - Fix MD2 culling in Mirror Mode --- src/hardware/hw_main.c | 7 ++++++- src/hardware/hw_md2.c | 1 + src/hardware/r_opengl/r_opengl.c | 16 +++++++++------- src/r_sky.c | 5 ++++- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index be4fda78..094a5212 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5433,9 +5433,14 @@ static void HWR_DrawSkyBackground(player_t *player) // The only time this will probably be an issue is when a sky wider than 1024 is used as a sky AND a regular wall texture angle = (dup_viewangle + gr_xtoviewangle[0]); - dimensionmultiply = ((float)textures[skytexture]->width/256.0f); + if (atransform.mirror) + { + angle = InvAngle(angle); + dimensionmultiply *= -1; + } + v[0].sow = v[3].sow = ((float) angle / ((ANGLE_90-1)*dimensionmultiply)); v[2].sow = v[1].sow = (-1.0f/dimensionmultiply)+((float) angle / ((ANGLE_90-1)*dimensionmultiply)); diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 1e4cd528..d7e2ed66 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1523,6 +1523,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr) finalscale *= FIXED_TO_FLOAT(spr->mobj->scale); p.flip = atransform.flip; + p.mirror = atransform.mirror; HWD.pfnDrawMD2i(buff, curr, durs, tics, next, &p, finalscale, flip, color); } diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 71a003fe..7bab2dbc 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1874,14 +1874,16 @@ static void DrawMD2Ex(INT32 *gl_cmd_buffer, md2_frame_t *frame, INT32 duration, pglEnable(GL_CULL_FACE); - // pos->flip is if the screen is flipped too - if (flipped != pos->flip) // If either are active, but not both, invert the model's culling + // flipped is if the object is flipped + // pos->flip is if the screen is flipped vertically + // pos->mirror is if the screen is flipped horizontally + // XOR all the flips together to figure out what culling to use! { - pglCullFace(GL_FRONT); - } - else - { - pglCullFace(GL_BACK); + boolean reversecull = (flipped ^ pos->flip ^ pos->mirror); + if (reversecull) + pglCullFace(GL_FRONT); + else + pglCullFace(GL_BACK); } #ifndef KOS_GL_COMPATIBILITY diff --git a/src/r_sky.c b/src/r_sky.c index 5162518c..ede1df04 100644 --- a/src/r_sky.c +++ b/src/r_sky.c @@ -80,5 +80,8 @@ void R_SetupSkyDraw(void) void R_SetSkyScale(void) { fixed_t difference = vid.fdupx-(vid.dupx< 1) + scr *= 2; + skyscale = FixedDiv(scr, vid.fdupx+difference); }