- FGameTexture conversion in am_map.cpp

This commit is contained in:
Christoph Oelckers 2020-04-14 00:25:08 +02:00
parent aeba304715
commit 73b4fbe861
4 changed files with 39 additions and 14 deletions

View file

@ -988,7 +988,7 @@ class DAutomap :public DAutomapBase
void calcMinMaxMtoF();
void DrawMarker(FTexture *tex, double x, double y, int yadjust,
void DrawMarker(FGameTexture *tex, double x, double y, int yadjust,
INTBOOL flip, double xscale, double yscale, int translation, double alpha, uint32_t fillcolor, FRenderStyle renderstyle);
void rotatePoint(double *x, double *y);
@ -1235,7 +1235,7 @@ void DAutomap::ScrollParchment (double dmapx, double dmapy)
if (mapback.isValid())
{
FTexture *backtex = TexMan.GetTexture(mapback);
auto backtex = TexMan.GetGameTexture(mapback);
if (backtex != nullptr)
{
@ -1588,7 +1588,7 @@ void DAutomap::clearFB (const AMColor &color)
}
else
{
FTexture *backtex = TexMan.GetTexture(mapback);
auto backtex = TexMan.GetGameTexture(mapback);
if (backtex != nullptr)
{
int pwidth = backtex->GetDisplayWidth();
@ -2908,7 +2908,7 @@ void DAutomap::drawThings ()
if (am_showthingsprites > 0 && t->sprite > 0)
{
FTexture *texture = nullptr;
FGameTexture *texture = nullptr;
spriteframe_t *frame;
int rotation = 0;
@ -2928,7 +2928,7 @@ void DAutomap::drawThings ()
rotation = int((angle.Normalized360() * (16. / 360.)).Degrees);
const FTextureID textureID = frame->Texture[show > 2 ? rotation : 0];
texture = TexMan.GetTexture(textureID, true);
texture = TexMan.GetGameTexture(textureID, true);
}
if (texture == nullptr) goto drawTriangle; // fall back to standard display if no sprite can be found.
@ -3023,7 +3023,7 @@ void DAutomap::drawThings ()
//
//=============================================================================
void DAutomap::DrawMarker (FTexture *tex, double x, double y, int yadjust,
void DAutomap::DrawMarker (FGameTexture *tex, double x, double y, int yadjust,
INTBOOL flip, double xscale, double yscale, int translation, double alpha, uint32_t fillcolor, FRenderStyle renderstyle)
{
if (tex == nullptr || !tex->isValid())
@ -3035,8 +3035,8 @@ void DAutomap::DrawMarker (FTexture *tex, double x, double y, int yadjust,
rotatePoint (&x, &y);
}
DrawTexture(twod, tex, CXMTOF(x) + f_x, CYMTOF(y) + yadjust + f_y,
DTA_DestWidthF, tex->GetDisplayWidthDouble() * CleanXfac * xscale,
DTA_DestHeightF, tex->GetDisplayHeightDouble() * CleanYfac * yscale,
DTA_DestWidth, tex->GetDisplayWidth() * CleanXfac * xscale,
DTA_DestHeight, tex->GetDisplayHeight() * CleanYfac * yscale,
DTA_ClipTop, f_y,
DTA_ClipBottom, f_y + f_h,
DTA_ClipLeft, f_x,
@ -3072,7 +3072,7 @@ void DAutomap::drawMarks ()
if (font == nullptr)
{
DrawMarker(TexMan.GetTexture(marknums[i], true), markpoints[i].x, markpoints[i].y, -3, 0,
DrawMarker(TexMan.GetGameTexture(marknums[i], true), markpoints[i].x, markpoints[i].y, -3, 0,
1, 1, 0, 1, 0, LegacyRenderStyles[STYLE_Normal]);
}
else
@ -3114,18 +3114,18 @@ void DAutomap::drawAuthorMarkers ()
}
FTextureID picnum;
FTexture *tex;
FGameTexture *tex;
uint16_t flip = 0;
if (mark->picnum.isValid())
{
tex = TexMan.GetTexture(mark->picnum, true);
tex = TexMan.GetGameTexture(mark->picnum, true);
if (tex->GetRotations() != 0xFFFF)
{
spriteframe_t *sprframe = &SpriteFrames[tex->GetRotations()];
picnum = sprframe->Texture[0];
flip = sprframe->Flip & 1;
tex = TexMan.GetTexture(picnum);
tex = TexMan.GetGameTexture(picnum);
}
}
else
@ -3140,7 +3140,7 @@ void DAutomap::drawAuthorMarkers ()
spriteframe_t *sprframe = &SpriteFrames[sprdef->spriteframes + mark->frame];
picnum = sprframe->Texture[0];
flip = sprframe->Flip & 1;
tex = TexMan.GetTexture(picnum);
tex = TexMan.GetGameTexture(picnum);
}
}
auto it = Level->GetActorIterator(mark->args[0]);

View file

@ -214,6 +214,12 @@ void DrawText(F2DDrawer* drawer, FFont* font, int normalcolor, double x, double
void DrawChar(F2DDrawer* drawer, FFont* font, int normalcolor, double x, double y, int character, int tag_first, ...);
void DrawTexture(F2DDrawer* drawer, FTexture* img, double x, double y, int tags_first, ...);
template <typename ...Params>
void DrawTexture(F2DDrawer* drawer, FGameTexture* img, double x, double y, int tags_first, Params&&... params)
{
DrawTexture(drawer, img->GetTexture(), x, y, tags_first, std::forward<Params>(params)...);
}
void DoDim(F2DDrawer* drawer, PalEntry color, float amount, int x1, int y1, int w, int h, FRenderStyle* style = nullptr);
void Dim(F2DDrawer* drawer, PalEntry color, float damount, int x1, int y1, int w, int h, FRenderStyle* style = nullptr);
void FillBorder(F2DDrawer *drawer, FTexture* img); // Fills the border around a 4:3 part of the screen on non-4:3 displays

View file

@ -44,7 +44,12 @@ public:
{
return InternalGetTexture(texnum.GetIndex(), animate, true, false);
}
FGameTexture* GetGameTexture(FTextureID texnum, bool animate = false)
{
return reinterpret_cast<FGameTexture*>(GetTexture(texnum, animate));
}
// This is the only access function that should be used inside the software renderer.
FTexture *GetPalettedTexture(FTextureID texnum, bool animate)
{

View file

@ -559,6 +559,20 @@ struct FTexCoordInfo
void GetFromTexture(FTexture *tex, float x, float y, bool forceworldpanning);
};
// Refactoring helper to allow piece by piece adjustment of the API
class FGameTexture
{
FTexture wrapped;
public:
FTexture* GetTexture() { return &wrapped; }
int GetDisplayWidth() /*const*/ { return wrapped.GetDisplayWidth(); }
int GetDisplayHeight() /*const*/ { return wrapped.GetDisplayHeight(); }
bool isValid() { return wrapped.isValid(); }
uint16_t GetRotations() { return wrapped.GetRotations(); }
};
#endif