- 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.
This commit is contained in:
Christoph Oelckers 2018-03-18 12:54:40 +01:00
parent 1d59a53cd4
commit 494504229f
3 changed files with 36 additions and 16 deletions

View File

@ -139,10 +139,9 @@ union FRenderStyle
bool IsVisible(double alpha) const throw(); bool IsVisible(double alpha) const throw();
private: private:
// Code that compares an actor's render style with a legacy render // Code that compares an actor's render style with a legacy render
// style value should be updated. Making these conversion operators // style value should be updated.
// private will catch those cases. operator ERenderStyle() = delete;
operator ERenderStyle() const { return STYLE_Normal; } operator int() const = delete;
operator int() const { return STYLE_Normal; }
}; };
extern FRenderStyle LegacyRenderStyles[STYLE_Count]; extern FRenderStyle LegacyRenderStyles[STYLE_Count];

View File

@ -49,9 +49,11 @@
#include "r_defs.h" #include "r_defs.h"
#include "r_state.h" #include "r_state.h"
#include "r_data/r_translate.h" #include "r_data/r_translate.h"
#include "r_data/renderstyle.h"
#include "bitmap.h"
class FBarShader : public FTexture class FBarShader : public FWorldTexture
{ {
public: public:
FBarShader(bool vertical, bool reverse) FBarShader(bool vertical, bool reverse)
@ -62,6 +64,7 @@ public:
Width = vertical ? 2 : 256; Width = vertical ? 2 : 256;
Height = vertical ? 256 : 2; Height = vertical ? 256 : 2;
CalcBitSize(); 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. // Fill the column/row with shading values.
// Vertical shaders have have minimum alpha at the top // 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: private:
uint8_t Pixels[512]; uint8_t Pixels[512];
Span DummySpan[2];
}; };

View File

@ -588,6 +588,7 @@ class FWorldTexture : public FTexture
protected: protected:
uint8_t *Pixeldata[2] = { nullptr, nullptr }; uint8_t *Pixeldata[2] = { nullptr, nullptr };
Span **Spandata[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(const char *name = nullptr, int lumpnum = -1);
~FWorldTexture(); ~FWorldTexture();