mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-27 20:20:40 +00:00
- added a reverse tile map so that the tile manager can retrieve special info even when a tile texture is passed by object to the render code and not by index.
This commit is contained in:
parent
cbeb481d59
commit
db4850a028
6 changed files with 28 additions and 7 deletions
|
@ -2125,7 +2125,7 @@ int32_t enginePostInit(void)
|
|||
I_FatalError("No translucency table found.");
|
||||
|
||||
palettePostLoadTables();
|
||||
|
||||
TileFiles.SetupReverseTileMap();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,8 @@ FBitmap FTileTexture::GetBgraBitmap(const PalEntry* remap, int* ptrans)
|
|||
TArray<uint8_t> buffer;
|
||||
bmp.Create(Size.x, Size.y);
|
||||
const uint8_t* ppix = Get8BitPixels();
|
||||
if (!remap) remap = GPalette.BaseColors; // no remap was passed but this code needs a color table, so use the base.
|
||||
if (!remap)
|
||||
remap = GPalette.BaseColors; // no remap was passed but this code needs a color table, so use the base.
|
||||
if (!ppix)
|
||||
{
|
||||
// This is needed for tiles with a palette remap.
|
||||
|
@ -133,6 +134,7 @@ void BuildTiles::AddTile(int tilenum, FTexture* tex, bool permap)
|
|||
auto& array = permap ? AllMapTiles : AllTiles;
|
||||
array.Push(tex);
|
||||
tiles[tilenum] = tex;
|
||||
|
||||
if (!permap) tilesbak[tilenum] = tex;
|
||||
}
|
||||
|
||||
|
@ -634,6 +636,7 @@ void artClearMapArt(void)
|
|||
{
|
||||
TileFiles.CloseAllMapArt();
|
||||
memcpy(TileFiles.tiles, TileFiles.tilesbak, sizeof(TileFiles.tiles));
|
||||
TileFiles.SetupReverseTileMap();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -658,6 +661,7 @@ void artSetupMapArt(const char* filename)
|
|||
FStringf fullname("%s_%02d.art", filename, i);
|
||||
TileFiles.LoadArtFile(fullname, true);
|
||||
}
|
||||
TileFiles.SetupReverseTileMap();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -232,6 +232,7 @@ struct BuildTiles
|
|||
FTexture* tilesbak[MAXTILES];
|
||||
TMap<FString, FTexture*> textures;
|
||||
TArray<FString> addedArt;
|
||||
TMap<FTexture*, int> TextureToTile;
|
||||
|
||||
BuildTiles()
|
||||
{
|
||||
|
@ -267,6 +268,21 @@ struct BuildTiles
|
|||
{
|
||||
addedArt = std::move(art);
|
||||
}
|
||||
int GetTileIndex(FTexture* tex)
|
||||
{
|
||||
auto p = TextureToTile.CheckKey(tex);
|
||||
return p ? *p : -1;
|
||||
}
|
||||
|
||||
void SetupReverseTileMap()
|
||||
{
|
||||
TextureToTile.Clear();
|
||||
for (int i = 0; i < MAXTILES; i++)
|
||||
{
|
||||
if (tiles[i] != nullptr) TextureToTile.Insert(tiles[i], i);
|
||||
}
|
||||
|
||||
}
|
||||
FTexture* ValidateCustomTile(int tilenum, int type);
|
||||
int32_t artLoadFiles(const char* filename);
|
||||
uint8_t* tileMakeWritable(int num);
|
||||
|
|
|
@ -307,7 +307,7 @@ FTextureBuffer FTexture::CreateTexBuffer(const PalEntry * remap, int flags)
|
|||
|
||||
FBitmap bmp(buffer, W * 4, W, H);
|
||||
|
||||
int trans;
|
||||
int trans = -1;
|
||||
auto Pixels = GetBgraBitmap(remap, &trans);
|
||||
bmp.Blit(0, 0, Pixels);
|
||||
|
||||
|
|
|
@ -230,6 +230,7 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int
|
|||
auto& h = hictinting[palette];
|
||||
bool applytint = false;
|
||||
// Canvas textures must be treated like hightile replacements in the following code.
|
||||
if (picnum < 0) picnum = TileFiles.GetTileIndex(tex); // Allow getting replacements also when the texture is not passed by its tile number.
|
||||
auto rep = (picnum >= 0 && hw_hightile && !(h.f & HICTINT_ALWAYSUSEART)) ? TileFiles.FindReplacement(picnum, palette) : nullptr;
|
||||
if (rep || tex->GetUseType() == FTexture::Canvas)
|
||||
{
|
||||
|
@ -292,7 +293,7 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int
|
|||
}
|
||||
|
||||
// Also load additional layers needed for this texture.
|
||||
if (hw_detailmapping && hw_hightile)
|
||||
if (hw_detailmapping && hw_hightile && picnum > -1)
|
||||
{
|
||||
float detscalex = detscale, detscaley = detscale;
|
||||
if (!(method & DAMETH_MODEL))
|
||||
|
@ -325,7 +326,7 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int
|
|||
*/
|
||||
}
|
||||
}
|
||||
if (hw_glowmapping && hw_hightile)
|
||||
if (hw_glowmapping && hw_hightile && picnum > -1)
|
||||
{
|
||||
if (!(method & DAMETH_MODEL))
|
||||
{
|
||||
|
@ -344,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])
|
||||
if (!(tex->PicAnim.sf & PICANM_NOFULLBRIGHT_BIT) && !(globalflags & GLOBAL_NO_GL_FULLBRIGHT) && !tex->NoBrightmapFlag[usepalswap] && picnum > -1)
|
||||
{
|
||||
if (TextureType == TT_HICREPLACE)
|
||||
{
|
||||
|
|
|
@ -178,7 +178,7 @@ void GLInstance::Draw2D(F2DDrawer *drawer)
|
|||
curbasepal = (cmd.mRemapIndex >> 8) & 0xff;
|
||||
auto savedf = globalflags;
|
||||
if (curbasepal > 0) globalflags |= GLOBAL_NO_GL_FULLBRIGHT; // temp. hack to disable brightmaps.
|
||||
SetTexture(0, tex, cmd.mRemapIndex & 0xff, 4/*DAMETH_CLAMPED*/, cmd.mFlags & F2DDrawer::DTF_Wrap ? SamplerRepeat : SamplerClampXY);
|
||||
SetTexture(-1, tex, cmd.mRemapIndex & 0xff, 4/*DAMETH_CLAMPED*/, cmd.mFlags & F2DDrawer::DTF_Wrap ? SamplerRepeat : SamplerClampXY);
|
||||
curbasepal = saved;
|
||||
globalflags = savedf;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue