mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-01 08:31:14 +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 "d_player.h"
|
||||||
#include "textures/bitmap.h"
|
#include "textures/bitmap.h"
|
||||||
#include "swrenderer/scene/r_light.h"
|
#include "swrenderer/scene/r_light.h"
|
||||||
|
#include "image.h"
|
||||||
|
|
||||||
// [RH] Base blending values (for e.g. underwater)
|
// [RH] Base blending values (for e.g. underwater)
|
||||||
int BaseBlendR, BaseBlendG, BaseBlendB;
|
int BaseBlendR, BaseBlendG, BaseBlendB;
|
||||||
|
@ -41,27 +42,23 @@ void InitSoftwareSky();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class FSWPaletteTexture : public FTexture
|
class FSWPaletteTexture : public FImageSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FSWPaletteTexture()
|
FSWPaletteTexture()
|
||||||
{
|
{
|
||||||
Width = 256;
|
Width = 256;
|
||||||
Height = 1;
|
Height = 1;
|
||||||
UseType = ETextureType::MiscPatch;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FBitmap GetBgraBitmap(PalEntry *, int *trans) override
|
int CopyPixels(FBitmap *bmp, int conversion) override
|
||||||
{
|
{
|
||||||
FBitmap bmp;
|
PalEntry *pe = (PalEntry*)bmp->GetPixels();
|
||||||
bmp.Create(256, 1);
|
|
||||||
PalEntry *pe = (PalEntry*)bmp.GetPixels();
|
|
||||||
for (int i = 0; i < 256; i++)
|
for (int i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
pe[i] = GPalette.BaseColors[i].d | 0xff000000;
|
pe[i] = GPalette.BaseColors[i].d | 0xff000000;
|
||||||
}
|
}
|
||||||
if (trans) *trans = 0;
|
return 0;
|
||||||
return bmp;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,7 +71,13 @@ public:
|
||||||
|
|
||||||
SWSceneDrawer::SWSceneDrawer()
|
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()
|
SWSceneDrawer::~SWSceneDrawer()
|
||||||
|
@ -98,7 +101,7 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
|
||||||
fbtex.reset(new FWrapperTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()));
|
fbtex.reset(new FWrapperTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()));
|
||||||
fbtex->GetSystemTexture(0)->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1);
|
fbtex->GetSystemTexture(0)->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1);
|
||||||
auto mat = FMaterial::ValidateTexture(fbtex.get(), false);
|
auto mat = FMaterial::ValidateTexture(fbtex.get(), false);
|
||||||
mat->AddTextureLayer(PaletteTexture.get());
|
mat->AddTextureLayer(PaletteTexture);
|
||||||
|
|
||||||
Canvas.reset();
|
Canvas.reset();
|
||||||
Canvas.reset(new DCanvas(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()));
|
Canvas.reset(new DCanvas(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()));
|
||||||
|
|
|
@ -12,7 +12,7 @@ class FWrapperTexture;
|
||||||
|
|
||||||
class SWSceneDrawer
|
class SWSceneDrawer
|
||||||
{
|
{
|
||||||
std::unique_ptr<FTexture> PaletteTexture;
|
FTexture *PaletteTexture;
|
||||||
std::unique_ptr<FWrapperTexture> FBTexture[2];
|
std::unique_ptr<FWrapperTexture> FBTexture[2];
|
||||||
int FBTextureIndex = 0;
|
int FBTextureIndex = 0;
|
||||||
bool FBIsTruecolor = false;
|
bool FBIsTruecolor = false;
|
||||||
|
|
Loading…
Reference in a new issue