From 46ffea94a456fe8e37f1c712b96e36a89b43f849 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 10 Oct 2019 19:30:05 +0200 Subject: [PATCH] - cleanup of gloadtile_art. --- source/build/include/polymost.h | 2 +- source/build/src/polymost.cpp | 25 +++++++++---------------- source/build/src/texcache.cpp | 5 ++--- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/source/build/include/polymost.h b/source/build/include/polymost.h index f24eb45b1..07e8a0af9 100644 --- a/source/build/include/polymost.h +++ b/source/build/include/polymost.h @@ -187,7 +187,7 @@ typedef struct pthtyp_t char skyface; } pthtyp; -extern void gloadtile_art(int32_t,int32_t,int32_t,int32_t,int32_t,pthtyp *,int32_t); +void gloadtile_art(int32_t dapic, int32_t dameth, pthtyp* pth, int32_t doalloc); extern int32_t gloadtile_hi(int32_t,int32_t,int32_t,hicreplctyp *,int32_t,pthtyp *,int32_t, polytintflags_t); extern int32_t globalnoeffect; diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index bb51f174d..d4932242c 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -674,11 +674,11 @@ void FlipNonSquareBlock(T* dst, const T* src, int x, int y, int srcpitch) } } -TArray emptiness; -static void gloadtile_art_indexed(int32_t dapic, int32_t dameth, pthtyp* pth, int32_t doalloc) +void gloadtile_art(int32_t dapic, int32_t dameth, pthtyp* pth, int32_t doalloc) { vec2_16_t const& tsizart = tilesiz[dapic]; vec2_t siz = { tsizart.x, tsizart.y }; + vec2_t ssiz = siz; //POGOTODO: npoty char npoty = 0; @@ -687,10 +687,10 @@ static void gloadtile_art_indexed(int32_t dapic, int32_t dameth, pthtyp* pth, in uint8_t *p = (uint8_t*)waloff[dapic]; if (!waloff[dapic]) { - emptiness.Resize(siz.x*siz.y); - memset(emptiness.Data(), 255, siz.x * siz.y); - p = emptiness.Data(); + static uint8_t pix = 255; + siz.x = siz.y = 1; + p = &pix; } { if (doalloc) @@ -698,7 +698,8 @@ static void gloadtile_art_indexed(int32_t dapic, int32_t dameth, pthtyp* pth, in assert(pth->glpic == nullptr); pth->glpic = GLInterface.NewTexture(); pth->glpic->CreateTexture(siz.x, siz.y, true, false); - pth->glpic->SetSampler(SamplerNoFilter); + pth->glpic->SetSampler((dameth & DAMETH_CLAMPED)? SamplerClampXY : SamplerRepeat); + polymost_setuptexture(pth->glpic, dameth, 0); } TArray flipped(siz.x*siz.y, true); @@ -712,17 +713,9 @@ static void gloadtile_art_indexed(int32_t dapic, int32_t dameth, pthtyp* pth, in pth->palnum = 0; pth->shade = 0; pth->effects = 0; - pth->flags = (PTH_HASALPHA|PTH_ONEBITALPHA) | (npoty*PTH_NPOTWALL) | PTH_INDEXED; + pth->flags = PTH_HASALPHA|PTH_ONEBITALPHA| PTH_INDEXED; pth->hicr = NULL; - pth->siz = siz; -} - -void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t dashade, int32_t dameth, pthtyp *pth, int32_t doalloc) -{ - if (dameth & PTH_INDEXED) - { - return gloadtile_art_indexed(dapic, dameth, pth, doalloc); - } + pth->siz = ssiz; } int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp *hicr, diff --git a/source/build/src/texcache.cpp b/source/build/src/texcache.cpp index 962c3ba4f..7ecabca8c 100644 --- a/source/build/src/texcache.cpp +++ b/source/build/src/texcache.cpp @@ -39,7 +39,7 @@ static pthtyp *texcache_tryart(int32_t const dapicnum, int32_t const dapalnum, i if (pth->flags & PTH_INVALIDATED) { pth->flags &= ~PTH_INVALIDATED; - gloadtile_art(dapicnum, searchpalnum, tintpalnum, dashade, dameth, pth, 0); + gloadtile_art(dapicnum, dameth, pth, 0); pth->palnum = dapalnum; } @@ -48,8 +48,7 @@ static pthtyp *texcache_tryart(int32_t const dapicnum, int32_t const dapalnum, i pth = (pthtyp *)Xcalloc(1,sizeof(pthtyp)); - gloadtile_art(dapicnum, searchpalnum, tintpalnum, dashade, dameth, pth, 1); - //thl.AddToCache(dapicnum, dapalnum, dameth); + gloadtile_art(dapicnum, dameth, pth, 1); pth->palnum = dapalnum; pth->next = texcache.list[j];