- texture manager update from Raze
* new texture format: ANM - this reads the first frame of a Build-ANM movie as a texture. * some preparations for indexed (paletted) rendering. * optimization of the patch texture checker - do not read in the entire file if checking the initial header is sufficient for rejecting it.
This commit is contained in:
parent
96ceb11af0
commit
528e4e46b3
15 changed files with 712 additions and 59 deletions
|
|
@ -29,6 +29,13 @@
|
|||
#include "c_cvars.h"
|
||||
#include "v_video.h"
|
||||
|
||||
static IHardwareTexture* (*layercallback)(int layer, int translation);
|
||||
|
||||
void FMaterial::SetLayerCallback(IHardwareTexture* (*cb)(int layer, int translation))
|
||||
{
|
||||
layercallback = cb;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Constructor
|
||||
|
|
@ -42,8 +49,9 @@ FMaterial::FMaterial(FGameTexture * tx, int scaleflags)
|
|||
auto imgtex = tx->GetTexture();
|
||||
mTextureLayers.Push({ imgtex, scaleflags, -1 });
|
||||
|
||||
if (tx->GetUseType() == ETextureType::SWCanvas && static_cast<FWrapperTexture*>(imgtex)->GetColorFormat() == 0)
|
||||
if ((tx->GetUseType() == ETextureType::SWCanvas && static_cast<FWrapperTexture*>(imgtex)->GetColorFormat() == 0) || (scaleflags & CTF_Indexed))
|
||||
{
|
||||
mTextureLayers[0].scaleFlags |= CTF_Indexed;
|
||||
mShaderIndex = SHADER_Paletted;
|
||||
}
|
||||
else if (tx->isHardwareCanvas())
|
||||
|
|
@ -149,12 +157,25 @@ FMaterial::~FMaterial()
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
IHardwareTexture *FMaterial::GetLayer(int i, int translation, MaterialLayerInfo **pLayer) const
|
||||
IHardwareTexture* FMaterial::GetLayer(int i, int translation, MaterialLayerInfo** pLayer) const
|
||||
{
|
||||
auto &layer = mTextureLayers[i];
|
||||
if (pLayer) *pLayer = &layer;
|
||||
|
||||
if (layer.layerTexture) return layer.layerTexture->GetHardwareTexture(translation, layer.scaleFlags);
|
||||
if (mShaderIndex == SHADER_Paletted && i > 0 && layercallback)
|
||||
{
|
||||
static MaterialLayerInfo deflayer = { nullptr, 0, CLAMP_XY };
|
||||
if (i == 1 || i == 2)
|
||||
{
|
||||
if (pLayer) *pLayer = &deflayer;
|
||||
//This must be done with a user supplied callback because we cannot set up the rules for palette data selection here
|
||||
return layercallback(i, translation);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& layer = mTextureLayers[i];
|
||||
if (pLayer) *pLayer = &layer;
|
||||
if (mShaderIndex == SHADER_Paletted) translation = -1;
|
||||
if (layer.layerTexture) return layer.layerTexture->GetHardwareTexture(translation, layer.scaleFlags);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -169,6 +190,7 @@ FMaterial * FMaterial::ValidateTexture(FGameTexture * gtex, int scaleflags, bool
|
|||
{
|
||||
if (gtex && gtex->isValid())
|
||||
{
|
||||
if (scaleflags & CTF_Indexed) scaleflags = CTF_Indexed;
|
||||
if (!gtex->expandSprites()) scaleflags &= ~CTF_Expand;
|
||||
|
||||
FMaterial *hwtex = gtex->Material[scaleflags];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue