mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- removed gl dependencies from gl_sky.cpp by moving some data into other places.
This commit is contained in:
parent
59477362d9
commit
cc926dec1e
9 changed files with 21 additions and 24 deletions
|
@ -155,8 +155,6 @@ public:
|
||||||
FTextureID glPart;
|
FTextureID glPart;
|
||||||
FTextureID mirrorTexture;
|
FTextureID mirrorTexture;
|
||||||
|
|
||||||
float mSky1Pos, mSky2Pos;
|
|
||||||
|
|
||||||
FRotator mAngles;
|
FRotator mAngles;
|
||||||
FVector2 mViewVector;
|
FVector2 mViewVector;
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,6 @@ int GLPortal::renderdepth;
|
||||||
int GLPortal::PlaneMirrorMode;
|
int GLPortal::PlaneMirrorMode;
|
||||||
GLuint GLPortal::QueryObject;
|
GLuint GLPortal::QueryObject;
|
||||||
|
|
||||||
int GLPortal::instack[2];
|
|
||||||
bool GLPortal::inskybox;
|
bool GLPortal::inskybox;
|
||||||
|
|
||||||
UniqueList<GLSkyInfo> UniqueSkies;
|
UniqueList<GLSkyInfo> UniqueSkies;
|
||||||
|
@ -442,7 +441,7 @@ void GLPortal::StartFrame()
|
||||||
if (renderdepth==0)
|
if (renderdepth==0)
|
||||||
{
|
{
|
||||||
inskybox=false;
|
inskybox=false;
|
||||||
instack[sector_t::floor]=instack[sector_t::ceiling]=0;
|
screen->instack[sector_t::floor] = screen->instack[sector_t::ceiling] = 0;
|
||||||
}
|
}
|
||||||
renderdepth++;
|
renderdepth++;
|
||||||
}
|
}
|
||||||
|
@ -743,7 +742,7 @@ void GLSectorStackPortal::DrawContents()
|
||||||
GLRenderer->mViewActor = NULL;
|
GLRenderer->mViewActor = NULL;
|
||||||
|
|
||||||
// avoid recursions!
|
// avoid recursions!
|
||||||
if (origin->plane != -1) instack[origin->plane]++;
|
if (origin->plane != -1) screen->instack[origin->plane]++;
|
||||||
|
|
||||||
drawer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
drawer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||||
SaveMapSection();
|
SaveMapSection();
|
||||||
|
@ -762,7 +761,7 @@ void GLSectorStackPortal::DrawContents()
|
||||||
drawer->DrawScene(DM_PORTAL);
|
drawer->DrawScene(DM_PORTAL);
|
||||||
RestoreMapSection();
|
RestoreMapSection();
|
||||||
|
|
||||||
if (origin->plane != -1) instack[origin->plane]--;
|
if (origin->plane != -1) screen->instack[origin->plane]--;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -789,7 +788,7 @@ void GLPlaneMirrorPortal::DrawContents()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// A plane mirror needs to flip the portal exclusion logic because inside the mirror, up is down and down is up.
|
// A plane mirror needs to flip the portal exclusion logic because inside the mirror, up is down and down is up.
|
||||||
std::swap(instack[sector_t::floor], instack[sector_t::ceiling]);
|
std::swap(screen->instack[sector_t::floor], screen->instack[sector_t::ceiling]);
|
||||||
|
|
||||||
int old_pm = PlaneMirrorMode;
|
int old_pm = PlaneMirrorMode;
|
||||||
|
|
||||||
|
@ -810,7 +809,7 @@ void GLPlaneMirrorPortal::DrawContents()
|
||||||
gl_RenderState.SetClipHeight(0.f, 0.f);
|
gl_RenderState.SetClipHeight(0.f, 0.f);
|
||||||
PlaneMirrorFlag--;
|
PlaneMirrorFlag--;
|
||||||
PlaneMirrorMode = old_pm;
|
PlaneMirrorMode = old_pm;
|
||||||
std::swap(instack[sector_t::floor], instack[sector_t::ceiling]);
|
std::swap(screen->instack[sector_t::floor], screen->instack[sector_t::ceiling]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLPlaneMirrorPortal::PushState()
|
void GLPlaneMirrorPortal::PushState()
|
||||||
|
|
|
@ -64,7 +64,6 @@ public:
|
||||||
static GLSceneDrawer *drawer;
|
static GLSceneDrawer *drawer;
|
||||||
static int PlaneMirrorMode;
|
static int PlaneMirrorMode;
|
||||||
static int inupperstack;
|
static int inupperstack;
|
||||||
static int instack[2];
|
|
||||||
static bool inskybox;
|
static bool inskybox;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -672,12 +672,6 @@ sector_t * GLSceneDrawer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, f
|
||||||
GLRenderer->mAngles.Pitch = (float)RAD2DEG(asin(angy / alen));
|
GLRenderer->mAngles.Pitch = (float)RAD2DEG(asin(angy / alen));
|
||||||
GLRenderer->mAngles.Roll.Degrees = r_viewpoint.Angles.Roll.Degrees;
|
GLRenderer->mAngles.Roll.Degrees = r_viewpoint.Angles.Roll.Degrees;
|
||||||
|
|
||||||
// Scroll the sky
|
|
||||||
GLRenderer->mSky1Pos = (double)fmod((double)screen->FrameTime * (double)level.skyspeed1, 1024.f) * 90./256.;
|
|
||||||
GLRenderer->mSky2Pos = (double)fmod((double)screen->FrameTime * (double)level.skyspeed2, 1024.f) * 90./256.;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (camera->player && camera->player-players==consoleplayer &&
|
if (camera->player && camera->player-players==consoleplayer &&
|
||||||
((camera->player->cheats & CF_CHASECAM) || (r_deathcamera && camera->health <= 0)) && camera==camera->player->mo)
|
((camera->player->cheats & CF_CHASECAM) || (r_deathcamera && camera->health <= 0)) && camera==camera->player->mo)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,9 +33,6 @@
|
||||||
#include "hwrenderer/utility/hw_lighting.h"
|
#include "hwrenderer/utility/hw_lighting.h"
|
||||||
#include "hwrenderer/textures/hw_material.h"
|
#include "hwrenderer/textures/hw_material.h"
|
||||||
|
|
||||||
#include "gl/renderer/gl_renderer.h"
|
|
||||||
#include "gl/scene/gl_portal.h"
|
|
||||||
|
|
||||||
CVAR(Bool,gl_noskyboxes, false, 0)
|
CVAR(Bool,gl_noskyboxes, false, 0)
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -76,7 +73,7 @@ void GLSkyInfo::init(int sky1, PalEntry FadeColor)
|
||||||
if (level.flags&LEVEL_DOUBLESKY)
|
if (level.flags&LEVEL_DOUBLESKY)
|
||||||
{
|
{
|
||||||
texture[1] = FMaterial::ValidateTexture(sky1texture, false, true);
|
texture[1] = FMaterial::ValidateTexture(sky1texture, false, true);
|
||||||
x_offset[1] = GLRenderer->mSky1Pos;
|
x_offset[1] = hw_sky1pos;
|
||||||
doublesky = true;
|
doublesky = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,13 +83,13 @@ void GLSkyInfo::init(int sky1, PalEntry FadeColor)
|
||||||
texture[0] = FMaterial::ValidateTexture(sky2texture, false, true);
|
texture[0] = FMaterial::ValidateTexture(sky2texture, false, true);
|
||||||
skytexno1 = sky2texture;
|
skytexno1 = sky2texture;
|
||||||
sky2 = true;
|
sky2 = true;
|
||||||
x_offset[0] = GLRenderer->mSky2Pos;
|
x_offset[0] = hw_sky2pos;
|
||||||
}
|
}
|
||||||
else if (!doublesky)
|
else if (!doublesky)
|
||||||
{
|
{
|
||||||
texture[0] = FMaterial::ValidateTexture(sky1texture, false, true);
|
texture[0] = FMaterial::ValidateTexture(sky1texture, false, true);
|
||||||
skytexno1 = sky1texture;
|
skytexno1 = sky1texture;
|
||||||
x_offset[0] = GLRenderer->mSky1Pos;
|
x_offset[0] = hw_sky1pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (level.skyfog > 0)
|
if (level.skyfog > 0)
|
||||||
|
@ -124,7 +121,8 @@ void GLWall::SkyPlane(HWDrawInfo *di, sector_t *sector, int plane, bool allowref
|
||||||
GLSkyInfo skyinfo;
|
GLSkyInfo skyinfo;
|
||||||
skyinfo.init(sector->sky, Colormap.FadeColor);
|
skyinfo.init(sector->sky, Colormap.FadeColor);
|
||||||
ptype = PORTALTYPE_SKY;
|
ptype = PORTALTYPE_SKY;
|
||||||
sky = UniqueSkies.Get(&skyinfo);
|
sky = &skyinfo;
|
||||||
|
PutPortal(di, ptype);
|
||||||
}
|
}
|
||||||
else if (sportal != nullptr)
|
else if (sportal != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -139,7 +137,7 @@ void GLWall::SkyPlane(HWDrawInfo *di, sector_t *sector, int plane, bool allowref
|
||||||
{
|
{
|
||||||
if (sector->PortalBlocksView(plane)) return;
|
if (sector->PortalBlocksView(plane)) return;
|
||||||
|
|
||||||
if (GLPortal::instack[1 - plane]) return;
|
if (screen->instack[1 - plane]) return;
|
||||||
ptype = PORTALTYPE_SECTORSTACK;
|
ptype = PORTALTYPE_SECTORSTACK;
|
||||||
portal = glport;
|
portal = glport;
|
||||||
}
|
}
|
||||||
|
@ -192,7 +190,7 @@ void GLWall::SkyLine(HWDrawInfo *di, sector_t *fs, line_t *line)
|
||||||
{
|
{
|
||||||
skyinfo.init(fs->sky, Colormap.FadeColor);
|
skyinfo.init(fs->sky, Colormap.FadeColor);
|
||||||
ptype = PORTALTYPE_SKY;
|
ptype = PORTALTYPE_SKY;
|
||||||
sky = UniqueSkies.Get(&skyinfo);
|
sky = &skyinfo;
|
||||||
}
|
}
|
||||||
ztop[0] = zceil[0];
|
ztop[0] = zceil[0];
|
||||||
ztop[1] = zceil[1];
|
ztop[1] = zceil[1];
|
||||||
|
|
|
@ -463,6 +463,7 @@ void FDrawInfo::AddPortal(GLWall *wall, int ptype)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PORTALTYPE_SKY:
|
case PORTALTYPE_SKY:
|
||||||
|
wall->sky = UniqueSkies.Get(wall->sky);
|
||||||
portal = GLPortal::FindPortal(wall->sky);
|
portal = GLPortal::FindPortal(wall->sky);
|
||||||
if (!portal) portal = new GLSkyPortal(wall->sky);
|
if (!portal) portal = new GLSkyPortal(wall->sky);
|
||||||
portal->AddLine(wall);
|
portal->AddLine(wall);
|
||||||
|
|
|
@ -51,6 +51,7 @@ bool skystretch;
|
||||||
|
|
||||||
fixed_t sky1cyl, sky2cyl;
|
fixed_t sky1cyl, sky2cyl;
|
||||||
double sky1pos, sky2pos;
|
double sky1pos, sky2pos;
|
||||||
|
float hw_sky1pos, hw_sky2pos;
|
||||||
|
|
||||||
CUSTOM_CVAR(Int, testskyoffset, 0, 0)
|
CUSTOM_CVAR(Int, testskyoffset, 0, 0)
|
||||||
{
|
{
|
||||||
|
@ -170,5 +171,10 @@ void R_UpdateSky (uint64_t mstime)
|
||||||
double ms = (double)mstime * FRACUNIT;
|
double ms = (double)mstime * FRACUNIT;
|
||||||
sky1pos = ms * level.skyspeed1;
|
sky1pos = ms * level.skyspeed1;
|
||||||
sky2pos = ms * level.skyspeed2;
|
sky2pos = ms * level.skyspeed2;
|
||||||
|
|
||||||
|
// The hardware renderer uses a different value range and clamps it to a single rotation
|
||||||
|
hw_sky1pos = (float)(fmod((double(mstime) * level.skyspeed1), 1024.) * (90. / 256.));
|
||||||
|
hw_sky2pos = (float)(fmod((double(mstime) * level.skyspeed2), 1024.) * (90. / 256.));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ extern FTextureID skyflatnum;
|
||||||
extern fixed_t sky1cyl, sky2cyl;
|
extern fixed_t sky1cyl, sky2cyl;
|
||||||
extern FTextureID sky1texture, sky2texture;
|
extern FTextureID sky1texture, sky2texture;
|
||||||
extern double sky1pos, sky2pos;
|
extern double sky1pos, sky2pos;
|
||||||
|
extern float hw_sky1pos, hw_sky2pos;
|
||||||
extern double skytexturemid;
|
extern double skytexturemid;
|
||||||
extern float skyiscale;
|
extern float skyiscale;
|
||||||
extern double skyscale;
|
extern double skyscale;
|
||||||
|
|
|
@ -327,6 +327,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int hwcaps = 0;
|
int hwcaps = 0;
|
||||||
|
int instack[2] = { 0,0 }; // this is globally maintained state for portal recursion avoidance.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DFrameBuffer (int width, int height, bool bgra);
|
DFrameBuffer (int width, int height, bool bgra);
|
||||||
|
|
Loading…
Reference in a new issue