From 494504229f8accc15f10241edce72e19c3151ca6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 18 Mar 2018 12:54:40 +0100 Subject: [PATCH] - fixed the BarShader texture. Even though unlikely, this should work as a regular texture because it can be used as such. As a result of the above, true color generation needs to be done explicitly now. --- src/r_data/renderstyle.h | 7 +++--- src/textures/shadertexture.cpp | 44 ++++++++++++++++++++++++---------- src/textures/textures.h | 1 + 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/r_data/renderstyle.h b/src/r_data/renderstyle.h index b1fd98a5c..68bc9a242 100644 --- a/src/r_data/renderstyle.h +++ b/src/r_data/renderstyle.h @@ -139,10 +139,9 @@ union FRenderStyle bool IsVisible(double alpha) const throw(); private: // Code that compares an actor's render style with a legacy render - // style value should be updated. Making these conversion operators - // private will catch those cases. - operator ERenderStyle() const { return STYLE_Normal; } - operator int() const { return STYLE_Normal; } + // style value should be updated. + operator ERenderStyle() = delete; + operator int() const = delete; }; extern FRenderStyle LegacyRenderStyles[STYLE_Count]; diff --git a/src/textures/shadertexture.cpp b/src/textures/shadertexture.cpp index 93e423470..2834c9318 100644 --- a/src/textures/shadertexture.cpp +++ b/src/textures/shadertexture.cpp @@ -49,9 +49,11 @@ #include "r_defs.h" #include "r_state.h" #include "r_data/r_translate.h" +#include "r_data/renderstyle.h" +#include "bitmap.h" -class FBarShader : public FTexture +class FBarShader : public FWorldTexture { public: FBarShader(bool vertical, bool reverse) @@ -62,6 +64,7 @@ public: Width = vertical ? 2 : 256; Height = vertical ? 256 : 2; CalcBitSize(); + PixelsAreStatic = 2; // The alpha buffer is static, but if this gets used as a regular texture, a separate buffer needs to be made. // Fill the column/row with shading values. // Vertical shaders have have minimum alpha at the top @@ -106,24 +109,41 @@ public: } } } - DummySpan[0].TopOffset = 0; - DummySpan[0].Length = vertical ? 256 : 2; - DummySpan[1].TopOffset = 0; - DummySpan[1].Length = 0; } - const uint8_t *GetColumn(unsigned int column, const Span **spans_out) + + uint8_t *MakeTexture(FRenderStyle style) override { - if (spans_out != NULL) + if (style.Flags & STYLEF_RedIsAlpha) { - *spans_out = DummySpan; + return Pixels; + } + else + { + // Since this presents itself to the game as a regular named texture + // it can easily be used on walls and flats and should work as such, + // even if it makes little sense. + auto Pix = new uint8_t[512]; + for (int i = 0; i < 512; i++) + { + Pix[i] = GrayMap[Pixels[i]]; + } + return Pix; } - return Pixels + ((column & WidthMask) << HeightBits); } - const uint8_t *GetPixels() { return Pixels; } - void Unload() {} + + int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL) override + { + bmp->CopyPixelData(x, y, Pixels, Width, Height, Height, 1, rotate, translationtables[TRANSLATION_Standard][8]->Palette, inf); + } + + bool UseBasePalette() override + { + return false; + } + + private: uint8_t Pixels[512]; - Span DummySpan[2]; }; diff --git a/src/textures/textures.h b/src/textures/textures.h index 0aede4562..675a9d4a3 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -588,6 +588,7 @@ class FWorldTexture : public FTexture protected: uint8_t *Pixeldata[2] = { nullptr, nullptr }; Span **Spandata[2] = { nullptr, nullptr }; + uint8_t PixelsAreStatic = 0; // can be set by subclasses which provide static pixel buffers. FWorldTexture(const char *name = nullptr, int lumpnum = -1); ~FWorldTexture();