mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
- remove InitSoftwareSky
This commit is contained in:
parent
db295fae3a
commit
ebfa61514e
4 changed files with 95 additions and 65 deletions
|
@ -31,12 +31,7 @@
|
|||
#include "polyrenderer/scene/poly_light.h"
|
||||
|
||||
EXTERN_CVAR(Float, skyoffset)
|
||||
|
||||
extern double skytexturemid;
|
||||
extern float skyiscale;
|
||||
extern double skyscale;
|
||||
extern fixed_t sky1cyl, sky2cyl;
|
||||
|
||||
EXTERN_CVAR(Int, r_skymode)
|
||||
|
||||
PolySkyDome::PolySkyDome()
|
||||
{
|
||||
|
@ -292,6 +287,53 @@ static FSoftwareTexture *GetSWTex(FTextureID texid, bool allownull = true)
|
|||
|
||||
void PolySkySetup::Update()
|
||||
{
|
||||
double skytexturemid = 0.0;
|
||||
double skyscale = 0.0;
|
||||
float skyiscale = 0.0f;
|
||||
fixed_t sky1cyl = 0, sky2cyl = 0;
|
||||
|
||||
auto skytex1 = TexMan.GetPalettedTexture(sky1texture, true);
|
||||
auto skytex2 = TexMan.GetPalettedTexture(sky2texture, true);
|
||||
|
||||
if (skytex1)
|
||||
{
|
||||
FSoftwareTexture *sskytex1 = skytex1->GetSoftwareTexture();
|
||||
FSoftwareTexture *sskytex2 = skytex2->GetSoftwareTexture();
|
||||
skytexturemid = 0;
|
||||
int skyheight = skytex1->GetDisplayHeight();
|
||||
if (skyheight >= 128 && skyheight < 200)
|
||||
{
|
||||
skytexturemid = -28;
|
||||
}
|
||||
else if (skyheight > 200)
|
||||
{
|
||||
skytexturemid = (200 - skyheight) * sskytex1->GetScale().Y + ((r_skymode == 2 && !(level.flags & LEVEL_FORCETILEDSKY)) ? skytex1->GetSkyOffset() : 0);
|
||||
}
|
||||
|
||||
if (viewwidth != 0 && viewheight != 0)
|
||||
{
|
||||
skyiscale = float(r_Yaspect / freelookviewheight);
|
||||
skyscale = freelookviewheight / r_Yaspect;
|
||||
|
||||
skyiscale *= float(r_viewpoint.FieldOfView.Degrees / 90.);
|
||||
skyscale *= float(90. / r_viewpoint.FieldOfView.Degrees);
|
||||
}
|
||||
|
||||
if (skystretch)
|
||||
{
|
||||
skyscale *= (double)SKYSTRETCH_HEIGHT / skyheight;
|
||||
skyiscale *= skyheight / (float)SKYSTRETCH_HEIGHT;
|
||||
skytexturemid *= skyheight / (double)SKYSTRETCH_HEIGHT;
|
||||
}
|
||||
|
||||
// The standard Doom sky texture is 256 pixels wide, repeated 4 times over 360 degrees,
|
||||
// giving a total sky width of 1024 pixels. So if the sky texture is no wider than 1024,
|
||||
// we map it to a cylinder with circumfrence 1024. For larger ones, we use the width of
|
||||
// the texture as the cylinder's circumfrence.
|
||||
sky1cyl = MAX(sskytex1->GetWidth(), fixed_t(sskytex1->GetScale().X * 1024));
|
||||
sky2cyl = MAX(sskytex2->GetWidth(), fixed_t(sskytex2->GetScale().Y * 1024));
|
||||
}
|
||||
|
||||
FTextureID sky1tex, sky2tex;
|
||||
double frontdpos = 0, backdpos = 0;
|
||||
|
||||
|
|
|
@ -57,65 +57,8 @@
|
|||
CVAR(Bool, r_linearsky, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
||||
EXTERN_CVAR(Int, r_skymode)
|
||||
|
||||
|
||||
double skytexturemid;
|
||||
double skyscale;
|
||||
float skyiscale;
|
||||
fixed_t sky1cyl, sky2cyl;
|
||||
|
||||
void InitSoftwareSky()
|
||||
{
|
||||
auto skytex1 = TexMan.GetPalettedTexture(sky1texture, true);
|
||||
auto skytex2 = TexMan.GetPalettedTexture(sky2texture, true);
|
||||
|
||||
if (skytex1 == nullptr)
|
||||
return;
|
||||
|
||||
// Note: I don't think it is good that this stuff gets cached globally.
|
||||
// For something that only needs to be once per frame it is rather pointless and makes it hard to swap out the underlying textures based on user settings.
|
||||
FSoftwareTexture *sskytex1 = skytex1->GetSoftwareTexture();
|
||||
FSoftwareTexture *sskytex2 = skytex2->GetSoftwareTexture();
|
||||
skytexturemid = 0;
|
||||
int skyheight = skytex1->GetDisplayHeight();
|
||||
if (skyheight >= 128 && skyheight < 200)
|
||||
{
|
||||
skytexturemid = -28;
|
||||
}
|
||||
else if (skyheight > 200)
|
||||
{
|
||||
skytexturemid = (200 - skyheight) * sskytex1->GetScale().Y + ((r_skymode == 2 && !(level.flags & LEVEL_FORCETILEDSKY)) ? skytex1->GetSkyOffset() : 0);
|
||||
}
|
||||
|
||||
if (viewwidth != 0 && viewheight != 0)
|
||||
{
|
||||
skyiscale = float(r_Yaspect / freelookviewheight);
|
||||
skyscale = freelookviewheight / r_Yaspect;
|
||||
|
||||
skyiscale *= float(r_viewpoint.FieldOfView.Degrees / 90.);
|
||||
skyscale *= float(90. / r_viewpoint.FieldOfView.Degrees);
|
||||
}
|
||||
|
||||
if (skystretch)
|
||||
{
|
||||
skyscale *= (double)SKYSTRETCH_HEIGHT / skyheight;
|
||||
skyiscale *= skyheight / (float)SKYSTRETCH_HEIGHT;
|
||||
skytexturemid *= skyheight / (double)SKYSTRETCH_HEIGHT;
|
||||
}
|
||||
|
||||
// The standard Doom sky texture is 256 pixels wide, repeated 4 times over 360 degrees,
|
||||
// giving a total sky width of 1024 pixels. So if the sky texture is no wider than 1024,
|
||||
// we map it to a cylinder with circumfrence 1024. For larger ones, we use the width of
|
||||
// the texture as the cylinder's circumfrence.
|
||||
sky1cyl = MAX(sskytex1->GetWidth(), fixed_t(sskytex1->GetScale().X * 1024));
|
||||
sky2cyl = MAX(sskytex2->GetWidth(), fixed_t(sskytex2->GetScale().Y * 1024));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
|
||||
static FSoftwareTexture *GetSWTex(FTextureID texid, bool allownull = true)
|
||||
{
|
||||
auto tex = TexMan.GetPalettedTexture(texid, true);
|
||||
|
@ -127,6 +70,48 @@ namespace swrenderer
|
|||
RenderSkyPlane::RenderSkyPlane(RenderThread *thread)
|
||||
{
|
||||
Thread = thread;
|
||||
|
||||
auto skytex1 = TexMan.GetPalettedTexture(sky1texture, true);
|
||||
auto skytex2 = TexMan.GetPalettedTexture(sky2texture, true);
|
||||
|
||||
if (skytex1 == nullptr)
|
||||
return;
|
||||
|
||||
FSoftwareTexture *sskytex1 = skytex1->GetSoftwareTexture();
|
||||
FSoftwareTexture *sskytex2 = skytex2->GetSoftwareTexture();
|
||||
skytexturemid = 0;
|
||||
int skyheight = skytex1->GetDisplayHeight();
|
||||
if (skyheight >= 128 && skyheight < 200)
|
||||
{
|
||||
skytexturemid = -28;
|
||||
}
|
||||
else if (skyheight > 200)
|
||||
{
|
||||
skytexturemid = (200 - skyheight) * sskytex1->GetScale().Y + ((r_skymode == 2 && !(level.flags & LEVEL_FORCETILEDSKY)) ? skytex1->GetSkyOffset() : 0);
|
||||
}
|
||||
|
||||
if (viewwidth != 0 && viewheight != 0)
|
||||
{
|
||||
skyiscale = float(r_Yaspect / freelookviewheight);
|
||||
skyscale = freelookviewheight / r_Yaspect;
|
||||
|
||||
skyiscale *= float(r_viewpoint.FieldOfView.Degrees / 90.);
|
||||
skyscale *= float(90. / r_viewpoint.FieldOfView.Degrees);
|
||||
}
|
||||
|
||||
if (skystretch)
|
||||
{
|
||||
skyscale *= (double)SKYSTRETCH_HEIGHT / skyheight;
|
||||
skyiscale *= skyheight / (float)SKYSTRETCH_HEIGHT;
|
||||
skytexturemid *= skyheight / (double)SKYSTRETCH_HEIGHT;
|
||||
}
|
||||
|
||||
// The standard Doom sky texture is 256 pixels wide, repeated 4 times over 360 degrees,
|
||||
// giving a total sky width of 1024 pixels. So if the sky texture is no wider than 1024,
|
||||
// we map it to a cylinder with circumfrence 1024. For larger ones, we use the width of
|
||||
// the texture as the cylinder's circumfrence.
|
||||
sky1cyl = MAX(sskytex1->GetWidth(), fixed_t(sskytex1->GetScale().X * 1024));
|
||||
sky2cyl = MAX(sskytex2->GetWidth(), fixed_t(sskytex2->GetScale().Y * 1024));
|
||||
}
|
||||
|
||||
void RenderSkyPlane::Render(VisiblePlane *pl)
|
||||
|
|
|
@ -41,6 +41,11 @@ namespace swrenderer
|
|||
void DrawSkyColumnStripe(int start_x, int y1, int y2, double scale, double texturemid, double yrepeat);
|
||||
void DrawSkyColumn(int start_x, int y1, int y2);
|
||||
|
||||
double skytexturemid;
|
||||
double skyscale;
|
||||
float skyiscale;
|
||||
fixed_t sky1cyl, sky2cyl;
|
||||
|
||||
FSoftwareTexture *frontskytex = nullptr;
|
||||
FSoftwareTexture *backskytex = nullptr;
|
||||
angle_t skyflip = 0;
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
// [RH] Base blending values (for e.g. underwater)
|
||||
int BaseBlendR, BaseBlendG, BaseBlendB;
|
||||
float BaseBlendA;
|
||||
void InitSoftwareSky();
|
||||
|
||||
|
||||
|
||||
|
@ -87,7 +86,6 @@ SWSceneDrawer::~SWSceneDrawer()
|
|||
sector_t *SWSceneDrawer::RenderView(player_t *player)
|
||||
{
|
||||
// Avoid using the pixel buffer from the last frame
|
||||
InitSoftwareSky(); // do this here to avoid problems when texture modes are changed on the fly.
|
||||
FBTextureIndex = (FBTextureIndex + 1) % 2;
|
||||
auto &fbtex = FBTexture[FBTextureIndex];
|
||||
|
||||
|
|
Loading…
Reference in a new issue