- backend update from Raze.

This commit is contained in:
Christoph Oelckers 2020-11-23 15:45:33 +01:00
parent 58d8ce1a4f
commit 9925cc380e
11 changed files with 38 additions and 17 deletions

View file

@ -186,8 +186,9 @@ void DrawChar(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double
{ {
return; return;
} }
bool palettetrans = (normalcolor == CR_UNDEFINED && parms.TranslationId != 0);
PalEntry color = 0xffffffff; PalEntry color = 0xffffffff;
parms.TranslationId = redirected ? -1 : font->GetColorTranslation((EColorRange)normalcolor, &color); if (!palettetrans) parms.TranslationId = redirected ? -1 : font->GetColorTranslation((EColorRange)normalcolor, &color);
parms.color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255); parms.color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255);
drawer->AddTexture(pic, parms); drawer->AddTexture(pic, parms);
} }
@ -211,8 +212,9 @@ void DrawChar(F2DDrawer *drawer, FFont *font, int normalcolor, double x, double
uint32_t tag = ListGetInt(args); uint32_t tag = ListGetInt(args);
bool res = ParseDrawTextureTags(drawer, pic, x, y, tag, args, &parms, false); bool res = ParseDrawTextureTags(drawer, pic, x, y, tag, args, &parms, false);
if (!res) return; if (!res) return;
bool palettetrans = (normalcolor == CR_UNDEFINED && parms.TranslationId != 0);
PalEntry color = 0xffffffff; PalEntry color = 0xffffffff;
parms.TranslationId = redirected ? -1 : font->GetColorTranslation((EColorRange)normalcolor, &color); if (!palettetrans) parms.TranslationId = redirected ? -1 : font->GetColorTranslation((EColorRange)normalcolor, &color);
parms.color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255); parms.color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255);
drawer->AddTexture(pic, parms); drawer->AddTexture(pic, parms);
} }

View file

@ -4,6 +4,9 @@
#include "intrect.h" #include "intrect.h"
struct event_t; struct event_t;
class FRenderState;
class FGameTexture;
enum EUpscaleFlags : int;
struct SystemCallbacks struct SystemCallbacks
{ {
@ -27,6 +30,8 @@ struct SystemCallbacks
void (*MenuClosed)(); void (*MenuClosed)();
bool (*CheckMenudefOption)(const char* opt); bool (*CheckMenudefOption)(const char* opt);
void (*ConsoleToggled)(int state); void (*ConsoleToggled)(int state);
bool (*PreBindTexture)(FRenderState* state, FGameTexture*& tex, EUpscaleFlags& flags, int& scaleflags, int& clampmode, int& translation, int& overrideshader);
void (*FontCharCreated)(FGameTexture* base, FGameTexture* untranslated, FGameTexture* translated);
}; };
extern SystemCallbacks sysCallbacks; extern SystemCallbacks sysCallbacks;

View file

@ -55,6 +55,7 @@
#include "fontchars.h" #include "fontchars.h"
#include "multipatchtexture.h" #include "multipatchtexture.h"
#include "texturemanager.h" #include "texturemanager.h"
#include "i_interface.h"
#include "fontinternals.h" #include "fontinternals.h"
@ -342,6 +343,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
{ {
Chars[i].TranslatedPic = tex; Chars[i].TranslatedPic = tex;
} }
if (sysCallbacks.FontCharCreated) sysCallbacks.FontCharCreated(pic, Chars[i].OriginalPic, Chars[i].TranslatedPic);
Chars[i].XMove = (int)Chars[i].TranslatedPic->GetDisplayWidth(); Chars[i].XMove = (int)Chars[i].TranslatedPic->GetDisplayWidth();
} }

View file

