mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
OpenGL: Fix sky drawing
sky positioning and scaling more correct compared to software.
This commit is contained in:
parent
ca0f0bf2fd
commit
bc0b5505a8
1 changed files with 36 additions and 23 deletions
|
@ -4355,7 +4355,7 @@ static void HWR_DrawSkyBackground(player_t *player)
|
|||
{
|
||||
FOutVector v[4];
|
||||
angle_t angle;
|
||||
float f;
|
||||
float dimensionmultiply;
|
||||
|
||||
// 3--2
|
||||
// | /|
|
||||
|
@ -4377,36 +4377,49 @@ static void HWR_DrawSkyBackground(player_t *player)
|
|||
|
||||
// X
|
||||
|
||||
if (textures[skytexture]->width > 256)
|
||||
angle = (angle_t)((float)(dup_viewangle + gr_xtoviewangle[0])
|
||||
/((float)textures[skytexture]->width/256.0f))
|
||||
%(ANGLE_90-1);
|
||||
else
|
||||
angle = (dup_viewangle + gr_xtoviewangle[0])%(ANGLE_90-1);
|
||||
// NOTE: This doesn't work right with texture widths greater than 1024
|
||||
// software doesn't draw any further than 1024 for skies anyway, but this doesn't overlap properly
|
||||
// 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
|
||||
|
||||
f = (float)((textures[skytexture]->width/2)
|
||||
* FIXED_TO_FLOAT(FINETANGENT((2048
|
||||
- ((INT32)angle>>(ANGLETOFINESHIFT + 1))) & FINEMASK)));
|
||||
angle = (dup_viewangle + gr_xtoviewangle[0]);
|
||||
|
||||
v[0].sow = v[3].sow = 0.22f+(f)/(textures[skytexture]->width/2);
|
||||
v[2].sow = v[1].sow = 0.22f+(f+(127))/(textures[skytexture]->width/2);
|
||||
dimensionmultiply = ((float)textures[skytexture]->width/256.0f);
|
||||
|
||||
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));
|
||||
|
||||
// Y
|
||||
angle = aimingangle;
|
||||
|
||||
float aspectratio = (float)vid.width/(float)vid.height;
|
||||
dimensionmultiply = ((float)textures[skytexture]->height/(128.0f*aspectratio));
|
||||
float angleturn = (((float)ANGLE_45-1.0f)*aspectratio)*dimensionmultiply;
|
||||
|
||||
if (textures[skytexture]->height > 256)
|
||||
angle = (angle_t)((float)(aimingangle)
|
||||
*(256.0f/(float)textures[skytexture]->height))
|
||||
%(ANGLE_90-1); // Just so that looking up and down scales right
|
||||
// Middle of the sky should always be at angle 0
|
||||
// need to keep correct aspect ratio with X
|
||||
if (atransform.flip)
|
||||
{
|
||||
// During vertical flip the sky should be flipped and it's y movement should also be flipped obviously
|
||||
v[3].tow = v[2].tow = -(0.5f-(0.5f/dimensionmultiply));
|
||||
v[0].tow = v[1].tow = (-1.0f/dimensionmultiply)-(0.5f-(0.5f/dimensionmultiply));
|
||||
}
|
||||
else
|
||||
angle = (aimingangle);
|
||||
{
|
||||
v[3].tow = v[2].tow = (-1.0f/dimensionmultiply)-(0.5f-(0.5f/dimensionmultiply));
|
||||
v[0].tow = v[1].tow = -(0.5f-(0.5f/dimensionmultiply));
|
||||
}
|
||||
|
||||
f = (float)((textures[skytexture]->height/2)
|
||||
* FIXED_TO_FLOAT(FINETANGENT((2048
|
||||
- ((INT32)angle>>(ANGLETOFINESHIFT + 1))) & FINEMASK)));
|
||||
|
||||
v[3].tow = v[2].tow = 0.22f+(f)/(textures[skytexture]->height/2);
|
||||
v[0].tow = v[1].tow = 0.22f+(f+(127))/(textures[skytexture]->height/2);
|
||||
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);
|
||||
v[3].tow = v[2].tow += ((float) angle / angleturn);
|
||||
v[0].tow = v[1].tow += ((float) angle / angleturn);
|
||||
}
|
||||
else
|
||||
{
|
||||
v[3].tow = v[2].tow -= ((float) angle / angleturn);
|
||||
v[0].tow = v[1].tow -= ((float) angle / angleturn);
|
||||
}
|
||||
|
||||
HWD.pfnDrawPolygon(NULL, v, 4, 0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue