mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 00:42:08 +00:00
- moved palette manager for indexed textures out of glbackend
This commit is contained in:
parent
9a46fa7ef0
commit
7c4e9ea87e
6 changed files with 53 additions and 44 deletions
|
@ -1022,7 +1022,6 @@ set (FASTMATH_SOURCES ${FASTMATH_SOURCES})
|
|||
set (PCH_SOURCES
|
||||
|
||||
glbackend/glbackend.cpp
|
||||
glbackend/gl_palmanager.cpp
|
||||
glbackend/gl_texture.cpp
|
||||
|
||||
thirdparty/src/md4.cpp
|
||||
|
@ -1081,6 +1080,7 @@ set (PCH_SOURCES
|
|||
core/rendering/hw_entrypoint.cpp
|
||||
core/rendering/hw_models.cpp
|
||||
core/rendering/hw_voxels.cpp
|
||||
core/rendering/hw_palmanager.cpp
|
||||
core/rendering/scene/hw_clipper.cpp
|
||||
core/rendering/scene/hw_walls.cpp
|
||||
core/rendering/scene/hw_flats.cpp
|
||||
|
|
|
@ -75,6 +75,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "gi.h"
|
||||
#include "gamefuncs.h"
|
||||
#include "hw_voxels.h"
|
||||
#include "hw_palmanager.h"
|
||||
|
||||
CVAR(Bool, autoloadlights, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, autoloadbrightmaps, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
|
@ -576,9 +577,9 @@ int GameMain()
|
|||
C_DeinitConsole();
|
||||
V_ClearFonts();
|
||||
voxClear();
|
||||
ClearPalManager();
|
||||
TexMan.DeleteAll();
|
||||
TileFiles.CloseAll(); // delete the texture data before shutting down graphics.
|
||||
GLInterface.Deinit();
|
||||
I_ShutdownGraphics();
|
||||
freeallmodels();
|
||||
if (gi)
|
||||
|
@ -943,6 +944,8 @@ int RunGame()
|
|||
lookups.postLoadTables();
|
||||
PostLoadSetup();
|
||||
lookups.postLoadLookups();
|
||||
FMaterial::SetLayerCallback(setpalettelayer);
|
||||
|
||||
V_Init2();
|
||||
twod->Begin(screen->GetWidth(), screen->GetHeight());
|
||||
twod->End();
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
#include <memory>
|
||||
#include "m_crc32.h"
|
||||
#include "glbackend.h"
|
||||
#include "hw_palmanager.h"
|
||||
|
||||
#include "resourcefile.h"
|
||||
#include "imagehelpers.h"
|
||||
|
@ -44,6 +44,8 @@
|
|||
#include "build.h"
|
||||
#include "v_video.h"
|
||||
|
||||
static PaletteManager* palmanager;
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// This class manages the hardware data for the indexed render mode.
|
||||
|
@ -138,4 +140,24 @@ IHardwareTexture* PaletteManager::GetLookup(int index)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
IHardwareTexture *setpalettelayer(int layer, int translation)
|
||||
{
|
||||
if (!palmanager) palmanager = new PaletteManager;
|
||||
if (layer == 1)
|
||||
return palmanager->GetPalette(GetTranslationType(translation) - Translation_Remap);
|
||||
else if (layer == 2)
|
||||
return palmanager->GetLookup(GetTranslationIndex(translation));
|
||||
else return nullptr;
|
||||
}
|
||||
|
||||
void ClearPalManager()
|
||||
{
|
||||
if (palmanager) delete palmanager;
|
||||
palmanager = nullptr;
|
||||
}
|
24
source/core/rendering/hw_palmanager.h
Normal file
24
source/core/rendering/hw_palmanager.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
|
||||
#include "gl_hwtexture.h"
|
||||
|
||||
struct palette_t;
|
||||
|
||||
class PaletteManager
|
||||
{
|
||||
IHardwareTexture* palettetextures[256] = {};
|
||||
IHardwareTexture* lookuptextures[256] = {};
|
||||
|
||||
unsigned FindPalswap(const uint8_t* paldata, palette_t& fadecolor);
|
||||
|
||||
public:
|
||||
~PaletteManager();
|
||||
void DeleteAll();
|
||||
IHardwareTexture *GetPalette(int index);
|
||||
IHardwareTexture* GetLookup(int index);
|
||||
};
|
||||
|
||||
|
||||
IHardwareTexture* setpalettelayer(int layer, int translation);
|
||||
void ClearPalManager();
|
||||
|
|
@ -70,33 +70,16 @@ void Draw2D(F2DDrawer* drawer, FRenderState& state);
|
|||
GLInstance GLInterface;
|
||||
|
||||
GLInstance::GLInstance()
|
||||
:palmanager(this)
|
||||
{
|
||||
VSMatrix mat(0);
|
||||
matrixArray.Push(mat);
|
||||
}
|
||||
|
||||
IHardwareTexture *setpalettelayer(int layer, int translation)
|
||||
{
|
||||
if (layer == 1)
|
||||
return GLInterface.palmanager.GetPalette(GetTranslationType(translation) - Translation_Remap);
|
||||
else if (layer == 2)
|
||||
return GLInterface.palmanager.GetLookup(GetTranslationIndex(translation));
|
||||
else return nullptr;
|
||||
}
|
||||
|
||||
void GLInstance::Init(int ydim)
|
||||
{
|
||||
FMaterial::SetLayerCallback(setpalettelayer);
|
||||
new(&renderState) PolymostRenderState; // reset to defaults.
|
||||
}
|
||||
|
||||
void GLInstance::Deinit()
|
||||
{
|
||||
palmanager.DeleteAll();
|
||||
lastPalswapIndex = -1;
|
||||
}
|
||||
|
||||
void GLInstance::Draw(EDrawType type, size_t start, size_t count)
|
||||
{
|
||||
assert (BufferLock > 0);
|
||||
|
|
|
@ -21,25 +21,6 @@ class F2DDrawer;
|
|||
struct palette_t;
|
||||
extern int xdim, ydim;
|
||||
|
||||
class PaletteManager
|
||||
{
|
||||
IHardwareTexture* palettetextures[256] = {};
|
||||
IHardwareTexture* lookuptextures[256] = {};
|
||||
|
||||
GLInstance* const inst;
|
||||
|
||||
unsigned FindPalswap(const uint8_t* paldata, palette_t& fadecolor);
|
||||
|
||||
public:
|
||||
PaletteManager(GLInstance *inst_) : inst(inst_)
|
||||
{}
|
||||
~PaletteManager();
|
||||
void DeleteAll();
|
||||
IHardwareTexture *GetPalette(int index);
|
||||
IHardwareTexture* GetLookup(int index);
|
||||
};
|
||||
|
||||
|
||||
struct glinfo_t {
|
||||
float maxanisotropy;
|
||||
};
|
||||
|
@ -75,9 +56,7 @@ class GLInstance
|
|||
friend IHardwareTexture* setpalettelayer(int layer, int translation);
|
||||
|
||||
public:
|
||||
TArray<PolymostRenderState> rendercommands;
|
||||
PaletteManager palmanager;
|
||||
int lastPalswapIndex = -1;
|
||||
TArray<PolymostRenderState> rendercommands;
|
||||
FGameTexture* currentTexture = nullptr;
|
||||
int MatrixChange = 0;
|
||||
|
||||
|
@ -90,8 +69,6 @@ public:
|
|||
|
||||
void Init(int y);
|
||||
|
||||
void Deinit();
|
||||
|
||||
static int GetTexDimension(int value)
|
||||
{
|
||||
//if (value > gl.max_texturesize) return gl.max_texturesize;
|
||||
|
|
Loading…
Reference in a new issue