mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-14 08:30:49 +00:00
- must merge before continuing...
This commit is contained in:
parent
86d851bc5c
commit
f01d1ec072
8 changed files with 75 additions and 40 deletions
|
@ -326,7 +326,7 @@ void OpenGLFrameBuffer::SetTextureFilterMode()
|
||||||
if (GLRenderer != nullptr && GLRenderer->mSamplerManager != nullptr) GLRenderer->mSamplerManager->SetTextureFilterMode();
|
if (GLRenderer != nullptr && GLRenderer->mSamplerManager != nullptr) GLRenderer->mSamplerManager->SetTextureFilterMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
IHardwareTexture *OpenGLFrameBuffer::CreateHardwareTexture(FTexture *tex)
|
IHardwareTexture *OpenGLFrameBuffer::CreateHardwareTexture()
|
||||||
{
|
{
|
||||||
return new FHardwareTexture(true/*tex->bNoCompress*/);
|
return new FHardwareTexture(true/*tex->bNoCompress*/);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public:
|
||||||
void WriteSavePic(player_t *player, FileWriter *file, int width, int height) override;
|
void WriteSavePic(player_t *player, FileWriter *file, int width, int height) override;
|
||||||
sector_t *RenderView(player_t *player) override;
|
sector_t *RenderView(player_t *player) override;
|
||||||
void SetTextureFilterMode() override;
|
void SetTextureFilterMode() override;
|
||||||
IHardwareTexture *CreateHardwareTexture(FTexture *tex) override;
|
IHardwareTexture *CreateHardwareTexture() override;
|
||||||
void PrecacheMaterial(FMaterial *mat, int translation) override;
|
void PrecacheMaterial(FMaterial *mat, int translation) override;
|
||||||
bool CheckPrecacheMaterial(FMaterial *mat) override;
|
bool CheckPrecacheMaterial(FMaterial *mat) override;
|
||||||
FModelRenderer *CreateModelRenderer(int mli) override;
|
FModelRenderer *CreateModelRenderer(int mli) override;
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "gi.h"
|
#include "gi.h"
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
#include "bitmap.h"
|
#include "bitmap.h"
|
||||||
|
#include "image.h"
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#define _access(a,b) access(a,b)
|
#define _access(a,b) access(a,b)
|
||||||
|
@ -357,7 +358,7 @@ int FTexture::CheckExternalFile(bool & hascolorkey)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
unsigned char *FTexture::LoadHiresTexture(int *width, int *height)
|
bool FTexture::LoadHiresTexture(FTextureBuffer &texbuffer)
|
||||||
{
|
{
|
||||||
if (HiresLump == -1)
|
if (HiresLump == -1)
|
||||||
{
|
{
|
||||||
|
@ -396,10 +397,15 @@ unsigned char *FTexture::LoadHiresTexture(int *width, int *height)
|
||||||
if (dwdata[i] == 0xffffff00 || dwdata[i] == 0xffff00ff) dwdata[i] = 0;
|
if (dwdata[i] == 0xffffff00 || dwdata[i] == 0xffff00ff) dwdata[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*width = w;
|
FContentId contentId;
|
||||||
*height = h;
|
contentId.id = 0;
|
||||||
return buffer;
|
contentId.imageID = HiresTexture->GetImage()->GetId();
|
||||||
|
texbuffer.mBuffer = buffer;
|
||||||
|
texbuffer.mWidth = w;
|
||||||
|
texbuffer.mHeight = h;
|
||||||
|
texbuffer.mContentId = contentId.id;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -348,46 +348,44 @@ static void xbrzOldScale(size_t factor, const uint32_t* src, uint32_t* trg, int
|
||||||
// the upsampled buffer.
|
// the upsampled buffer.
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
unsigned char *FTexture::CreateUpsampledTextureBuffer (unsigned char *inputBuffer, const int inWidth, const int inHeight, int &outWidth, int &outHeight, bool hasAlpha )
|
void FTexture::CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasAlpha)
|
||||||
{
|
{
|
||||||
// [BB] Make sure that outWidth and outHeight denote the size of
|
// [BB] Make sure that outWidth and outHeight denote the size of
|
||||||
// the returned buffer even if we don't upsample the input buffer.
|
// the returned buffer even if we don't upsample the input buffer.
|
||||||
outWidth = inWidth;
|
int outWidth = texbuffer.mWidth;
|
||||||
outHeight = inHeight;
|
int outHeight = texbuffer.mHeight;
|
||||||
|
|
||||||
// [BB] Don't resample if the width or height of the input texture is bigger than gl_texture_hqresize_maxinputsize.
|
// [BB] Don't resample if the width or height of the input texture is bigger than gl_texture_hqresize_maxinputsize.
|
||||||
if ( ( inWidth > gl_texture_hqresize_maxinputsize ) || ( inHeight > gl_texture_hqresize_maxinputsize ) )
|
if ( ( outWidth > gl_texture_hqresize_maxinputsize ) || ( outHeight > gl_texture_hqresize_maxinputsize ) )
|
||||||
return inputBuffer;
|
return;
|
||||||
|
|
||||||
// [BB] Don't try to upsample textures based off FCanvasTexture.
|
// [BB] Don't try to upsample textures based off FCanvasTexture. (This should never get here in the first place!)
|
||||||
if ( bHasCanvas )
|
if ( bHasCanvas )
|
||||||
return inputBuffer;
|
return;
|
||||||
|
|
||||||
// already scaled?
|
// already scaled?
|
||||||
if (Scale.X >= 2 && Scale.Y >= 2)
|
if (Scale.X >= 2 && Scale.Y >= 2)
|
||||||
return inputBuffer;
|
return;
|
||||||
|
|
||||||
switch (UseType)
|
switch (UseType)
|
||||||
{
|
{
|
||||||
case ETextureType::Sprite:
|
case ETextureType::Sprite:
|
||||||
case ETextureType::SkinSprite:
|
case ETextureType::SkinSprite:
|
||||||
if (!(gl_texture_hqresize_targets & 2)) return inputBuffer;
|
if (!(gl_texture_hqresize_targets & 2)) return;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ETextureType::FontChar:
|
case ETextureType::FontChar:
|
||||||
if (!(gl_texture_hqresize_targets & 4)) return inputBuffer;
|
if (!(gl_texture_hqresize_targets & 4)) return;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (!(gl_texture_hqresize_targets & 1)) return inputBuffer;
|
if (!(gl_texture_hqresize_targets & 1)) return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputBuffer)
|
if (texbuffer.mBuffer)
|
||||||
{
|
{
|
||||||
int type = gl_texture_hqresize;
|
int type = gl_texture_hqresize;
|
||||||
outWidth = inWidth;
|
|
||||||
outHeight = inHeight;
|
|
||||||
#ifdef HAVE_MMX
|
#ifdef HAVE_MMX
|
||||||
// hqNx MMX does not preserve the alpha channel so fall back to C-version for such textures
|
// hqNx MMX does not preserve the alpha channel so fall back to C-version for such textures
|
||||||
if (hasAlpha && type > 6 && type <= 9)
|
if (hasAlpha && type > 6 && type <= 9)
|
||||||
|
|
|
@ -64,6 +64,7 @@ public:
|
||||||
bool bMasked = true; // Image (might) have holes (Assume true unless proven otherwise!)
|
bool bMasked = true; // Image (might) have holes (Assume true unless proven otherwise!)
|
||||||
int8_t bTranslucent = -1; // Image has pixels with a non-0/1 value. (-1 means the user needs to do a real check)
|
int8_t bTranslucent = -1; // Image has pixels with a non-0/1 value. (-1 means the user needs to do a real check)
|
||||||
|
|
||||||
|
int GetId() const { return ImageID; }
|
||||||
|
|
||||||
// 'noremap0' will only be looked at by FPatchTexture and forwarded by FMultipatchTexture.
|
// 'noremap0' will only be looked at by FPatchTexture and forwarded by FMultipatchTexture.
|
||||||
|
|
||||||
|
|
|
@ -661,23 +661,22 @@ bool FTexture::ProcessData(unsigned char * buffer, int w, int h, bool ispatch)
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
unsigned char * FTexture::CreateTexBuffer(int translation, int & w, int & h, int flags)
|
FTextureBuffer FTexture::CreateTexBuffer(int translation, int flags)
|
||||||
{
|
{
|
||||||
|
FTextureBuffer result;
|
||||||
|
|
||||||
unsigned char * buffer = nullptr;
|
unsigned char * buffer = nullptr;
|
||||||
int W, H;
|
int W, H;
|
||||||
int isTransparent = -1;
|
int isTransparent = -1;
|
||||||
|
|
||||||
if (flags & CTF_CheckHires)
|
if (flags & CTF_CheckHires)
|
||||||
{
|
{
|
||||||
buffer = LoadHiresTexture(&w, &h);
|
if (LoadHiresTexture(result)) return result;
|
||||||
if (buffer != nullptr)
|
|
||||||
return buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int exx = !!(flags & CTF_Expand);
|
int exx = !!(flags & CTF_Expand);
|
||||||
|
|
||||||
W = w = GetWidth() + 2 * exx;
|
W = GetWidth() + 2 * exx;
|
||||||
H = h = GetHeight() + 2 * exx;
|
H = GetHeight() + 2 * exx;
|
||||||
|
|
||||||
buffer = new unsigned char[W*(H + 1) * 4];
|
buffer = new unsigned char[W*(H + 1) * 4];
|
||||||
memset(buffer, 0, W * (H + 1) * 4);
|
memset(buffer, 0, W * (H + 1) * 4);
|
||||||
|
@ -700,13 +699,24 @@ unsigned char * FTexture::CreateTexBuffer(int translation, int & w, int & h, int
|
||||||
// A translated image is not conclusive for setting the texture's transparency info.
|
// A translated image is not conclusive for setting the texture's transparency info.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FContentId builder;
|
||||||
|
builder.id = 0;
|
||||||
|
builder.imageID = GetImage()->GetId();
|
||||||
|
builder.translation = MAX(0, translation);
|
||||||
|
builder.expand = exx;
|
||||||
|
|
||||||
|
result.mBuffer = buffer;
|
||||||
|
result.mWidth = W;
|
||||||
|
result.mHeight = H;
|
||||||
|
result.mContentId = builder.id;
|
||||||
|
|
||||||
if (flags & CTF_ProcessData)
|
if (flags & CTF_ProcessData)
|
||||||
{
|
{
|
||||||
buffer = CreateUpsampledTextureBuffer(buffer, W, H, w, h, !!isTransparent);
|
CreateUpsampledTextureBuffer(result, !!isTransparent);
|
||||||
ProcessData(buffer, w, h, false);
|
ProcessData(result.mBuffer, result.mWidth, result.mHeight, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buffer;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
|
@ -226,6 +226,31 @@ namespace OpenGLRenderer
|
||||||
class FHardwareTexture;
|
class FHardwareTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
union FContentId
|
||||||
|
{
|
||||||
|
uint64_t id;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned imageID : 24;
|
||||||
|
unsigned translation : 16;
|
||||||
|
unsigned expand : 1;
|
||||||
|
unsigned scaler : 4;
|
||||||
|
unsigned scalefactor : 4;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FTextureBuffer
|
||||||
|
{
|
||||||
|
uint8_t *mBuffer = nullptr;
|
||||||
|
int mWidth = 0;
|
||||||
|
int mHeight = 0;
|
||||||
|
uint64_t mContentId = 0; // unique content identifier. (Two images created from the same image source with the same settings will return the same value.)
|
||||||
|
|
||||||
|
FTextureBuffer()
|
||||||
|
{
|
||||||
|
if (mBuffer) delete[] mBuffer;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Base texture class
|
// Base texture class
|
||||||
class FTexture
|
class FTexture
|
||||||
|
@ -258,12 +283,7 @@ public:
|
||||||
virtual ~FTexture ();
|
virtual ~FTexture ();
|
||||||
virtual FImageSource *GetImage() const { return nullptr; }
|
virtual FImageSource *GetImage() const { return nullptr; }
|
||||||
void AddAutoMaterials();
|
void AddAutoMaterials();
|
||||||
unsigned char *CreateUpsampledTextureBuffer(unsigned char *inputBuffer, const int inWidth, const int inHeight, int &outWidth, int &outHeight, bool hasAlpha);
|
void CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasAlpha);
|
||||||
|
|
||||||
// These should only be used in places where the texture scaling must be ignored and absolutely nowhere else!
|
|
||||||
// Preferably all code depending on the physical texture size should be rewritten, unless it is part of the software rasterizer.
|
|
||||||
//int GetPixelWidth() { return GetWidth(); }
|
|
||||||
//int GetPixelHeight() { return GetHeight(); }
|
|
||||||
|
|
||||||
// These are mainly meant for 2D code which only needs logical information about the texture to position it properly.
|
// These are mainly meant for 2D code which only needs logical information about the texture to position it properly.
|
||||||
int GetDisplayWidth() { return GetScaledWidth(); }
|
int GetDisplayWidth() { return GetScaledWidth(); }
|
||||||
|
@ -466,13 +486,13 @@ protected:
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
unsigned char * CreateTexBuffer(int translation, int & w, int & h, int flags = 0);
|
FTextureBuffer CreateTexBuffer(int translation, int flags = 0);
|
||||||
bool GetTranslucency();
|
bool GetTranslucency();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int CheckDDPK3();
|
int CheckDDPK3();
|
||||||
int CheckExternalFile(bool & hascolorkey);
|
int CheckExternalFile(bool & hascolorkey);
|
||||||
unsigned char *LoadHiresTexture(int *width, int *height);
|
bool LoadHiresTexture(FTextureBuffer &texbuffer);
|
||||||
|
|
||||||
bool bSWSkyColorDone = false;
|
bool bSWSkyColorDone = false;
|
||||||
PalEntry FloorSkyColor;
|
PalEntry FloorSkyColor;
|
||||||
|
|
|
@ -424,7 +424,7 @@ public:
|
||||||
// Delete any resources that need to be deleted after restarting with a different IWAD
|
// Delete any resources that need to be deleted after restarting with a different IWAD
|
||||||
virtual void CleanForRestart() {}
|
virtual void CleanForRestart() {}
|
||||||
virtual void SetTextureFilterMode() {}
|
virtual void SetTextureFilterMode() {}
|
||||||
virtual IHardwareTexture *CreateHardwareTexture(FTexture *tex) { return nullptr; }
|
virtual IHardwareTexture *CreateHardwareTexture() { return nullptr; }
|
||||||
virtual bool CheckPrecacheMaterial(FMaterial *mat) { return true; }
|
virtual bool CheckPrecacheMaterial(FMaterial *mat) { return true; }
|
||||||
virtual void PrecacheMaterial(FMaterial *mat, int translation) {}
|
virtual void PrecacheMaterial(FMaterial *mat, int translation) {}
|
||||||
virtual FModelRenderer *CreateModelRenderer(int mli) { return nullptr; }
|
virtual FModelRenderer *CreateModelRenderer(int mli) { return nullptr; }
|
||||||
|
|
Loading…
Reference in a new issue