@ -38,6 +38,7 @@
#include "image.h" #include "image.h"
#include "fontchars.h" #include "fontchars.h"
#include "texturemanager.h" #include "texturemanager.h"
#include "i_interface.h"
#include "fontinternals.h" #include "fontinternals.h"
@ -116,6 +117,7 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FGameTexture
} }
else Chars[i].TranslatedPic = Chars[i].OriginalPic; else Chars[i].TranslatedPic = Chars[i].OriginalPic;
Chars[i].XMove = (int)Chars[i].TranslatedPic->GetDisplayWidth(); Chars[i].XMove = (int)Chars[i].TranslatedPic->GetDisplayWidth();
if (sysCallbacks.FontCharCreated) sysCallbacks.FontCharCreated(pic, Chars[i].OriginalPic, Chars[i].TranslatedPic);
} }
else else
{ {

View file

@ -267,7 +267,7 @@ private:
void *operator new(size_t len, nonew&) void *operator new(size_t len, nonew&)
{ {
return M_Malloc(len); return M_Calloc(len, 1);
} }
public: public:

View file

@ -5,6 +5,7 @@
#include "hw_material.h" #include "hw_material.h"
#include "texmanip.h" #include "texmanip.h"
#include "version.h" #include "version.h"
#include "i_interface.h"
struct FColormap; struct FColormap;
class IVertexBuffer; class IVertexBuffer;
@ -569,6 +570,7 @@ public:
mBias.mChanged = true; mBias.mChanged = true;
} }
private:
void SetMaterial(FMaterial *mat, int clampmode, int translation, int overrideshader) void SetMaterial(FMaterial *mat, int clampmode, int translation, int overrideshader)
{ {
mMaterial.mMaterial = mat; mMaterial.mMaterial = mat;
@ -581,10 +583,16 @@ public:
mStreamData.uDetailParms = { scale.X, scale.Y, 2, 0 }; mStreamData.uDetailParms = { scale.X, scale.Y, 2, 0 };
} }
public:
void SetMaterial(FGameTexture* tex, EUpscaleFlags upscalemask, int scaleflags, int clampmode, int translation, int overrideshader) void SetMaterial(FGameTexture* tex, EUpscaleFlags upscalemask, int scaleflags, int clampmode, int translation, int overrideshader)
{
if (!sysCallbacks.PreBindTexture || !sysCallbacks.PreBindTexture(this, tex, upscalemask, scaleflags, clampmode, translation, overrideshader))
{ {
if (shouldUpscale(tex, upscalemask)) scaleflags |= CTF_Upscale; if (shouldUpscale(tex, upscalemask)) scaleflags |= CTF_Upscale;
SetMaterial(FMaterial::ValidateTexture(tex, scaleflags), clampmode, translation, overrideshader); }
auto mat = FMaterial::ValidateTexture(tex, scaleflags);
assert(mat);
SetMaterial(mat, clampmode, translation, overrideshader);
} }
void SetClipSplit(float bottom, float top) void SetClipSplit(float bottom, float top)

View file

@ -124,7 +124,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawImage, SBar_DrawImage)
return 0; return 0;
} }
void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string, double x, double y, int flags, int trans, double alpha, int wrapwidth, int linespacing, double scaleX, double scaleY); void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string, double x, double y, int flags, int trans, double alpha, int wrapwidth, int linespacing, double scaleX, double scaleY, int translation);
DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawString, SBar_DrawString) DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawString, SBar_DrawString)
{ {
@ -140,7 +140,8 @@ DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawString, SBar_DrawString)
PARAM_INT(linespacing); PARAM_INT(linespacing);
PARAM_FLOAT(scaleX); PARAM_FLOAT(scaleX);
PARAM_FLOAT(scaleY); PARAM_FLOAT(scaleY);
SBar_DrawString(self, font, string, x, y, flags, trans, alpha, wrapwidth, linespacing, scaleX, scaleY); PARAM_INT(pt);
SBar_DrawString(self, font, string, x, y, flags, trans, alpha, wrapwidth, linespacing, scaleX, scaleY, pt);
return 0; return 0;
} }

View file

@ -79,8 +79,8 @@ void VMFunction::CreateRegUse()
int count = 0; int count = 0;
if (!Proto) if (!Proto)
{ {
if (RegTypes) return; //if (RegTypes) return;
Printf(TEXTCOLOR_ORANGE "Function without prototype needs register info manually set: %s\n", PrintableName.GetChars()); //Printf(TEXTCOLOR_ORANGE "Function without prototype needs register info manually set: %s\n", PrintableName.GetChars());
return; return;
} }
assert(Proto->isPrototype()); assert(Proto->isPrototype());

View file

