mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
Made SWPaletteTexture an ImageSource and let it be managed by the texture manager.
This is a lot easier to manage because the palette is just static data that can easily mimic an image.
This commit is contained in:
parent
4cd60fbe99
commit
b32aa60760
2 changed files with 14 additions and 11 deletions
|
@ -33,6 +33,7 @@
|
|||
#include "d_player.h"
|
||||
#include "textures/bitmap.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "image.h"
|
||||
|
||||
// [RH] Base blending values (for e.g. underwater)
|
||||
int BaseBlendR, BaseBlendG, BaseBlendB;
|
||||
|
@ -41,27 +42,23 @@ void InitSoftwareSky();
|
|||
|
||||
|
||||
|
||||
class FSWPaletteTexture : public FTexture
|
||||
class FSWPaletteTexture : public FImageSource
|
||||
{
|
||||
public:
|
||||
FSWPaletteTexture()
|
||||
{
|
||||
Width = 256;
|
||||
Height = 1;
|
||||
UseType = ETextureType::MiscPatch;
|
||||
}
|
||||
|
||||
FBitmap GetBgraBitmap(PalEntry *, int *trans) override
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override
|
||||
{
|
||||
FBitmap bmp;
|
||||
bmp.Create(256, 1);
|
||||
PalEntry *pe = (PalEntry*)bmp.GetPixels();
|
||||
PalEntry *pe = (PalEntry*)bmp->GetPixels();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
pe[i] = GPalette.BaseColors[i].d | 0xff000000;
|
||||
}
|
||||
if (trans) *trans = 0;
|
||||
return bmp;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -74,7 +71,13 @@ public:
|
|||
|
||||
SWSceneDrawer::SWSceneDrawer()
|
||||
{
|
||||
PaletteTexture.reset(new FSWPaletteTexture);
|
||||
auto texid = TexMan.CheckForTexture("@@palette@@", ETextureType::Any);
|
||||
if (!texid.Exists())
|
||||
{
|
||||
auto tex = new FImageTexture(new FSWPaletteTexture, "@@palette@@");
|
||||
texid = TexMan.AddTexture(tex);
|
||||
}
|
||||
PaletteTexture = TexMan.GetTexture(texid);
|
||||
}
|
||||
|
||||
SWSceneDrawer::~SWSceneDrawer()
|
||||
|
@ -98,7 +101,7 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
|
|||
fbtex.reset(new FWrapperTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()));
|
||||
fbtex->GetSystemTexture(0)->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1);
|
||||
auto mat = FMaterial::ValidateTexture(fbtex.get(), false);
|
||||
mat->AddTextureLayer(PaletteTexture.get());
|
||||
mat->AddTextureLayer(PaletteTexture);
|
||||
|
||||
Canvas.reset();
|
||||
Canvas.reset(new DCanvas(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()));
|
||||
|
|
|
@ -12,7 +12,7 @@ class FWrapperTexture;
|
|||
|
||||
class SWSceneDrawer
|
||||
{
|
||||
std::unique_ptr<FTexture> PaletteTexture;
|
||||
FTexture *PaletteTexture;
|
||||
std::unique_ptr<FWrapperTexture> FBTexture[2];
|
||||
int FBTextureIndex = 0;
|
||||
bool FBIsTruecolor = false;
|
||||
|
|
Loading…
Reference in a new issue