mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
- test skyboxes with dynamic_cast and scale them properly.
This commit is contained in:
parent
217b80b1fb
commit
f7dd16ba16
8 changed files with 57 additions and 50 deletions
|
@ -44,7 +44,6 @@ FSkyBox::FSkyBox(const char *name)
|
|||
}
|
||||
else previous = nullptr;
|
||||
faces[0]=faces[1]=faces[2]=faces[3]=faces[4]=faces[5] = nullptr;
|
||||
bSkybox = true;
|
||||
fliptop = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,42 @@
|
|||
#pragma once
|
||||
|
||||
#include "textures.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Todo: Get rid of this
|
||||
// The faces can easily be stored in the material layer array
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class FSkyBox : public FImageTexture
|
||||
{
|
||||
public:
|
||||
|
||||
FGameTexture* previous;
|
||||
FGameTexture* faces[6]; // the faces need to be full materials as they can have all supported effects.
|
||||
bool fliptop;
|
||||
|
||||
FSkyBox(const char* name);
|
||||
void SetSize();
|
||||
|
||||
bool Is3Face() const
|
||||
{
|
||||
return faces[5] == nullptr;
|
||||
}
|
||||
|
||||
bool IsFlipped() const
|
||||
{
|
||||
return fliptop;
|
||||
}
|
||||
|
||||
FGameTexture* GetSkyFace(int num) const
|
||||
{
|
||||
return faces[num];
|
||||
}
|
||||
|
||||
bool GetSkyFlip() const
|
||||
{
|
||||
return fliptop;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -94,7 +94,6 @@ FTexture::FTexture (int lumpnum)
|
|||
bNoRemap0(false), bMasked(true), bAlphaTexture(false), bHasCanvas(false),
|
||||
Rotations(0xFFFF), SkyOffset(0), Width(0), Height(0)
|
||||
{
|
||||
bSkybox = false;
|
||||
bNoCompress = false;
|
||||
bTranslucent = -1;
|
||||
}
|
||||
|
|
|
@ -258,7 +258,6 @@ protected:
|
|||
uint8_t bAlphaTexture : 1; // Texture is an alpha channel without color information
|
||||
uint8_t bHasCanvas : 1; // Texture is based off FCanvasTexture
|
||||
|
||||
uint8_t bSkybox : 1; // is a cubic skybox
|
||||
int8_t bTranslucent : 2;
|
||||
|
||||
uint16_t Rotations;
|
||||
|
@ -447,35 +446,6 @@ enum
|
|||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Todo: Get rid of this
|
||||
// The faces can easily be stored in the material layer array
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class FSkyBox : public FImageTexture
|
||||
{
|
||||
public:
|
||||
|
||||
FGameTexture* previous;
|
||||
FGameTexture* faces[6]; // the faces need to be full materials as they can have all supported effects.
|
||||
bool fliptop;
|
||||
|
||||
FSkyBox(const char* name);
|
||||
void SetSize();
|
||||
|
||||
bool Is3Face() const
|
||||
{
|
||||
return faces[5] == nullptr;
|
||||
}
|
||||
|
||||
bool IsFlipped() const
|
||||
{
|
||||
return fliptop;
|
||||
}
|
||||
};
|
||||
|
||||
enum EGameTexFlags
|
||||
{
|
||||
GTexf_NoDecals = 1, // Decals should not stick to texture
|
||||
|
@ -644,7 +614,6 @@ public:
|
|||
|
||||
bool isUserContent() const;
|
||||
int CheckRealHeight() { return xs_RoundToInt(Base->CheckRealHeight() / ScaleY); }
|
||||
bool isSkybox() const { return Base->bSkybox; }
|
||||
void SetSize(int x, int y)
|
||||
{
|
||||
TexelWidth = x;
|
||||
|
@ -684,13 +653,6 @@ public:
|
|||
return Base->GetTranslucency();
|
||||
}
|
||||
|
||||
// Since these properties will later piggyback on existing members of FGameTexture, the accessors need to be here.
|
||||
FGameTexture *GetSkyFace(int num)
|
||||
{
|
||||
return (isSkybox() ? static_cast<FSkyBox*>(Base.get())->faces[num] : nullptr);
|
||||
}
|
||||
bool GetSkyFlip() { return isSkybox() ? static_cast<FSkyBox*>(Base.get())->fliptop : false; }
|
||||
|
||||
int GetClampMode(int clampmode)
|
||||
{
|
||||
if (GetUseType() == ETextureType::SWCanvas) clampmode = CLAMP_NOFILTER;
|
||||
|
|
|
@ -78,6 +78,7 @@
|
|||
#include "s_music.h"
|
||||
#include "animations.h"
|
||||
#include "texturemanager.h"
|
||||
#include "p_lnspec.h"
|
||||
|
||||
extern AActor *SpawnMapThing (int index, FMapThing *mthing, int position);
|
||||
|
||||
|
@ -188,9 +189,13 @@ static void PrecacheLevel(FLevelLocals *Level)
|
|||
|
||||
for (i = Level->sides.Size() - 1; i >= 0; i--)
|
||||
{
|
||||
AddToList(hitlist.Data(), Level->sides[i].GetTexture(side_t::top), FTextureManager::HIT_Wall);
|
||||
AddToList(hitlist.Data(), Level->sides[i].GetTexture(side_t::mid), FTextureManager::HIT_Wall);
|
||||
AddToList(hitlist.Data(), Level->sides[i].GetTexture(side_t::bottom), FTextureManager::HIT_Wall);
|
||||
auto &sd = Level->sides[i];
|
||||
int hitflag = FTextureManager::HIT_Wall;
|
||||
// Only precache skyboxes when this is actually used as a sky transfer.
|
||||
if (sd.linedef->sidedef[0] == &sd && sd.linedef->special == Static_Init && sd.linedef->args[1] == Init_TransferSky) hitflag |= FTextureManager::HIT_Sky;
|
||||
AddToList(hitlist.Data(), sd.GetTexture(side_t::top), hitflag);
|
||||
AddToList(hitlist.Data(), sd.GetTexture(side_t::mid), FTextureManager::HIT_Wall);
|
||||
AddToList(hitlist.Data(), sd.GetTexture(side_t::bottom), hitflag);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "hw_renderstate.h"
|
||||
#include "hw_material.h"
|
||||
|
||||
class FSkyBox;
|
||||
|
||||
struct HWSkyInfo
|
||||
{
|
||||
|
@ -358,7 +359,7 @@ struct HWSkyPortal : public HWPortal
|
|||
friend struct HWEEHorizonPortal;
|
||||
|
||||
void RenderRow(HWDrawInfo *di, FRenderState &state, EDrawType prim, int row, bool apply = true);
|
||||
void RenderBox(HWDrawInfo *di, FRenderState &state, FTextureID texno, FGameTexture * gltex, float x_offset, bool sky2);
|
||||
void RenderBox(HWDrawInfo *di, FRenderState &state, FTextureID texno, FSkyBox * gltex, float x_offset, bool sky2);
|
||||
void RenderDome(HWDrawInfo *di, FRenderState &state, FGameTexture * tex, float x_offset, float y_offset, bool mirror, int mode);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -93,12 +93,13 @@ void HWSkyPortal::RenderDome(HWDrawInfo *di, FRenderState &state, FGameTexture *
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HWSkyPortal::RenderBox(HWDrawInfo *di, FRenderState &state, FTextureID texno, FGameTexture * tex, float x_offset, bool sky2)
|
||||
void HWSkyPortal::RenderBox(HWDrawInfo *di, FRenderState &state, FTextureID texno, FSkyBox * tex, float x_offset, bool sky2)
|
||||
{
|
||||
int faces;
|
||||
|
||||
state.EnableModelMatrix(true);
|
||||
state.mModelMatrix.loadIdentity();
|
||||
state.mModelMatrix.scale(1, 1 / di->Level->info->pixelstretch, 1); // Undo the map's vertical scaling as skyboxes are true cubes.
|
||||
|
||||
if (!sky2)
|
||||
state.mModelMatrix.rotate(-180.0f+x_offset, di->Level->info->skyrotatevector.X, di->Level->info->skyrotatevector.Z, di->Level->info->skyrotatevector.Y);
|
||||
|
@ -171,9 +172,10 @@ void HWSkyPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
|
|||
di->SetupView(state, 0, 0, 0, !!(mState->MirrorFlag & 1), !!(mState->PlaneMirrorFlag & 1));
|
||||
|
||||
state.SetVertexBuffer(vertexBuffer);
|
||||
if (origin->texture[0] && origin->texture[0]->isSkybox())
|
||||
auto skybox = origin->texture[0] ? dynamic_cast<FSkyBox*>(origin->texture[0]->GetTexture()) : nullptr;
|
||||
if (skybox)
|
||||
{
|
||||
RenderBox(di, state, origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2);
|
||||
RenderBox(di, state, origin->skytexno1, skybox, origin->x_offset[0], origin->sky2);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -101,12 +101,12 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
|
|||
for (int i = 0; i<TexMan.NumTextures(); i++)
|
||||
{
|
||||
// HIT_Wall must be checked for MBF-style sky transfers.
|
||||
if (texhitlist[i] & (FTextureManager::HIT_Sky | FTextureManager::HIT_Wall))
|
||||
if (texhitlist[i] & (FTextureManager::HIT_Sky))
|
||||
{
|
||||
auto tex = TexMan.GameByIndex(i);
|
||||
if (tex->isSkybox())
|
||||
auto sb = dynamic_cast<FSkyBox*>(tex->GetTexture());
|
||||
if (sb)
|
||||
{
|
||||
FSkyBox *sb = static_cast<FSkyBox*>(tex->GetTexture());
|
||||
for (int i = 0; i<6; i++)
|
||||
{
|
||||
if (sb->faces[i])
|
||||
|
|
Loading…
Reference in a new issue