@ -57,7 +57,7 @@ IMPLEMENT_CLASS(DHUDFont, false, false);
CVAR(Color, crosshaircolor, 0xff0000, CVAR_ARCHIVE); CVAR(Color, crosshaircolor, 0xff0000, CVAR_ARCHIVE);
CVAR(Int, crosshairhealth, 2, CVAR_ARCHIVE); CVAR(Int, crosshairhealth, 2, CVAR_ARCHIVE);
CVAR(Float, crosshairscale, 1.0, CVAR_ARCHIVE); CVARD(Float, crosshairscale, 0.5, CVAR_ARCHIVE, "changes the size of the crosshair");
CVAR(Bool, crosshairgrow, false, CVAR_ARCHIVE); CVAR(Bool, crosshairgrow, false, CVAR_ARCHIVE);
EXTERN_CVAR(Bool, vid_fps) EXTERN_CVAR(Bool, vid_fps)
@ -602,7 +602,7 @@ void DStatusBarCore::DrawGraphic(FGameTexture* tex, double x, double y, int flag
// //
//============================================================================ //============================================================================
void DStatusBarCore::DrawString(FFont* font, const FString& cstring, double x, double y, int flags, double Alpha, int translation, int spacing, EMonospacing monospacing, int shadowX, int shadowY, double scaleX, double scaleY) void DStatusBarCore::DrawString(FFont* font, const FString& cstring, double x, double y, int flags, double Alpha, int translation, int spacing, EMonospacing monospacing, int shadowX, int shadowY, double scaleX, double scaleY, int pt)
{ {
bool monospaced = monospacing != EMonospacing::Off; bool monospaced = monospacing != EMonospacing::Off;
double dx = 0; double dx = 0;
@ -724,10 +724,11 @@ void DStatusBarCore::DrawString(FFont* font, const FString& cstring, double x, d
DTA_FillColor, 0, DTA_FillColor, 0,
TAG_DONE); TAG_DONE);
} }
DrawChar(twod, font, fontcolor, rx, ry, ch, DrawChar(twod, font, pt == 0? fontcolor : CR_UNDEFINED, rx, ry, ch,
DTA_DestWidthF, rw, DTA_DestWidthF, rw,
DTA_DestHeightF, rh, DTA_DestHeightF, rh,
DTA_Alpha, Alpha, DTA_Alpha, Alpha,
DTA_TranslationIndex, pt,
TAG_DONE); TAG_DONE);
dx = monospaced dx = monospaced
@ -739,7 +740,7 @@ void DStatusBarCore::DrawString(FFont* font, const FString& cstring, double x, d
} }
} }
void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string, double x, double y, int flags, int trans, double alpha, int wrapwidth, int linespacing, double scaleX, double scaleY) void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string, double x, double y, int flags, int trans, double alpha, int wrapwidth, int linespacing, double scaleX, double scaleY, int pt)
{ {
if (font == nullptr) ThrowAbortException(X_READ_NIL, nullptr); if (font == nullptr) ThrowAbortException(X_READ_NIL, nullptr);
if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function"); if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
@ -758,13 +759,13 @@ void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string
auto brk = V_BreakLines(font->mFont, int(wrapwidth * scaleX), string, true); auto brk = V_BreakLines(font->mFont, int(wrapwidth * scaleX), string, true);
for (auto& line : brk) for (auto& line : brk)
{ {
self->DrawString(font->mFont, line.Text, x, y, flags, alpha, trans, font->mSpacing, font->mMonospacing, font->mShadowX, font->mShadowY, scaleX, scaleY); self->DrawString(font->mFont, line.Text, x, y, flags, alpha, trans, font->mSpacing, font->mMonospacing, font->mShadowX, font->mShadowY, scaleX, scaleY, pt);
y += (font->mFont->GetHeight() + linespacing) * scaleY; y += (font->mFont->GetHeight() + linespacing) * scaleY;
} }
} }
else else
{ {
self->DrawString(font->mFont, string, x, y, flags, alpha, trans, font->mSpacing, font->mMonospacing, font->mShadowX, font->mShadowY, scaleX, scaleY); self->DrawString(font->mFont, string, x, y, flags, alpha, trans, font->mSpacing, font->mMonospacing, font->mShadowX, font->mShadowY, scaleX, scaleY, pt);
} }
} }

View file

@ -186,7 +186,7 @@ public:
void StatusbarToRealCoords(double& x, double& y, double& w, double& h) const; void StatusbarToRealCoords(double& x, double& y, double& w, double& h) const;
void DrawGraphic(FGameTexture* texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY, PalEntry color = 0xffffffff, int translation = 0, double rotate = 0, ERenderStyle style = STYLE_Translucent); void DrawGraphic(FGameTexture* texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY, PalEntry color = 0xffffffff, int translation = 0, double rotate = 0, ERenderStyle style = STYLE_Translucent);
void DrawGraphic(FTextureID texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY, PalEntry color = 0xffffffff, int translation = 0, double rotate = 0, ERenderStyle style = STYLE_Translucent); void DrawGraphic(FTextureID texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY, PalEntry color = 0xffffffff, int translation = 0, double rotate = 0, ERenderStyle style = STYLE_Translucent);
void DrawString(FFont* font, const FString& cstring, double x, double y, int flags, double Alpha, int translation, int spacing, EMonospacing monospacing, int shadowX, int shadowY, double scaleX, double scaleY); void DrawString(FFont* font, const FString& cstring, double x, double y, int flags, double Alpha, int translation, int spacing, EMonospacing monospacing, int shadowX, int shadowY, double scaleX, double scaleY, int pt);
void TransformRect(double& x, double& y, double& w, double& h, int flags = 0); void TransformRect(double& x, double& y, double& w, double& h, int flags = 0);
void Fill(PalEntry color, double x, double y, double w, double h, int flags = 0); void Fill(PalEntry color, double x, double y, double w, double h, int flags = 0);
void SetClipRect(double x, double y, double w, double h, int flags = 0); void SetClipRect(double x, double y, double w, double h, int flags = 0);

View file

@ -361,7 +361,7 @@ inline FGameTexture* MakeGameTexture(FTexture* tex, const char *name, ETextureTy
return t; return t;
} }
enum EUpscaleFlags enum EUpscaleFlags : int
{ {
UF_None = 0, UF_None = 0,
UF_Texture = 1, UF_Texture = 1,