- enable the texture scalers in software mode.
Currently only implemented for 8 bit in the classic renderer.
This commit is contained in:
parent
656dbc9647
commit
4d8e8e7741
5 changed files with 121 additions and 82 deletions
|
|
@ -37,6 +37,9 @@
|
|||
#include "r_swtexture.h"
|
||||
#include "bitmap.h"
|
||||
#include "m_alloc.h"
|
||||
#include "imagehelpers.h"
|
||||
|
||||
EXTERN_CVAR(Bool, gl_texture_usehires)
|
||||
|
||||
|
||||
FSoftwareTexture *FTexture::GetSoftwareTexture()
|
||||
|
|
@ -56,6 +59,25 @@ FSoftwareTexture *FTexture::GetSoftwareTexture()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FSoftwareTexture::FSoftwareTexture(FTexture *tex)
|
||||
{
|
||||
mTexture = tex;
|
||||
mSource = tex;
|
||||
|
||||
mBufferFlags = (gl_texture_usehires && !tex->isScaled() && tex->GetImage() && !tex->isSprite() ) ? CTF_CheckHires|CTF_ProcessData : CTF_ProcessData;
|
||||
auto info = tex->CreateTexBuffer(0, CTF_CheckOnly| mBufferFlags);
|
||||
mPhysicalWidth = info.mWidth;
|
||||
mPhysicalHeight = info.mHeight;
|
||||
mPhysicalScale = mPhysicalWidth / tex->Width;;
|
||||
CalcBitSize();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FSoftwareTexture::CalcBitSize ()
|
||||
{
|
||||
// WidthBits is rounded down, and HeightBits is rounded up
|
||||
|
|
@ -93,7 +115,23 @@ const uint8_t *FSoftwareTexture::GetPixels(int style)
|
|||
{
|
||||
if (Pixels.Size() == 0 || CheckModified(style))
|
||||
{
|
||||
Pixels = mSource->Get8BitPixels(style);
|
||||
if (mPhysicalScale == 1)
|
||||
{
|
||||
Pixels = mSource->Get8BitPixels(style);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto tempbuffer = mTexture->CreateTexBuffer(0, mBufferFlags);
|
||||
Pixels.Resize(GetWidth()*GetHeight());
|
||||
PalEntry *pe = (PalEntry*)tempbuffer.mBuffer;
|
||||
for (int y = 0; y < GetHeight(); y++)
|
||||
{
|
||||
for (int x = 0; x < GetWidth(); x++)
|
||||
{
|
||||
Pixels[y + x * GetHeight()] = ImageHelpers::RGBToPalette(false, pe[x + y * GetWidth()], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Pixels.Data();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue