Render the skies correctly on splitscreen in OpenGL mode

This commit is contained in:
MPC 2018-11-10 16:19:41 -03:00
parent c7e58b7cd5
commit eb4a72440a

View file

@ -3527,9 +3527,7 @@ static void HWR_Subsector(size_t num)
#ifndef POLYSKY #ifndef POLYSKY
// Moved here because before, when above the ceiling and the floor does not have the sky flat, it doesn't draw the sky // Moved here because before, when above the ceiling and the floor does not have the sky flat, it doesn't draw the sky
if (gr_frontsector->ceilingpic == skyflatnum || gr_frontsector->floorpic == skyflatnum) if (gr_frontsector->ceilingpic == skyflatnum || gr_frontsector->floorpic == skyflatnum)
{
drawsky = true; drawsky = true;
}
#endif #endif
#ifdef R_FAKEFLOORS #ifdef R_FAKEFLOORS
@ -5601,7 +5599,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
// ========================================================================== // ==========================================================================
// //
// ========================================================================== // ==========================================================================
static void HWR_DrawSkyBackground(player_t *player) static void HWR_DrawSkyBackground(void)
{ {
FOutVector v[4]; FOutVector v[4];
angle_t angle; angle_t angle;
@ -5609,18 +5607,18 @@ static void HWR_DrawSkyBackground(player_t *player)
float aspectratio; float aspectratio;
float angleturn; float angleturn;
// 3--2
// | /|
// |/ |
// 0--1
(void)player;
HWR_GetTexture(skytexture); HWR_GetTexture(skytexture);
aspectratio = (float)vid.width/(float)vid.height;
//Hurdler: the sky is the only texture who need 4.0f instead of 1.0 //Hurdler: the sky is the only texture who need 4.0f instead of 1.0
// because it's called just after clearing the screen // because it's called just after clearing the screen
// and thus, the near clipping plane is set to 3.99 // and thus, the near clipping plane is set to 3.99
// Sryder: Just use the near clipping plane value then // Sryder: Just use the near clipping plane value then
// 3--2
// | /|
// |/ |
// 0--1
v[0].x = v[3].x = -ZCLIP_PLANE-1; v[0].x = v[3].x = -ZCLIP_PLANE-1;
v[1].x = v[2].x = ZCLIP_PLANE+1; v[1].x = v[2].x = ZCLIP_PLANE+1;
v[0].y = v[1].y = -ZCLIP_PLANE-1; v[0].y = v[1].y = -ZCLIP_PLANE-1;
@ -5635,7 +5633,6 @@ 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 // 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]); angle = (dup_viewangle + gr_xtoviewangle[0]);
dimensionmultiply = ((float)textures[skytexture]->width/256.0f); dimensionmultiply = ((float)textures[skytexture]->width/256.0f);
v[0].sow = v[3].sow = ((float) angle / ((ANGLE_90-1)*dimensionmultiply)); v[0].sow = v[3].sow = ((float) angle / ((ANGLE_90-1)*dimensionmultiply));
@ -5643,10 +5640,13 @@ static void HWR_DrawSkyBackground(player_t *player)
// Y // Y
angle = aimingangle; angle = aimingangle;
aspectratio = (float)vid.width/(float)vid.height;
dimensionmultiply = ((float)textures[skytexture]->height/(128.0f*aspectratio)); dimensionmultiply = ((float)textures[skytexture]->height/(128.0f*aspectratio));
angleturn = (((float)ANGLE_45-1.0f)*aspectratio)*dimensionmultiply;
if (splitscreen)
{
dimensionmultiply *= 2;
angle *= 2;
}
// Middle of the sky should always be at angle 0 // Middle of the sky should always be at angle 0
// need to keep correct aspect ratio with X // need to keep correct aspect ratio with X
@ -5662,6 +5662,8 @@ static void HWR_DrawSkyBackground(player_t *player)
v[0].tow = v[1].tow = -(0.5f-(0.5f/dimensionmultiply)); v[0].tow = v[1].tow = -(0.5f-(0.5f/dimensionmultiply));
} }
angleturn = (((float)ANGLE_45-1.0f)*aspectratio)*dimensionmultiply;
if (angle > ANGLE_180) // Do this because we don't want the sky to suddenly teleport when crossing over 0 to 360 and vice versa if (angle > ANGLE_180) // Do this because we don't want the sky to suddenly teleport when crossing over 0 to 360 and vice versa
{ {
angle = InvAngle(angle); angle = InvAngle(angle);
@ -5825,12 +5827,8 @@ if (0)
HWD.pfnSetSpecialState(HWD_SET_FOG_MODE, 0); // Turn it off HWD.pfnSetSpecialState(HWD_SET_FOG_MODE, 0); // Turn it off
} }
#ifndef _NDS
if (drawsky) if (drawsky)
HWR_DrawSkyBackground(player); HWR_DrawSkyBackground();
#else
(void)HWR_DrawSkyBackground;
#endif
//Hurdler: it doesn't work in splitscreen mode //Hurdler: it doesn't work in splitscreen mode
drawsky = splitscreen; drawsky = splitscreen;
@ -6046,12 +6044,8 @@ if (0)
HWD.pfnSetSpecialState(HWD_SET_FOG_MODE, 0); // Turn it off HWD.pfnSetSpecialState(HWD_SET_FOG_MODE, 0); // Turn it off
} }
#ifndef _NDS
if (!skybox && drawsky) // Don't draw the regular sky if there's a skybox if (!skybox && drawsky) // Don't draw the regular sky if there's a skybox
HWR_DrawSkyBackground(player); HWR_DrawSkyBackground();
#else
(void)HWR_DrawSkyBackground;
#endif
//Hurdler: it doesn't work in splitscreen mode //Hurdler: it doesn't work in splitscreen mode
drawsky = splitscreen; drawsky = splitscreen;