- more trivial adjustments.

This commit is contained in:
Christoph Oelckers 2020-05-24 00:38:10 +02:00
parent 00e7b2fa25
commit da26d1cec4
12 changed files with 81 additions and 53 deletions

View file

@ -46,8 +46,8 @@ VPXTexture::VPXTexture() {}
void VPXTexture::SetFrame(const void *data_, int width, int height) void VPXTexture::SetFrame(const void *data_, int width, int height)
{ {
Size.x = width; Width = width;
Size.y = height; Height = height;
data = data_; data = data_;
DeleteHardwareTextures(); DeleteHardwareTextures();
} }
@ -62,11 +62,11 @@ FBitmap VPXTexture::GetBgraBitmap(const PalEntry* remap, int* trans)
{ {
FBitmap bmp; FBitmap bmp;
bmp.Create(Size.x, Size.y); bmp.Create(Width, Height);
auto spix = (uint8_t*)data; auto spix = (uint8_t*)data;
auto dpix = bmp.GetPixels(); auto dpix = bmp.GetPixels();
for (int i = 0; i < Size.x * Size.y; i++) for (int i = 0; i < Width * Height; i++)
{ {
int p = i * 4; int p = i * 4;
float y = spix[p] * (1/255.f); float y = spix[p] * (1/255.f);

View file

@ -327,7 +327,7 @@ int32_t polymost_spriteHasTranslucency(tspritetype const * const tspr)
auto tex = TileFiles.tiles[tspr->picnum]; auto tex = TileFiles.tiles[tspr->picnum];
auto si = tex->FindReplacement(tspr->shade, 0); auto si = tex->FindReplacement(tspr->shade, 0);
if (si && hw_hightile) tex = si->faces[0]; if (si && hw_hightile) tex = si->faces[0];
if (tex->Get8BitPixels()) return false; if (tex->GetTexelWidth() == 0 || tex->GetTexelHeight() == 0) return false;
return tex && tex->GetTranslucency(); return tex && tex->GetTranslucency();
} }

View file

@ -39,7 +39,7 @@
#include "image.h" #include "image.h"
#include "palettecontainer.h" #include "palettecontainer.h"
#if 0
//========================================================================== //==========================================================================
// //
// //
@ -75,4 +75,3 @@ int FBuildTexture::CopyPixels(FBitmap *bmp, int conversion)
} }
#endif

View file

@ -49,13 +49,11 @@
** the pixel data, it is fairly inefficient to process. ** the pixel data, it is fairly inefficient to process.
*/ */
#include <stdint.h>
#include "files.h" #include "files.h"
#include "filesystem.h"
#include "bitmap.h" #include "bitmap.h"
#include "imagehelpers.h" #include "imagehelpers.h"
#include "image.h" #include "image.h"
#include "m_png.h"
#include "filesystem.h"
// Since we want this to compile under Linux too, we need to define this // Since we want this to compile under Linux too, we need to define this
// stuff ourselves instead of including a DirectX header. // stuff ourselves instead of including a DirectX header.

View file

@ -148,6 +148,27 @@ public:
static void RegisterForPrecache(FImageSource *img, bool requiretruecolor); static void RegisterForPrecache(FImageSource *img, bool requiretruecolor);
}; };
//==========================================================================
//
// A texture defined in a Build TILESxxx.ART file
//
//==========================================================================
struct FRemapTable;
class FBuildTexture : public FImageSource
{
public:
FBuildTexture(const FString& pathprefix, int tilenum, const uint8_t* pixels, FRemapTable* translation, int width, int height, int left, int top);
TArray<uint8_t> CreatePalettedPixels(int conversion) override;
int CopyPixels(FBitmap* bmp, int conversion) override;
protected:
const uint8_t* RawPixels;
FRemapTable* Translation;
};
//========================================================================== //==========================================================================
// //
// a TGA texture // a TGA texture

View file

