mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
- final cleanup of picanm code.
This commit is contained in:
parent
266364fc2e
commit
d6786cf0eb
6 changed files with 131 additions and 63 deletions
|
@ -177,7 +177,7 @@ void FGLRenderer::BindToFrameBuffer(FTexture *mat)
|
|||
if (BaseLayer == nullptr)
|
||||
{
|
||||
// must create the hardware texture first
|
||||
BaseLayer = new FHardwareTexture();
|
||||
BaseLayer = new ::FHardwareTexture();
|
||||
BaseLayer->CreateTexture(mat->GetTexelWidth()*4, mat->GetTexelHeight()*4, ::FHardwareTexture::TrueColor, false);
|
||||
mat->SetHardwareTexture(0, BaseLayer);
|
||||
}
|
||||
|
|
|
@ -470,10 +470,7 @@ void SaveEngineState()
|
|||
{
|
||||
fw->Write(&picanm[i], sizeof(picanm[i]));
|
||||
}
|
||||
for (int i = 0; i < MAXTILES; i++)
|
||||
{
|
||||
MREAD(&picanm[i], sizeof(picanm[i]), 1, fil);
|
||||
}
|
||||
WriteMagic(fw);
|
||||
|
||||
|
||||
fw->Write(&tailspritefree, sizeof(tailspritefree));
|
||||
|
@ -538,6 +535,11 @@ void LoadEngineState()
|
|||
fr.Read(prevspritestat, sizeof(prevspritestat));
|
||||
fr.Read(nextspritestat, sizeof(nextspritestat));
|
||||
CheckMagic(fr);
|
||||
for (int i = 0; i < MAXTILES; i++)
|
||||
{
|
||||
fr.Read(&picanm[i], sizeof(picanm[i]));
|
||||
}
|
||||
CheckMagic(fr);
|
||||
|
||||
fr.Read(&tailspritefree, sizeof(tailspritefree));
|
||||
fr.Read(&myconnectindex, sizeof(myconnectindex));
|
||||
|
|
|
@ -115,6 +115,7 @@ void FTileTexture::Create8BitPixels(uint8_t* buffer)
|
|||
FArtTile* GetTileTexture(const char* name, const TArray<uint8_t>& backingstore, uint32_t offset, int width, int height, int picanm)
|
||||
{
|
||||
auto tex = new FArtTile(backingstore, offset, width, height, picanm);
|
||||
|
||||
if (tex)
|
||||
{
|
||||
tex->SetName(name);
|
||||
|
@ -176,6 +177,10 @@ void BuildTiles::AddTiles (int firsttile, TArray<uint8_t>& RawData, bool permap)
|
|||
|
||||
auto tex = GetTileTexture("", RawData, uint32_t(tiledata - tiles), width, height, anm);
|
||||
AddTile(i, tex);
|
||||
int leftoffset, topoffset;
|
||||
auto PicAnim = tileConvertAnimFormat(anm, &leftoffset, &topoffset);
|
||||
tex->SetOffsets(leftoffset, topoffset);
|
||||
|
||||
tiledata += size;
|
||||
}
|
||||
}
|
||||
|
@ -597,7 +602,7 @@ void tileCopy(int tile, int source, int pal, int xoffset, int yoffset, int flags
|
|||
// Only modify the picanm info.
|
||||
tex = TileFiles.tiles[tile];
|
||||
if (!tex) return;
|
||||
picanm = &tex->PicAnim;
|
||||
picanm = &TileFiles.tiledata[tile].picanm;
|
||||
sourceanm = picanm;
|
||||
srcxo = tex->GetLeftOffset();
|
||||
srcyo = tex->GetTopOffset();
|
||||
|
@ -607,7 +612,7 @@ void tileCopy(int tile, int source, int pal, int xoffset, int yoffset, int flags
|
|||
if (source == -1) source = tile;
|
||||
tex = TileFiles.tiles[source];
|
||||
if (!tex) return;
|
||||
sourceanm = &tex->PicAnim;
|
||||
sourceanm = &TileFiles.tiledata[source].picanm;
|
||||
srcxo = tex->GetLeftOffset();
|
||||
srcyo = tex->GetTopOffset();
|
||||
|
||||
|
@ -623,7 +628,7 @@ void tileCopy(int tile, int source, int pal, int xoffset, int yoffset, int flags
|
|||
}
|
||||
}
|
||||
tex = new FLooseTile(buffer, tex->GetWidth(), tex->GetHeight());
|
||||
picanm = &tex->PicAnim;
|
||||
picanm = &TileFiles.tiledata[tile].picanm;
|
||||
TileFiles.AddTile(tile, tex);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,32 @@
|
|||
|
||||
#include "textures.h"
|
||||
|
||||
|
||||
// picanm[].sf:
|
||||
// |bit(1<<7)
|
||||
// |animtype|animtype|texhitscan|nofullbright|speed|speed|speed|speed|
|
||||
enum AnimFlags
|
||||
{
|
||||
PICANM_ANIMTYPE_NONE = 0,
|
||||
PICANM_ANIMTYPE_OSC = (1 << 6),
|
||||
PICANM_ANIMTYPE_FWD = (2 << 6),
|
||||
PICANM_ANIMTYPE_BACK = (3 << 6),
|
||||
|
||||
PICANM_ANIMTYPE_SHIFT = 6,
|
||||
PICANM_ANIMTYPE_MASK = (3 << 6), // must be 192
|
||||
PICANM_MISC_MASK = (3 << 4),
|
||||
PICANM_TEXHITSCAN_BIT = (2 << 4),
|
||||
PICANM_NOFULLBRIGHT_BIT = (1 << 4),
|
||||
PICANM_ANIMSPEED_MASK = 15, // must be 15
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MAXTILES = 30720,
|
||||
MAXUSERTILES = (MAXTILES-16) // reserve 16 tiles at the end
|
||||
|
||||
};
|
||||
|
||||
enum class ReplacementType : int
|
||||
{
|
||||
Art,
|
||||
|
@ -10,6 +36,28 @@ enum class ReplacementType : int
|
|||
Canvas
|
||||
};
|
||||
|
||||
|
||||
// NOTE: If the layout of this struct is changed, loadpics() must be modified
|
||||
// accordingly.
|
||||
struct picanm_t
|
||||
{
|
||||
uint8_t num; // animate number
|
||||
uint8_t sf; // anim. speed and flags
|
||||
uint8_t extra;
|
||||
|
||||
void Clear()
|
||||
{
|
||||
extra = sf = num = 0;
|
||||
}
|
||||
};
|
||||
picanm_t tileConvertAnimFormat(int32_t const picanmdisk, int* lo, int* to);
|
||||
|
||||
struct rottile_t
|
||||
{
|
||||
int16_t newtile;
|
||||
int16_t owner;
|
||||
};
|
||||
|
||||
struct HightileReplacement
|
||||
{
|
||||
FTexture* faces[6]; // only one gets used by a texture, the other 5 are for skyboxes only
|
||||
|
@ -45,7 +93,6 @@ public:
|
|||
: RawPixels(backingstore), Offset(offset)
|
||||
{
|
||||
SetSize(width, height);
|
||||
PicAnim = tileConvertAnimFormat(picanm, &leftoffset, &topoffset);
|
||||
}
|
||||
|
||||
const uint8_t* Get8BitPixels() override
|
||||
|
@ -358,7 +405,7 @@ struct PicAnm
|
|||
picanm_t& operator[](size_t index)
|
||||
{
|
||||
assert(index < MAXTILES);
|
||||
return TileFiles.tiles[index]->GetAnim();
|
||||
return TileFiles.tiledata[index].picanm;
|
||||
}
|
||||
};
|
||||
extern PicAnm picanm;
|
||||
|
@ -411,7 +458,7 @@ inline int heightBits(int num)
|
|||
inline rottile_t& RotTile(int tile)
|
||||
{
|
||||
assert(tile < MAXTILES);
|
||||
return TileFiles.tiles[tile]->GetRotTile();
|
||||
return TileFiles.tiledata[tile].RotTile;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,63 +41,71 @@
|
|||
#include "tarray.h"
|
||||
#include "palentry.h"
|
||||
|
||||
class FImageSource;
|
||||
class FTexture;
|
||||
class FHardwareTexture;
|
||||
class FImageSource;
|
||||
|
||||
// picanm[].sf:
|
||||
// |bit(1<<7)
|
||||
// |animtype|animtype|texhitscan|nofullbright|speed|speed|speed|speed|
|
||||
enum AnimFlags
|
||||
enum MaterialShaderIndex
|
||||
{
|
||||
PICANM_ANIMTYPE_NONE = 0,
|
||||
PICANM_ANIMTYPE_OSC = (1 << 6),
|
||||
PICANM_ANIMTYPE_FWD = (2 << 6),
|
||||
PICANM_ANIMTYPE_BACK = (3 << 6),
|
||||
|
||||
PICANM_ANIMTYPE_SHIFT = 6,
|
||||
PICANM_ANIMTYPE_MASK = (3 << 6), // must be 192
|
||||
PICANM_MISC_MASK = (3 << 4),
|
||||
PICANM_TEXHITSCAN_BIT = (2 << 4),
|
||||
PICANM_NOFULLBRIGHT_BIT = (1 << 4),
|
||||
PICANM_ANIMSPEED_MASK = 15, // must be 15
|
||||
SHADER_Default,
|
||||
SHADER_Warp1,
|
||||
SHADER_Warp2,
|
||||
SHADER_Brightmap,
|
||||
SHADER_Specular,
|
||||
SHADER_SpecularBrightmap,
|
||||
SHADER_PBR,
|
||||
SHADER_PBRBrightmap,
|
||||
SHADER_Paletted,
|
||||
SHADER_NoTexture,
|
||||
SHADER_BasicFuzz,
|
||||
SHADER_SmoothFuzz,
|
||||
SHADER_SwirlyFuzz,
|
||||
SHADER_TranslucentFuzz,
|
||||
SHADER_JaggedFuzz,
|
||||
SHADER_NoiseFuzz,
|
||||
SHADER_SmoothNoiseFuzz,
|
||||
SHADER_SoftwareFuzz,
|
||||
FIRST_USER_SHADER
|
||||
};
|
||||
|
||||
struct UserShaderDesc
|
||||
{
|
||||
FString shader;
|
||||
MaterialShaderIndex shaderType;
|
||||
FString defines;
|
||||
bool disablealphatest = false;
|
||||
};
|
||||
|
||||
extern TArray<UserShaderDesc> usershaders;
|
||||
|
||||
|
||||
struct FloatRect
|
||||
{
|
||||
float left,top;
|
||||
float width,height;
|
||||
|
||||
|
||||
void Offset(float xofs,float yofs)
|
||||
{
|
||||
left+=xofs;
|
||||
top+=yofs;
|
||||
}
|
||||
void Scale(float xfac,float yfac)
|
||||
{
|
||||
left*=xfac;
|
||||
width*=xfac;
|
||||
top*=yfac;
|
||||
height*=yfac;
|
||||
}
|
||||
};
|
||||
|
||||
enum ECreateTexBufferFlags
|
||||
{
|
||||
CTF_CheckHires = 1, // use external hires replacement if found
|
||||
CTF_Expand = 2, // create buffer with a one-pixel wide border
|
||||
CTF_ProcessData = 4, // run postprocessing on the generated buffer. This is only needed when using the data for a hardware texture.
|
||||
CTF_CheckOnly = 8, // Only runs the code to get a content ID but does not create a texture. Can be used to access a caching system for the hardware textures.
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MAXTILES = 30720,
|
||||
MAXUSERTILES = (MAXTILES-16) // reserve 16 tiles at the end
|
||||
|
||||
};
|
||||
|
||||
// NOTE: If the layout of this struct is changed, loadpics() must be modified
|
||||
// accordingly.
|
||||
struct picanm_t
|
||||
{
|
||||
uint8_t num; // animate number
|
||||
uint8_t sf; // anim. speed and flags
|
||||
uint8_t extra;
|
||||
|
||||
void Clear()
|
||||
{
|
||||
extra = sf = num = 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct rottile_t
|
||||
{
|
||||
int16_t newtile;
|
||||
int16_t owner;
|
||||
};
|
||||
|
||||
class FBitmap;
|
||||
struct FRemapTable;
|
||||
|
@ -113,23 +121,30 @@ class FMultipatchTextureBuilder;
|
|||
|
||||
extern int r_spriteadjustSW, r_spriteadjustHW;
|
||||
|
||||
picanm_t tileConvertAnimFormat(int32_t const picanmdisk, int *lo, int *to);
|
||||
|
||||
|
||||
class FNullTextureID : public FTextureID
|
||||
{
|
||||
public:
|
||||
FNullTextureID() : FTextureID(0) {}
|
||||
};
|
||||
|
||||
enum FTextureFormat : uint32_t
|
||||
{
|
||||
TEX_Pal,
|
||||
TEX_Gray,
|
||||
TEX_RGB, // Actually ARGB
|
||||
|
||||
TEX_Count
|
||||
};
|
||||
|
||||
class FSoftwareTexture;
|
||||
class FGLRenderState;
|
||||
|
||||
struct spriteframewithrotate;
|
||||
class FSerializer;
|
||||
namespace OpenGLRenderer
|
||||
{
|
||||
class FGLRenderState;
|
||||
class FHardwareTexture;
|
||||
}
|
||||
|
||||
union FContentIdBuilder
|
||||
|
@ -150,6 +165,7 @@ struct FTextureBuffer
|
|||
uint8_t *mBuffer = nullptr;
|
||||
int mWidth = 0;
|
||||
int mHeight = 0;
|
||||
uint64_t mContentId = 0; // unique content identifier. (Two images created from the same image source with the same settings will return the same value.)
|
||||
|
||||
FTextureBuffer() = default;
|
||||
|
||||
|
@ -164,6 +180,7 @@ struct FTextureBuffer
|
|||
mBuffer = other.mBuffer;
|
||||
mWidth = other.mWidth;
|
||||
mHeight = other.mHeight;
|
||||
mContentId = other.mContentId;
|
||||
other.mBuffer = nullptr;
|
||||
}
|
||||
|
||||
|
@ -172,6 +189,7 @@ struct FTextureBuffer
|
|||
mBuffer = other.mBuffer;
|
||||
mWidth = other.mWidth;
|
||||
mHeight = other.mHeight;
|
||||
mContentId = other.mContentId;
|
||||
other.mBuffer = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
@ -227,8 +245,6 @@ public:
|
|||
int GetDisplayLeftOffset() const { return leftoffset; }
|
||||
int GetDisplayTopOffset() const { return topoffset; }
|
||||
void SetOffsets(int x, int y) { leftoffset = x; topoffset = y; }
|
||||
picanm_t& GetAnim() { return PicAnim; } // This must be modifiable. There's quite a bit of code messing around with the flags in here.
|
||||
rottile_t& GetRotTile() { return RotTile; }
|
||||
FTextureBuffer CreateTexBuffer(const PalEntry *palette, int flags = 0);
|
||||
bool GetTranslucency();
|
||||
void CheckTrans(unsigned char * buffer, int size, int trans);
|
||||
|
@ -247,7 +263,6 @@ public:
|
|||
}
|
||||
|
||||
int alphaThreshold = 128;
|
||||
picanm_t PicAnim = {};
|
||||
FixedBitArray<256> NoBrightmapFlag{ 0 };
|
||||
|
||||
protected:
|
||||
|
@ -272,7 +287,6 @@ protected:
|
|||
struct { uint16_t Width, Height; };
|
||||
};
|
||||
int leftoffset = 0, topoffset = 0;
|
||||
rottile_t RotTile = { -1,-1 };
|
||||
uint8_t bMasked = true; // Texture (might) have holes
|
||||
int8_t bTranslucent = -1; // Does this texture have an active alpha channel?
|
||||
bool skyColorDone = false;
|
||||
|
|
|
@ -345,7 +345,7 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int
|
|||
}
|
||||
}
|
||||
#if 1
|
||||
if (!(tex->PicAnim.sf & PICANM_NOFULLBRIGHT_BIT) && !(globalflags & GLOBAL_NO_GL_FULLBRIGHT) && !tex->NoBrightmapFlag[usepalswap] && picnum > -1)
|
||||
if (picnum > -1 && !(TileFiles.tiledata[picnum].picanm.sf & PICANM_NOFULLBRIGHT_BIT) && !(globalflags & GLOBAL_NO_GL_FULLBRIGHT) && !tex->NoBrightmapFlag[usepalswap])
|
||||
{
|
||||
if (TextureType == TT_HICREPLACE)
|
||||
{
|
||||
|
@ -359,7 +359,7 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int
|
|||
}
|
||||
else
|
||||
{
|
||||
tex->PicAnim.sf |= PICANM_NOFULLBRIGHT_BIT;
|
||||
TileFiles.tiledata[picnum].picanm.sf |= PICANM_NOFULLBRIGHT_BIT;
|
||||
}
|
||||
}
|
||||
else if (TextureType == TT_TRUECOLOR)
|
||||
|
|
Loading…
Reference in a new issue