diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 409e50f27..152d60b53 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -572,17 +572,17 @@ if( HAVE_MMX ) add_definitions( -DHAVE_MMX=1 ) set( SYSTEM_SOURCES ${SYSTEM_SOURCES} - gl/hqnx_asm/hq2x_asm.cpp - gl/hqnx_asm/hq3x_asm.cpp - gl/hqnx_asm/hq4x_asm.cpp - gl/hqnx_asm/hqnx_asm_Image.cpp) + textures/hires/hqnx_asm/hq2x_asm.cpp + textures/hires/hqnx_asm/hq3x_asm.cpp + textures/hires/hqnx_asm/hq4x_asm.cpp + textures/hires/hqnx_asm/hqnx_asm_Image.cpp) if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) set_source_files_properties( - gl/hqnx_asm/hq2x_asm.cpp - gl/hqnx_asm/hq3x_asm.cpp - gl/hqnx_asm/hq4x_asm.cpp - gl/textures/gl_hqresize.cpp + textures/hires/hqnx_asm/hq2x_asm.cpp + textures/hires/hqnx_asm/hq3x_asm.cpp + textures/hires/hqnx_asm/hq4x_asm.cpp + textures/hires/gl_hqresize.cpp PROPERTIES COMPILE_FLAGS "-mmmx" ) endif( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) endif( HAVE_MMX ) @@ -687,6 +687,9 @@ file( GLOB HEADER_FILES sfmt/*.h sound/*.h textures/*.h + textures/hires/hqnx/*.h + textures/hires/hqnx_asm/*.h + textures/hires/xbr/*.h scripting/*.h scripting/backend/*.h scripting/decorate/*.h @@ -716,9 +719,6 @@ file( GLOB HEADER_FILES gl/api/*.h gl/data/*.h gl/dynlights/*.h - gl/hqnx/*.h - gl/hqnx_asm/*.h - gl/xbr/*.h gl/models/*.h gl/renderer/*.h gl/scene/*.h @@ -833,12 +833,12 @@ set( FASTMATH_SOURCES sound/timiditypp/fft4g.cpp sound/timiditypp/reverb.cpp gl/utility/gl_clock.cpp - gl/hqnx/init.cpp - gl/hqnx/hq2x.cpp - gl/hqnx/hq3x.cpp - gl/hqnx/hq4x.cpp - gl/xbr/xbrz.cpp - gl/xbr/xbrz_old.cpp + textures/hires/hqnx/init.cpp + textures/hires/hqnx/hq2x.cpp + textures/hires/hqnx/hq3x.cpp + textures/hires/hqnx/hq4x.cpp + textures/hires/xbr/xbrz.cpp + textures/hires/xbr/xbrz_old.cpp gl/scene/gl_bsp.cpp gl/scene/gl_fakeflat.cpp gl/scene/gl_clipper.cpp @@ -1087,9 +1087,7 @@ set (PCH_SOURCES gl/textures/gl_hwtexture.cpp gl/textures/gl_texture.cpp gl/textures/gl_material.cpp - gl/textures/gl_hirestex.cpp gl/textures/gl_samplers.cpp - gl/textures/gl_hqresize.cpp menu/joystickmenu.cpp menu/loadsavemenu.cpp menu/menu.cpp @@ -1134,6 +1132,8 @@ set (PCH_SOURCES textures/formats/tgatexture.cpp textures/formats/worldtexture.cpp textures/formats/warptexture.cpp + textures/hires/hqresize.cpp + textures/hires/hirestex.cpp xlat/parse_xlat.cpp fragglescript/t_func.cpp fragglescript/t_load.cpp @@ -1414,9 +1414,6 @@ source_group("Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/menu/.+") source_group("OpenGL Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/.+") source_group("OpenGL Renderer\\Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/data/.+") source_group("OpenGL Renderer\\Dynamic Lights" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/dynlights/.+") -source_group("OpenGL Renderer\\HQ Resize" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/hqnx/.+") -source_group("OpenGL Renderer\\HQ Resize MMX version" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/hqnx_asm/.+") -source_group("OpenGL Renderer\\XBRZ" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/hqnx_asm/.+") source_group("OpenGL Renderer\\Models" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/models/.+") source_group("OpenGL Renderer\\Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/renderer/.+") source_group("OpenGL Renderer\\Scene" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/scene/.+") @@ -1438,8 +1435,12 @@ source_group("Poly Renderer\\Math" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_D source_group("Poly Renderer\\Drawers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/polyrenderer/drawers/.+") source_group("Poly Renderer\\Scene" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/polyrenderer/scene/.+") source_group("Render Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_data/.+") -source_group("Render Data\\Textures\\Formats" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/textures/formats/.+") source_group("Render Data\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/textures/.+") +source_group("Render Data\\Textures\\Hires" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/textures/hires/.+") +source_group("Render Data\\Textures\\Hires\\HQ Resize" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/textures/hires/hqnx/.+") +source_group("Render Data\\Textures\\Hires\\HQ Resize MMX version" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/textures/hires/hqnx_asm/.+") +source_group("Render Data\\Textures\\Hires\\XBRZ" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/textures/hires/xbr/.+") +source_group("Render Data\\Textures\\Formats" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/textures/formats/.+") source_group("Render Data\\Models" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_data/models/.+") source_group("Render Interface" FILES r_defs.h r_renderer.h r_sky.cpp r_sky.h r_state.h r_utility.cpp r_utility.h) source_group("Resource Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/resourcefiles/.+") diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index f5a48842d..59bae9e0b 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -63,7 +63,6 @@ #include "gl/shaders/gl_shadowmapshader.h" #include "gl/shaders/gl_postprocessshader.h" #include "gl/stereo3d/gl_stereo3d.h" -#include "gl/textures/gl_texture.h" #include "gl/textures/gl_material.h" #include "gl/textures/gl_samplers.h" #include "gl/utility/gl_clock.h" diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 0f3bc7ffb..48f5e96c4 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -40,7 +40,6 @@ #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_scenedrawer.h" #include "gl/shaders/gl_shader.h" -#include "gl/textures/gl_texture.h" #include "gl/textures/gl_material.h" #include "gl/utility/gl_clock.h" #include "gl/renderer/gl_quaddrawer.h" diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 9b0073c12..ded02561c 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -72,7 +72,6 @@ #include "gl/scene/gl_scenedrawer.h" #include "gl/scene/gl_portal.h" #include "gl/shaders/gl_shader.h" -#include "gl/textures/gl_texture.h" #include "gl/textures/gl_material.h" diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index bd7d4be61..772387a2d 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -44,7 +44,6 @@ #include "gl/renderer/gl_lightdata.h" #include "gl/data/gl_data.h" #include "gl/textures/gl_hwtexture.h" -#include "gl/textures/gl_texture.h" #include "gl/utility/gl_clock.h" #include "gl/utility/gl_templates.h" #include "gl/gl_functions.h" diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 6975f4d76..d7e722d63 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -43,7 +43,6 @@ #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderer.h" #include "gl/data/gl_data.h" -#include "gl/textures/gl_texture.h" #include "gl/textures/gl_material.h" #include "gl/textures/gl_samplers.h" #include "gl/shaders/gl_shader.h" @@ -70,10 +69,6 @@ FGLTexture::FGLTexture(FTexture * tx, bool expandpatches) tex = tx; mHwTexture = NULL; - HiresLump = -1; - hirestexture = NULL; - bHasColorkey = false; - bIsTransparent = -1; bExpandFlag = expandpatches; lastSampler = 254; lastTranslation = -1; @@ -89,58 +84,6 @@ FGLTexture::FGLTexture(FTexture * tx, bool expandpatches) FGLTexture::~FGLTexture() { Clean(true); - if (hirestexture) delete hirestexture; -} - -//========================================================================== -// -// Checks for the presence of a hires texture replacement and loads it -// -//========================================================================== -unsigned char *FGLTexture::LoadHiresTexture(FTexture *tex, int *width, int *height) -{ - if (bExpandFlag) return NULL; // doesn't work for expanded textures - - if (HiresLump==-1) - { - bHasColorkey = false; - HiresLump = CheckDDPK3(tex); - if (HiresLump < 0) HiresLump = CheckExternalFile(tex, bHasColorkey); - - if (HiresLump >=0) - { - hirestexture = FTexture::CreateTexture(HiresLump, ETextureType::Any); - } - } - if (hirestexture != NULL) - { - int w=hirestexture->GetWidth(); - int h=hirestexture->GetHeight(); - - unsigned char * buffer=new unsigned char[w*(h+1)*4]; - memset(buffer, 0, w * (h+1) * 4); - - FBitmap bmp(buffer, w*4, w, h); - - int trans = hirestexture->CopyTrueColorPixels(&bmp, 0, 0); - hirestexture->CheckTrans(buffer, w*h, trans); - bIsTransparent = hirestexture->gl_info.mIsTransparent; - - if (bHasColorkey) - { - // This is a crappy Doomsday color keyed image - // We have to remove the key manually. :( - uint32_t * dwdata=(uint32_t*)buffer; - for (int i=(w*h);i>0;i--) - { - if (dwdata[i]==0xffffff00 || dwdata[i]==0xffff00ff) dwdata[i]=0; - } - } - *width = w; - *height = h; - return buffer; - } - return NULL; } //=========================================================================== @@ -194,7 +137,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F // by hires textures if (gl_texture_usehires && hirescheck != NULL && !alphatrans) { - buffer = LoadHiresTexture (hirescheck, &w, &h); + buffer = hirescheck->LoadHiresTexture (&w, &h); if (buffer) { return buffer; @@ -227,8 +170,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F int trans = tex->CopyTrueColorPixels(&bmp, exx, exx, 0, translation >= STRange_Min? &inf : nullptr); tex->CheckTrans(buffer, W*H, trans); - isTransparent = tex->gl_info.mIsTransparent; - if (bIsTransparent == -1) bIsTransparent = isTransparent; + isTransparent = tex->bTranslucent; // alpha texture for legacy mode if (alphatrans) { @@ -259,7 +201,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F // [BB] The hqnx upsampling (not the scaleN one) destroys partial transparency, don't upsamle textures using it. // [BB] Potentially upsample the buffer. - return gl_CreateUpsampledTextureBuffer ( tex, buffer, W, H, w, h, !!isTransparent); + return tex->CreateUpsampledTextureBuffer (buffer, W, H, w, h, !!isTransparent); } @@ -553,7 +495,7 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) mMaxBound = -1; mMaterials.Push(this); tx->gl_info.Material[expanded] = this; - if (tx->bHasCanvas) tx->gl_info.mIsTransparent = 0; + if (tx->bHasCanvas) tx->bTranslucent = 0; } //=========================================================================== diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index 32d2049ec..b1a629efc 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -62,20 +62,14 @@ class FGLTexture friend class FMaterial; public: FTexture * tex; - FTexture * hirestexture; - int8_t bIsTransparent; - int HiresLump; private: FHardwareTexture *mHwTexture; - bool bHasColorkey; // only for hires bool bExpandFlag; uint8_t lastSampler; int lastTranslation; - unsigned char * LoadHiresTexture(FTexture *hirescheck, int *width, int *height); - FHardwareTexture *CreateHwTexture(); const FHardwareTexture *Bind(int texunit, int clamp, int translation, FTexture *hirescheck); @@ -222,7 +216,7 @@ public: bool GetTransparent() const { - if (mBaseLayer->bIsTransparent == -1) + if (tex->bTranslucent == -1) { if (!mBaseLayer->tex->bHasCanvas) { @@ -232,10 +226,10 @@ public: } else { - mBaseLayer->bIsTransparent = 0; + tex->bTranslucent = 0; } } - return !!mBaseLayer->bIsTransparent; + return !!tex->bTranslucent; } static void DeleteAll(); diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index 17e9464bf..541204472 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -43,7 +43,6 @@ #include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" -#include "gl/textures/gl_texture.h" #include "gl/textures/gl_material.h" #include "gl/textures/gl_samplers.h" #include "gl/models/gl_models.h" diff --git a/src/gl/textures/gl_texture.h b/src/gl/textures/gl_texture.h index bc52c78c5..22b51610f 100644 --- a/src/gl/textures/gl_texture.h +++ b/src/gl/textures/gl_texture.h @@ -4,9 +4,6 @@ #include "r_defs.h" #include "textures/textures.h" -unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, unsigned char *inputBuffer, const int inWidth, const int inHeight, int &outWidth, int &outHeight, bool hasAlpha ); -int CheckDDPK3(FTexture *tex); -int CheckExternalFile(FTexture *tex, bool & hascolorkey); #endif // __GL_HQRESIZE_H__ diff --git a/src/gl/textures/gl_hirestex.cpp b/src/textures/hires/hirestex.cpp similarity index 86% rename from src/gl/textures/gl_hirestex.cpp rename to src/textures/hires/hirestex.cpp index 51e66ad9b..288e99790 100644 --- a/src/gl/textures/gl_hirestex.cpp +++ b/src/textures/hires/hirestex.cpp @@ -20,19 +20,10 @@ //-------------------------------------------------------------------------- // /* -** Hires texture management +** external hires texture management (i.e. Doomsday style texture packs) ** */ -#ifdef _MSC_VER -#define F_OK 0 /* Check for file existence */ -#define W_OK 2 /* Check for write permission */ -#define R_OK 4 /* Check for read permission */ -#include -#else -#include -#endif - #include "w_wad.h" #include "m_png.h" #include "sbar.h" @@ -42,12 +33,9 @@ #include "doomstat.h" #include "d_main.h" #include "zstring.h" +#include "bitmap.h" #include "textures.h" -#ifndef _WIN32 -#define _access(a,b) access(a,b) -#endif - static int Doom2Wad = -1; // quick'n dirty hack. Should be enough here... @@ -67,7 +55,7 @@ static void SetDoom2Wad() // Checks for the presence of a hires texture replacement in a Doomsday style PK3 // //========================================================================== -int CheckDDPK3(FTexture *tex) +int FTexture::CheckDDPK3() { static const char * doom1texpath[]= { "data/jdoom/textures/doom/%s.%s", "data/jdoom/textures/doom-ult/%s.%s", "data/jdoom/textures/doom1/%s.%s", "data/jdoom/textures/%s.%s", NULL }; @@ -111,7 +99,7 @@ int CheckDDPK3(FTexture *tex) FString checkName; const char ** checklist; - ETextureType useType=tex->UseType; + ETextureType useType=UseType; if (useType==ETextureType::SkinSprite || useType==ETextureType::Decal || useType==ETextureType::FontChar) { @@ -165,7 +153,7 @@ int CheckDDPK3(FTexture *tex) for (const char ** extp=extensions; *extp; extp++) { - checkName.Format(*checklist, tex->Name.GetChars(), *extp); + checkName.Format(*checklist, Name.GetChars(), *extp); int lumpnum = Wads.CheckNumForFullName(checkName); if (lumpnum >= 0) return lumpnum; } @@ -180,7 +168,7 @@ int CheckDDPK3(FTexture *tex) // Checks for the presence of a hires texture replacement // //========================================================================== -int CheckExternalFile(FTexture *tex, bool & hascolorkey) +int FTexture::CheckExternalFile(bool & hascolorkey) { static const char * doom1texpath[]= { "%stextures/doom/doom1/%s.%s", "%stextures/doom/doom1/%s-ck.%s", @@ -292,7 +280,7 @@ int CheckExternalFile(FTexture *tex, bool & hascolorkey) FString checkName; const char ** checklist; - ETextureType useType = tex->UseType; + ETextureType useType = UseType; if (useType == ETextureType::SkinSprite || useType == ETextureType::Decal || useType == ETextureType::FontChar) { @@ -346,7 +334,7 @@ int CheckExternalFile(FTexture *tex, bool & hascolorkey) for (const char ** extp=extensions; *extp; extp++) { - checkName.Format(*checklist, progdir.GetChars(), tex->Name.GetChars(), *extp); + checkName.Format(*checklist, progdir.GetChars(), Name.GetChars(), *extp); if (_access(checkName, 0) == 0) { hascolorkey = !!strstr(checkName, "-ck."); @@ -358,4 +346,54 @@ int CheckExternalFile(FTexture *tex, bool & hascolorkey) return -3; } +//========================================================================== +// +// Checks for the presence of a hires texture replacement and loads it +// +//========================================================================== + +unsigned char *FTexture::LoadHiresTexture(int *width, int *height) +{ + if (HiresLump == -1) + { + bHiresHasColorKey = false; + HiresLump = CheckDDPK3(); + if (HiresLump < 0) HiresLump = CheckExternalFile(bHiresHasColorKey); + + if (HiresLump >= 0) + { + HiresTexture = FTexture::CreateTexture(HiresLump, ETextureType::Any); + HiresTexture->Name = ""; + TexMan.AddTexture(HiresTexture); // let the texture manager manage this. + } + } + if (HiresTexture != nullptr) + { + int w = HiresTexture->GetWidth(); + int h = HiresTexture->GetHeight(); + + unsigned char * buffer = new unsigned char[w*(h + 1) * 4]; + memset(buffer, 0, w * (h + 1) * 4); + + FBitmap bmp(buffer, w * 4, w, h); + + int trans = HiresTexture->CopyTrueColorPixels(&bmp, 0, 0); + HiresTexture->CheckTrans(buffer, w*h, trans); + + if (bHiresHasColorKey) + { + // This is a crappy Doomsday color keyed image + // We have to remove the key manually. :( + uint32_t * dwdata = (uint32_t*)buffer; + for (int i = (w*h); i>0; i--) + { + if (dwdata[i] == 0xffffff00 || dwdata[i] == 0xffff00ff) dwdata[i] = 0; + } + } + *width = w; + *height = h; + return buffer; + } + return nullptr; +} diff --git a/src/gl/hqnx/common.h b/src/textures/hires/hqnx/common.h similarity index 100% rename from src/gl/hqnx/common.h rename to src/textures/hires/hqnx/common.h diff --git a/src/gl/hqnx/hq2x.cpp b/src/textures/hires/hqnx/hq2x.cpp similarity index 100% rename from src/gl/hqnx/hq2x.cpp rename to src/textures/hires/hqnx/hq2x.cpp diff --git a/src/gl/hqnx/hq3x.cpp b/src/textures/hires/hqnx/hq3x.cpp similarity index 100% rename from src/gl/hqnx/hq3x.cpp rename to src/textures/hires/hqnx/hq3x.cpp diff --git a/src/gl/hqnx/hq4x.cpp b/src/textures/hires/hqnx/hq4x.cpp similarity index 100% rename from src/gl/hqnx/hq4x.cpp rename to src/textures/hires/hqnx/hq4x.cpp diff --git a/src/gl/hqnx/hqx.h b/src/textures/hires/hqnx/hqx.h similarity index 100% rename from src/gl/hqnx/hqx.h rename to src/textures/hires/hqnx/hqx.h diff --git a/src/gl/hqnx/init.cpp b/src/textures/hires/hqnx/init.cpp similarity index 100% rename from src/gl/hqnx/init.cpp rename to src/textures/hires/hqnx/init.cpp diff --git a/src/gl/hqnx_asm/hq2x_asm.cpp b/src/textures/hires/hqnx_asm/hq2x_asm.cpp similarity index 100% rename from src/gl/hqnx_asm/hq2x_asm.cpp rename to src/textures/hires/hqnx_asm/hq2x_asm.cpp diff --git a/src/gl/hqnx_asm/hq3x_asm.cpp b/src/textures/hires/hqnx_asm/hq3x_asm.cpp similarity index 100% rename from src/gl/hqnx_asm/hq3x_asm.cpp rename to src/textures/hires/hqnx_asm/hq3x_asm.cpp diff --git a/src/gl/hqnx_asm/hq4x_asm.cpp b/src/textures/hires/hqnx_asm/hq4x_asm.cpp similarity index 100% rename from src/gl/hqnx_asm/hq4x_asm.cpp rename to src/textures/hires/hqnx_asm/hq4x_asm.cpp diff --git a/src/gl/hqnx_asm/hqnx_asm.h b/src/textures/hires/hqnx_asm/hqnx_asm.h similarity index 100% rename from src/gl/hqnx_asm/hqnx_asm.h rename to src/textures/hires/hqnx_asm/hqnx_asm.h diff --git a/src/gl/hqnx_asm/hqnx_asm_Image.cpp b/src/textures/hires/hqnx_asm/hqnx_asm_Image.cpp similarity index 100% rename from src/gl/hqnx_asm/hqnx_asm_Image.cpp rename to src/textures/hires/hqnx_asm/hqnx_asm_Image.cpp diff --git a/src/gl/hqnx_asm/hqnx_asm_Image.h b/src/textures/hires/hqnx_asm/hqnx_asm_Image.h similarity index 100% rename from src/gl/hqnx_asm/hqnx_asm_Image.h rename to src/textures/hires/hqnx_asm/hqnx_asm_Image.h diff --git a/src/gl/textures/gl_hqresize.cpp b/src/textures/hires/hqresize.cpp similarity index 96% rename from src/gl/textures/gl_hqresize.cpp rename to src/textures/hires/hqresize.cpp index 7995c910d..c2cba11ec 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/textures/hires/hqresize.cpp @@ -37,14 +37,13 @@ #include "gl/system/gl_system.h" #include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" -#include "gl/textures/gl_texture.h" #include "c_cvars.h" -#include "gl/hqnx/hqx.h" +#include "hqnx/hqx.h" #ifdef HAVE_MMX -#include "gl/hqnx_asm/hqnx_asm.h" +#include "hqnx_asm/hqnx_asm.h" #endif -#include "gl/xbr/xbrz.h" -#include "gl/xbr/xbrz_old.h" +#include "xbr/xbrz.h" +#include "xbr/xbrz_old.h" #include "parallel_for.h" @@ -314,7 +313,7 @@ static void xbrzOldScale(size_t factor, const uint32_t* src, uint32_t* trg, int // the upsampled buffer. // //=========================================================================== -unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, unsigned char *inputBuffer, const int inWidth, const int inHeight, int &outWidth, int &outHeight, bool hasAlpha ) +unsigned char *FTexture::CreateUpsampledTextureBuffer (unsigned char *inputBuffer, const int inWidth, const int inHeight, int &outWidth, int &outHeight, bool hasAlpha ) { // [BB] Make sure that outWidth and outHeight denote the size of // the returned buffer even if we don't upsample the input buffer. @@ -326,18 +325,18 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u return inputBuffer; // [BB] Don't try to upsample textures based off FCanvasTexture. - if ( inputTexture->bHasCanvas ) + if ( bHasCanvas ) return inputBuffer; // [BB] Don't upsample non-shader handled warped textures. Needs too much memory and time - if (gl.legacyMode && inputTexture->bWarped) + if (gl.legacyMode && bWarped) return inputBuffer; // already scaled? - if (inputTexture->Scale.X >= 2 && inputTexture->Scale.Y >= 2) + if (Scale.X >= 2 && Scale.Y >= 2) return inputBuffer; - switch (inputTexture->UseType) + switch (UseType) { case ETextureType::Sprite: case ETextureType::SkinSprite: diff --git a/src/gl/xbr/xbrz.cpp b/src/textures/hires/xbr/xbrz.cpp similarity index 100% rename from src/gl/xbr/xbrz.cpp rename to src/textures/hires/xbr/xbrz.cpp diff --git a/src/gl/xbr/xbrz.h b/src/textures/hires/xbr/xbrz.h similarity index 100% rename from src/gl/xbr/xbrz.h rename to src/textures/hires/xbr/xbrz.h diff --git a/src/gl/xbr/xbrz_config.h b/src/textures/hires/xbr/xbrz_config.h similarity index 100% rename from src/gl/xbr/xbrz_config.h rename to src/textures/hires/xbr/xbrz_config.h diff --git a/src/gl/xbr/xbrz_config_old.h b/src/textures/hires/xbr/xbrz_config_old.h similarity index 100% rename from src/gl/xbr/xbrz_config_old.h rename to src/textures/hires/xbr/xbrz_config_old.h diff --git a/src/gl/xbr/xbrz_old.cpp b/src/textures/hires/xbr/xbrz_old.cpp similarity index 100% rename from src/gl/xbr/xbrz_old.cpp rename to src/textures/hires/xbr/xbrz_old.cpp diff --git a/src/gl/xbr/xbrz_old.h b/src/textures/hires/xbr/xbrz_old.h similarity index 100% rename from src/gl/xbr/xbrz_old.h rename to src/textures/hires/xbr/xbrz_old.h diff --git a/src/textures/textures.h b/src/textures/textures.h index a076f1441..a94dd2906 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -167,11 +167,13 @@ enum FTextureFormat : uint32_t // Base texture class class FTexture { + public: static FTexture *CreateTexture(const char *name, int lumpnum, ETextureType usetype); static FTexture *CreateTexture(int lumpnum, ETextureType usetype); virtual ~FTexture (); void AddAutoMaterials(); + unsigned char *CreateUpsampledTextureBuffer(unsigned char *inputBuffer, const int inWidth, const int inHeight, int &outWidth, int &outHeight, bool hasAlpha); //int16_t LeftOffset, TopOffset; @@ -186,6 +188,8 @@ public: // Paletted variant FTexture *PalVersion = nullptr; + // External hires texture + FTexture *HiresTexture = nullptr; // Material layers FTexture *Brightmap = nullptr; FTexture *Normal = nullptr; // Normal map texture @@ -213,12 +217,14 @@ public: uint8_t bBrightmapChecked : 1; // Set to 1 if brightmap has been checked uint8_t bGlowing : 1; // Texture glow color int8_t bTranslucent : 2; + bool bHiresHasColorKey = false; // Support for old color-keyed Doomsday textures uint16_t Rotations; int16_t SkyOffset; FloatRect *areas = nullptr; int areacount = 0; PalEntry GlowColor = 0; + int HiresLump = -1; // For external hires textures. struct Span @@ -396,7 +402,13 @@ protected: void GenerateBgraMipmapsFast(); int MipmapLevels() const; + +public: + unsigned char *LoadHiresTexture(int *width, int *height); private: + int CheckDDPK3(); + int CheckExternalFile(bool & hascolorkey); + bool bSWSkyColorDone = false; PalEntry FloorSkyColor; PalEntry CeilingSkyColor; @@ -420,7 +432,6 @@ public: int GlowHeight; int shaderindex; float shaderspeed; - int mIsTransparent:2; bool bAutoGlowing : 1; // Glow info is determined from texture image. bool bFullbright:1; // always draw fullbright bool bSkybox:1; // This is a skybox