@ -335,17 +335,17 @@ void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FTexture *
// scaling is not used here. // scaling is not used here.
if (!local_origin) if (!local_origin)
{ {
fU1 = float(left) / src->GetWidth(); fU1 = float(left) / src->GetDisplayWidth();
fV1 = float(top) / src->GetHeight(); fV1 = float(top) / src->GetDisplayHeight();
fU2 = float(right) / src->GetWidth(); fU2 = float(right) / src->GetDisplayWidth();
fV2 = float(bottom) / src->GetHeight(); fV2 = float(bottom) / src->GetDisplayHeight();
} }
else else
{ {
fU1 = 0; fU1 = 0;
fV1 = 0; fV1 = 0;
fU2 = float(right - left) / src->GetWidth(); fU2 = float(right - left) / src->GetDisplayWidth();
fV2 = float(bottom - top) / src->GetHeight(); fV2 = float(bottom - top) / src->GetDisplayHeight();
} }
dg.mVertIndex = (int)mVertices.Reserve(4); dg.mVertIndex = (int)mVertices.Reserve(4);
auto ptr = &mVertices[dg.mVertIndex]; auto ptr = &mVertices[dg.mVertIndex];
@ -667,7 +667,7 @@ void F2DDrawer::rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
float alpha = GetAlphaFromBlend(method, dablend) * (1.f - drawpoly_alpha); // Hmmm... float alpha = GetAlphaFromBlend(method, dablend) * (1.f - drawpoly_alpha); // Hmmm...
p.a = (uint8_t)(alpha * 255); p.a = (uint8_t)(alpha * 255);
vec2_16_t const siz = dg.mTexture->GetSize(); vec2_t const siz = { dg.mTexture->GetDisplayWidth(), dg.mTexture->GetDisplayHeight() };
vec2_16_t ofs = { 0, 0 }; vec2_16_t ofs = { 0, 0 };
if (!(dastat & RS_TOPLEFT)) if (!(dastat & RS_TOPLEFT))

View file

@ -116,8 +116,8 @@ bool SetTextureParms(DrawParms *parms, FTexture *img, double xx, double yy)
{ {
parms->x = xx; parms->x = xx;
parms->y = yy; parms->y = yy;
parms->texwidth = img->GetWidth(); parms->texwidth = img->GetDisplayWidth();
parms->texheight = img->GetHeight(); parms->texheight = img->GetDisplayHeight();
if (parms->top == INT_MAX || parms->fortext) if (parms->top == INT_MAX || parms->fortext)
{ {
parms->top = img->GetTopOffset(); parms->top = img->GetTopOffset();
@ -128,11 +128,11 @@ bool SetTextureParms(DrawParms *parms, FTexture *img, double xx, double yy)
} }
if (parms->destwidth == INT_MAX || parms->fortext) if (parms->destwidth == INT_MAX || parms->fortext)
{ {
parms->destwidth = img->GetWidth(); parms->destwidth = img->GetDisplayWidth();
} }
if (parms->destheight == INT_MAX || parms->fortext) if (parms->destheight == INT_MAX || parms->fortext)
{ {
parms->destheight = img->GetHeight(); parms->destheight = img->GetDisplayHeight();
} }
switch (parms->cleanmode) switch (parms->cleanmode)
@ -390,8 +390,8 @@ bool ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t tag, Va_Li
assert(fortext == false); assert(fortext == false);
if (img == NULL) return false; if (img == NULL) return false;
parms->cleanmode = DTA_Fullscreen; parms->cleanmode = DTA_Fullscreen;
parms->virtWidth = img->GetWidth(); parms->virtWidth = img->GetDisplayWidth();
parms->virtHeight = img->GetHeight(); parms->virtHeight = img->GetDisplayHeight();
} }
break; break;
@ -432,19 +432,19 @@ bool ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t tag, Va_Li
break; break;
case DTA_SrcX: case DTA_SrcX:
parms->srcx = ListGetDouble(tags) / img->GetWidth(); parms->srcx = ListGetDouble(tags) / img->GetDisplayWidth();
break; break;
case DTA_SrcY: case DTA_SrcY:
parms->srcy = ListGetDouble(tags) / img->GetHeight(); parms->srcy = ListGetDouble(tags) / img->GetDisplayHeight();
break; break;
case DTA_SrcWidth: case DTA_SrcWidth:
parms->srcwidth = ListGetDouble(tags) / img->GetWidth(); parms->srcwidth = ListGetDouble(tags) / img->GetDisplayWidth();
break; break;
case DTA_SrcHeight: case DTA_SrcHeight:
parms->srcheight = ListGetDouble(tags) / img->GetHeight(); parms->srcheight = ListGetDouble(tags) / img->GetDisplayHeight();
break; break;
case DTA_TopOffset: case DTA_TopOffset:
@ -476,8 +476,8 @@ bool ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t tag, Va_Li
if (fortext) return false; if (fortext) return false;
if (ListGetInt(tags)) if (ListGetInt(tags))
{ {
parms->left = img->GetWidth() * 0.5; parms->left = img->GetDisplayWidth() * 0.5;
parms->top = img->GetHeight() * 0.5; parms->top = img->GetDisplayHeight() * 0.5;
} }
break; break;
@ -486,8 +486,8 @@ bool ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t tag, Va_Li
if (fortext) return false; if (fortext) return false;
if (ListGetInt(tags)) if (ListGetInt(tags))
{ {
parms->left = img->GetWidth() * 0.5; parms->left = img->GetDisplayWidth() * 0.5;
parms->top = img->GetHeight(); parms->top = img->GetDisplayHeight();
} }
break; break;

View file

@ -416,13 +416,13 @@ void FListMenuItemStaticPatch::Drawer(DListMenu* menu, const DVector2& origin, b
FTexture *tex = mTexture; FTexture *tex = mTexture;
if (mYpos >= 0) if (mYpos >= 0)
{ {
if (mCentered) x -= tex->GetWidth()/2; if (mCentered) x -= tex->GetDisplayWidth()/2;
DrawTexture (twod, tex, x, mYpos, DTA_Clean, true, TAG_DONE); DrawTexture (twod, tex, x, mYpos, DTA_Clean, true, TAG_DONE);
} }
else else
{ {
int x = (mXpos - 160) * CleanXfac + (screen->GetWidth()>>1); int x = (mXpos - 160) * CleanXfac + (screen->GetWidth()>>1);
if (mCentered) x -= (tex->GetWidth()*CleanXfac)/2; if (mCentered) x -= (tex->GetDisplayWidth()*CleanXfac)/2;
DrawTexture (twod, tex, x, -mYpos*CleanYfac, DTA_CleanNoMove, true, TAG_DONE); DrawTexture (twod, tex, x, -mYpos*CleanYfac, DTA_CleanNoMove, true, TAG_DONE);
} }
} }
@ -645,7 +645,7 @@ void FListMenuItemPatch::Drawer(DListMenu* menu, const DVector2& origin, bool se
int FListMenuItemPatch::GetWidth() int FListMenuItemPatch::GetWidth()
{ {
return mTexture return mTexture
? mTexture->GetWidth() ? mTexture->GetDisplayWidth()
: 0; : 0;
} }

View file

@ -268,10 +268,10 @@ bool DMenu::MouseEventBack(int type, int x, int y)
FTexture* tex = TileFiles.GetTexture("engine/graphics/m_back.png"); FTexture* tex = TileFiles.GetTexture("engine/graphics/m_back.png");
if (tex != NULL) if (tex != NULL)
{ {
if (m_show_backbutton&1) x -= screen->GetWidth() - tex->GetWidth() * CleanXfac; if (m_show_backbutton&1) x -= screen->GetWidth() - tex->GetDisplayWidth() * CleanXfac;
if (m_show_backbutton&2) y -= screen->GetHeight() - tex->GetHeight() * CleanYfac; if (m_show_backbutton&2) y -= screen->GetHeight() - tex->GetDisplayHeight() * CleanYfac;
mBackbuttonSelected = ( x >= 0 && x < tex->GetWidth() * CleanXfac && mBackbuttonSelected = ( x >= 0 && x < tex->GetDisplayWidth() * CleanXfac &&
y >= 0 && y < tex->GetHeight() * CleanYfac); y >= 0 && y < tex->GetDisplayHeight() * CleanYfac);
if (mBackbuttonSelected && type == MOUSE_Release) if (mBackbuttonSelected && type == MOUSE_Release)
{ {
if (m_use_mouse == 2) mBackbuttonSelected = false; if (m_use_mouse == 2) mBackbuttonSelected = false;
@ -322,19 +322,21 @@ void DMenu::Drawer ()
if (this == DMenu::CurrentMenu && BackbuttonAlpha > 0 && m_show_backbutton >= 0 && m_use_mouse) if (this == DMenu::CurrentMenu && BackbuttonAlpha > 0 && m_show_backbutton >= 0 && m_use_mouse)
{ {
FTexture* tex = TileFiles.GetTexture("engine/graphics/m_back.png"); FTexture* tex = TileFiles.GetTexture("engine/graphics/m_back.png");
int w = tex->GetWidth() * CleanXfac; {
int h = tex->GetHeight() * CleanYfac; int w = tex->GetDisplayWidth() * CleanXfac;
int x = (!(m_show_backbutton&1))? 0:screen->GetWidth() - w; int h = tex->GetDisplayHeight() * CleanYfac;
int y = (!(m_show_backbutton&2))? 0:screen->GetHeight() - h; int x = (!(m_show_backbutton & 1)) ? 0 : screen->GetWidth() - w;
int y = (!(m_show_backbutton & 2)) ? 0 : screen->GetHeight() - h;
if (mBackbuttonSelected && (mMouseCapture || m_use_mouse == 1)) if (mBackbuttonSelected && (mMouseCapture || m_use_mouse == 1))
{ {
DrawTexture(twod, tex, x, y, DTA_CleanNoMove, true, DTA_ColorOverlay, MAKEARGB(40, 255,255,255), TAG_DONE); DrawTexture(twod, tex, x, y, DTA_CleanNoMove, true, DTA_ColorOverlay, MAKEARGB(40, 255, 255, 255), TAG_DONE);
} }
else else
{ {
DrawTexture(twod, tex, x, y, DTA_CleanNoMove, true, DTA_Alpha, BackbuttonAlpha, TAG_DONE); DrawTexture(twod, tex, x, y, DTA_CleanNoMove, true, DTA_Alpha, BackbuttonAlpha, TAG_DONE);
} }
} }
}
} }

View file

@ -416,7 +416,7 @@ unsigned FSavegameManager::ExtractSaveData(int index)
{ {
SavePic = PNGTexture_CreateFromFile(png, node->Filename); SavePic = PNGTexture_CreateFromFile(png, node->Filename);
delete png; delete png;
if (SavePic && SavePic->GetWidth() == 1 && SavePic->GetHeight() == 1) if (SavePic && SavePic->GetDisplayWidth() == 1 && SavePic->GetDisplayHeight() == 1)
{ {
delete SavePic; delete SavePic;
SavePic = nullptr; SavePic = nullptr;

View file

@ -178,10 +178,10 @@ void FGLRenderer::BindToFrameBuffer(FTexture *mat)
{ {
// must create the hardware texture first // must create the hardware texture first
BaseLayer = new FHardwareTexture(); BaseLayer = new FHardwareTexture();
BaseLayer->CreateTexture(mat->GetWidth()*4, mat->GetHeight()*4, FHardwareTexture::TrueColor, false); BaseLayer->CreateTexture(mat->GetTexelWidth()*4, mat->GetTexelHeight()*4, ::FHardwareTexture::TrueColor, false);
mat->SetHardwareTexture(0, BaseLayer); mat->SetHardwareTexture(0, BaseLayer);
} }
BaseLayer->BindToFrameBuffer(mat->GetWidth()*4, mat->GetHeight()*4); BaseLayer->BindToFrameBuffer(mat->GetTexelWidth()*4, mat->GetTexelHeight()*4);
} }
//=========================================================================== //===========================================================================

View file

@ -226,6 +226,10 @@ public:
int GetWidth() const { return Size.x; } int GetWidth() const { return Size.x; }
int GetHeight() const { return Size.y; } int GetHeight() const { return Size.y; }
int GetTexelWidth() const { return Size.x; }
int GetTexelHeight() const { return Size.y; }
int GetDisplayWidth() const { return Size.x; }
int GetDisplayHeight() const { return Size.y; }
const vec2_16_t &GetSize() const { return Size; } const vec2_16_t &GetSize() const { return Size; }
const uint8_t& GetPicSize() const { return PicSize; } const uint8_t& GetPicSize() const { return PicSize; }
int GetLeftOffset() const { return PicAnim.xofs; } int GetLeftOffset() const { return PicAnim.xofs; }
@ -294,7 +298,11 @@ protected:
FString Name; FString Name;
union
{
vec2_16_t Size = { 0,0 }; // Keep this in the native format so that we can use it without copying it around. vec2_16_t Size = { 0,0 }; // Keep this in the native format so that we can use it without copying it around.
struct { uint16_t Width, Height; };
};
rottile_t RotTile = { -1,-1 }; rottile_t RotTile = { -1,-1 };
uint8_t bMasked = true; // Texture (might) have holes uint8_t bMasked = true; // Texture (might) have holes
int8_t bTranslucent = -1; // Does this texture have an active alpha channel? int8_t bTranslucent = -1; // Does this texture have an active alpha channel?