diff --git a/src/gl/scene/gl_swscene.cpp b/src/gl/scene/gl_swscene.cpp index 5a67324b1..c76c44b79 100644 --- a/src/gl/scene/gl_swscene.cpp +++ b/src/gl/scene/gl_swscene.cpp @@ -65,7 +65,6 @@ public: class FSWSceneTexture : public FTexture { public: - FHardwareTexture *hwtex; FSWSceneTexture(int w, int h, int bits) { @@ -73,9 +72,8 @@ public: Height = h; WidthBits = bits; UseType = ETextureType::SWCanvas; - - hwtex = new FHardwareTexture(true); - new FGLTexture(this, hwtex); + bNoCompress = true; + gl_info.SystemTexture[0] = screen->CreateHardwareTexture(this); } // This is just a wrapper around the hardware texture and should never call the bitmap getters - if it does, something is wrong. @@ -101,20 +99,23 @@ SWSceneDrawer::~SWSceneDrawer() void SWSceneDrawer::RenderView(player_t *player) { DCanvas buffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()); - if (FBTexture == nullptr || FBTexture->hwtex == nullptr || FBTexture->GetWidth() != screen->GetWidth() || FBTexture->GetHeight() != screen->GetHeight() || (V_IsTrueColor() ? 1:0) != FBTexture->WidthBits) + if (FBTexture == nullptr || FBTexture->gl_info.SystemTexture[0] == nullptr || + FBTexture->GetWidth() != screen->GetWidth() || + FBTexture->GetHeight() != screen->GetHeight() || + (V_IsTrueColor() ? 1:0) != FBTexture->WidthBits) { // This manually constructs its own material here. if (FBTexture != nullptr) delete FBTexture; FBTexture = new FSWSceneTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()); - FBTexture->hwtex->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1); + FBTexture->gl_info.SystemTexture[0]->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1); auto mat = FMaterial::ValidateTexture(FBTexture, false); mat->AddTextureLayer(PaletteTexture); } - auto buf = FBTexture->hwtex->MapBuffer(); + auto buf = FBTexture->gl_info.SystemTexture[0]->MapBuffer(); if (!buf) I_FatalError("Unable to map buffer for software rendering"); buffer.SetBuffer(screen->GetWidth(), screen->GetHeight(), screen->GetWidth(), buf); SWRenderer->RenderView(player, &buffer); - FBTexture->hwtex->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, 0, "swbuffer"); + FBTexture->gl_info.SystemTexture[0]->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, 0, "swbuffer"); auto map = swrenderer::CameraLight::Instance()->ShaderColormap(); screen->Begin2D(false); diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 36e6343bd..b4a1721b6 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -388,6 +388,12 @@ void OpenGLFrameBuffer::SetTextureFilterMode() if (GLRenderer != nullptr && GLRenderer->mSamplerManager != nullptr) GLRenderer->mSamplerManager->SetTextureFilterMode(); } +FHardwareTexture *OpenGLFrameBuffer::CreateHardwareTexture(FTexture *tex) +{ + return new FHardwareTexture(tex->bNoCompress); +} + + void OpenGLFrameBuffer::UpdatePalette() { if (GLRenderer) diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h index 6cd1efc34..d21ee0230 100644 --- a/src/gl/system/gl_framebuffer.h +++ b/src/gl/system/gl_framebuffer.h @@ -43,6 +43,7 @@ public: void WriteSavePic(player_t *player, FileWriter *file, int width, int height) override; void RenderView(player_t *player) override; void SetTextureFilterMode() override; + FHardwareTexture *CreateHardwareTexture(FTexture *tex) override; // Retrieves a buffer containing image data for a screenshot. // Hint: Pitch can be negative for upside-down images, in which case buffer diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 3881da78f..fa55339d7 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -35,6 +35,7 @@ #include "gl/system/gl_debug.h" #include "gl/renderer/gl_renderer.h" #include "gl/textures/gl_material.h" +#include "gl/textures/gl_samplers.h" extern TexFilter_s TexFilter[]; @@ -491,3 +492,64 @@ void FHardwareTexture::BindToFrameBuffer(int width, int height) glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer(width, height)); } + +//=========================================================================== +// +// Binds a texture to the renderer +// +//=========================================================================== + +bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, int translation, int flags) +{ + int usebright = false; + + if (translation <= 0) + { + translation = -translation; + } + else + { + auto remap = TranslationToTable(translation); + translation = remap == nullptr ? 0 : remap->GetUniqueIndex(); + } + + bool needmipmap = (clampmode <= CLAMP_XY); + + // Texture has become invalid + if ((!tex->bHasCanvas && (!tex->bWarped || gl.legacyMode)) && tex->CheckModified(DefaultRenderStyle())) + { + Clean(true); + } + + // Bind it to the system. + if (!Bind(texunit, translation, needmipmap)) + { + + int w = 0, h = 0; + + // Create this texture + unsigned char * buffer = nullptr; + + if (!tex->bHasCanvas) + { + if (gl.legacyMode) flags |= CTF_MaybeWarped; + buffer = tex->CreateTexBuffer(translation, w, h, flags | CTF_ProcessData); + } + else + { + w = tex->GetWidth(); + h = tex->GetHeight(); + } + if (!CreateTexture(buffer, w, h, texunit, needmipmap, translation, "FHardwareTexture.BindOrCreate")) + { + // could not create texture + delete[] buffer; + return false; + } + delete[] buffer; + } + if (tex->bHasCanvas) static_cast(tex)->NeedUpdate(); + GLRenderer->mSamplerManager->Bind(texunit, clampmode, 255); + return true; +} + diff --git a/src/gl/textures/gl_hwtexture.h b/src/gl/textures/gl_hwtexture.h index 9b2fbf681..5a0ba827c 100644 --- a/src/gl/textures/gl_hwtexture.h +++ b/src/gl/textures/gl_hwtexture.h @@ -83,6 +83,8 @@ public: void BindToFrameBuffer(int w, int h); unsigned int Bind(int texunit, int translation, bool needmipmap); + bool BindOrCreate(FTexture *tex, int texunit, int clampmode, int translation, int flags); + void AllocateBuffer(int w, int h, int texelsize); uint8_t *MapBuffer(); diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 92b648c9e..d93a3a5f8 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -26,13 +26,11 @@ #include "sbar.h" #include "stats.h" #include "r_utility.h" -#include "textures/warpbuffer.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/renderer/gl_renderer.h" #include "gl/textures/gl_material.h" -#include "gl/textures/gl_samplers.h" #include "gl/shaders/gl_shader.h" EXTERN_CVAR(Bool, gl_render_precise) @@ -40,185 +38,6 @@ EXTERN_CVAR(Int, gl_lightmode) EXTERN_CVAR(Bool, gl_precache) EXTERN_CVAR(Bool, gl_texture_usehires) -//=========================================================================== -// -// The GL texture maintenance class -// -//=========================================================================== - -//=========================================================================== -// -// Constructor -// -//=========================================================================== -FGLTexture::FGLTexture(FTexture * tx, bool expandpatches) -{ - assert(tx->gl_info.SystemTexture[expandpatches] == NULL); - tex = tx; - - mHwTexture = NULL; - lastSampler = 254; - lastTranslation = -1; - tex->gl_info.SystemTexture[expandpatches] = this; -} - -//=========================================================================== -// -// Constructor 2 for the SW framebuffer which provides its own hardware texture. -// -//=========================================================================== -FGLTexture::FGLTexture(FTexture * tx, FHardwareTexture *hwtex) -{ - assert(tx->gl_info.SystemTexture[0] == NULL); - tex = tx; - - mHwTexture = hwtex; - lastSampler = 254; - lastTranslation = -1; - tex->gl_info.SystemTexture[0] = this; -} - -//=========================================================================== -// -// Destructor -// -//=========================================================================== - -FGLTexture::~FGLTexture() -{ - Clean(true); - for (auto & i : tex->gl_info.SystemTexture) if (i == this) i = nullptr; -} - -//=========================================================================== -// -// Deletes all allocated resources -// -//=========================================================================== - -void FGLTexture::Clean(bool all) -{ - if (mHwTexture != nullptr) - { - if (!all) mHwTexture->Clean(false); - else - { - delete mHwTexture; - mHwTexture = nullptr; - } - - lastSampler = 253; - lastTranslation = -1; - } -} - - -void FGLTexture::CleanUnused(SpriteHits &usedtranslations) -{ - if (mHwTexture != nullptr) - { - mHwTexture->CleanUnused(usedtranslations); - lastSampler = 253; - lastTranslation = -1; - } -} - - -//=========================================================================== -// -// Create hardware texture for world use -// -//=========================================================================== - -FHardwareTexture *FGLTexture::CreateHwTexture() -{ - if (tex->UseType==ETextureType::Null) return NULL; // Cannot register a NULL texture - if (mHwTexture == NULL) - { - mHwTexture = new FHardwareTexture(tex->bNoCompress); - } - return mHwTexture; -} - -//=========================================================================== -// -// Binds a texture to the renderer -// -//=========================================================================== - -bool FGLTexture::Bind(int texunit, int clampmode, int translation, int flags) -{ - int usebright = false; - - if (translation <= 0) - { - translation = -translation; - } - else - { - auto remap = TranslationToTable(translation); - translation = remap == nullptr ? 0 : remap->GetUniqueIndex(); - } - - bool needmipmap = (clampmode <= CLAMP_XY); - - FHardwareTexture *hwtex = CreateHwTexture(); - - if (hwtex) - { - // Texture has become invalid - if ((!tex->bHasCanvas && (!tex->bWarped || gl.legacyMode)) && tex->CheckModified(DefaultRenderStyle())) - { - Clean(true); - hwtex = CreateHwTexture(); - } - - // Bind it to the system. - if (!hwtex->Bind(texunit, translation, needmipmap)) - { - - int w=0, h=0; - - // Create this texture - unsigned char * buffer = nullptr; - - if (!tex->bHasCanvas) - { - buffer = tex->CreateTexBuffer(translation, w, h, flags | CTF_ProcessData); - if (tex->bWarped && gl.legacyMode && w*h <= 256*256) // do not software-warp larger textures, especially on the old systems that still need this fallback. - { - // need to do software warping - FWarpTexture *wt = static_cast(tex); - unsigned char *warpbuffer = new unsigned char[w*h*4]; - WarpBuffer((uint32_t*)warpbuffer, (const uint32_t*)buffer, w, h, wt->WidthOffsetMultiplier, wt->HeightOffsetMultiplier, screen->FrameTime, wt->Speed, tex->bWarped); - delete[] buffer; - buffer = warpbuffer; - wt->GenTime[0] = screen->FrameTime; - } - } - else - { - w = tex->GetWidth(); - h = tex->GetHeight(); - } - if (!hwtex->CreateTexture(buffer, w, h, texunit, needmipmap, translation, "FGLTexture.Bind")) - { - // could not create texture - delete[] buffer; - return false; - } - delete[] buffer; - } - if (tex->bHasCanvas) static_cast(tex)->NeedUpdate(); - if (translation != lastTranslation) lastSampler = 254; - if (lastSampler != clampmode) - lastSampler = GLRenderer->mSamplerManager->Bind(texunit, clampmode, lastSampler); - lastTranslation = translation; - return true; - } - return false; -} - //=========================================================================== // // @@ -288,18 +107,18 @@ float FTexCoordInfo::TextureAdjustWidth() const // // //=========================================================================== -FGLTexture * FMaterial::ValidateSysTexture(FTexture * tex, bool expand) +FHardwareTexture * FMaterial::ValidateSysTexture(FTexture * tex, bool expand) { if (tex && tex->UseType!=ETextureType::Null) { - FGLTexture *gltex = tex->gl_info.SystemTexture[expand]; - if (gltex == NULL) + FHardwareTexture *gltex = tex->gl_info.SystemTexture[expand]; + if (gltex == nullptr) { - gltex = new FGLTexture(tex, expand); + gltex = tex->gl_info.SystemTexture[expand] = screen->CreateHardwareTexture(tex); } return gltex; } - return NULL; + return nullptr; } //=========================================================================== @@ -625,7 +444,7 @@ void FMaterial::Bind(int clampmode, int translation) // Textures that are already scaled in the texture lump will not get replaced by hires textures. int flags = mExpanded? CTF_Expand : (gl_texture_usehires && tex->Scale.X == 1 && tex->Scale.Y == 1 && clampmode <= CLAMP_XY)? CTF_CheckHires : 0; - if (mBaseLayer->Bind(0, clampmode, translation, flags)) + if (mBaseLayer->BindOrCreate(tex, 0, clampmode, translation, flags)) { for(unsigned i=0;iid; layer = TexMan(id); - ValidateSysTexture(layer, mExpanded); } else { layer = mTextureLayers[i].texture; } - layer->gl_info.SystemTexture[mExpanded]->Bind(i+1, clampmode, 0, 0); + auto systex = ValidateSysTexture(layer, mExpanded); + systex->BindOrCreate(layer, i+1, clampmode, 0, 0); maxbound = i+1; } } @@ -730,7 +549,6 @@ int FMaterial::GetAreas(FloatRect **pAreas) const { if (mShaderIndex == SHADER_Default) // texture splitting can only be done if there's no attached effects { - FTexture *tex = mBaseLayer->tex; *pAreas = tex->areas; return tex->areacount; } @@ -748,14 +566,14 @@ int FMaterial::GetAreas(FloatRect **pAreas) const void FMaterial::BindToFrameBuffer() { - if (mBaseLayer->mHwTexture == NULL) + if (mBaseLayer == nullptr) { // must create the hardware texture first - mBaseLayer->Bind(0, 0, 0, 0); + mBaseLayer->BindOrCreate(tex, 0, 0, 0, 0); FHardwareTexture::Unbind(0); ClearLastTexture(); } - mBaseLayer->mHwTexture->BindToFrameBuffer(mWidth, mHeight); + mBaseLayer->BindToFrameBuffer(mWidth, mHeight); } //========================================================================== @@ -823,8 +641,8 @@ void FMaterial::FlushAll() { for (int j = 0; j < 2; j++) { - FGLTexture *gltex = TexMan.ByIndex(i)->gl_info.SystemTexture[j]; - if (gltex != NULL) gltex->Clean(true); + auto gltex = TexMan.ByIndex(i)->gl_info.SystemTexture[j]; + if (gltex != nullptr) gltex->Clean(true); } } } diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index a9342ef43..9cb17d8c3 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -43,39 +43,6 @@ struct FTexCoordInfo float TextureAdjustWidth() const; }; -//=========================================================================== -// -// device independent wrapper around the hardware texture and its sampler state -// -//=========================================================================== -class FMaterial; - -class FGLTexture -{ - friend class FMaterial; -public: - FTexture * tex; - -private: - FHardwareTexture *mHwTexture; - - uint8_t lastSampler; - int lastTranslation; - - FHardwareTexture *CreateHwTexture(); - - bool Bind(int texunit, int clamp, int translation, int flags); - -public: - FGLTexture(FTexture * tx, bool expandpatches); - FGLTexture(FTexture * tx, FHardwareTexture *hwtex); // for the SW framebuffer - ~FGLTexture(); - - void Clean(bool all); - void CleanUnused(SpriteHits &usedtranslations); - bool isInitialized() const { return mHwTexture != nullptr; } -}; - //=========================================================================== // // this is the material class for OpenGL. @@ -98,7 +65,7 @@ class FMaterial static TArray mMaterials; static int mMaxBound; - FGLTexture *mBaseLayer; + FHardwareTexture *mBaseLayer; TArray mTextureLayers; int mShaderIndex; @@ -115,7 +82,7 @@ class FMaterial float mSpriteU[2], mSpriteV[2]; FloatRect mSpriteRect; - FGLTexture * ValidateSysTexture(FTexture * tex, bool expand); + FHardwareTexture * ValidateSysTexture(FTexture * tex, bool expand); bool TrimBorders(uint16_t *rect); public: @@ -134,7 +101,7 @@ public: } bool isMasked() const { - return !!mBaseLayer->tex->bMasked; + return !!tex->bMasked; } int GetLayers() const diff --git a/src/hwrenderer/scene/hw_fakeflat.cpp b/src/hwrenderer/scene/hw_fakeflat.cpp index c2695a7bc..e41a00007 100644 --- a/src/hwrenderer/scene/hw_fakeflat.cpp +++ b/src/hwrenderer/scene/hw_fakeflat.cpp @@ -173,9 +173,8 @@ area_t hw_CheckViewArea(area_t in_area, vertex_t *v1, vertex_t *v2, sector_t *fr // allow some tolerance in case slopes are involved if (cz1 <= fz1 + 1. / 100 && cz2 <= fz2 + 1. / 100) return area_below; - else - return area_normal; } + return area_normal; } diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 1a5d92192..e21158f83 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -45,6 +45,7 @@ #include "c_dispatch.h" #include "v_video.h" #include "m_fixed.h" +#include "textures/warpbuffer.h" FTexture *CreateBrightmapTexture(FTexture*); @@ -1352,7 +1353,7 @@ bool FTexture::ProcessData(unsigned char * buffer, int w, int h, bool ispatch) unsigned char * FTexture::CreateTexBuffer(int translation, int & w, int & h, int flags) { - unsigned char * buffer; + unsigned char * buffer = nullptr; int W, H; int isTransparent = -1; @@ -1360,71 +1361,82 @@ unsigned char * FTexture::CreateTexBuffer(int translation, int & w, int & h, int if ((flags & CTF_CheckHires) && translation != STRange_AlphaTexture) { buffer = LoadHiresTexture(&w, &h); - if (buffer) - { - return buffer; - } } - int exx = !!(flags & CTF_Expand); - - W = w = GetWidth() + 2 * exx; - H = h = GetHeight() + 2 * exx; - - - buffer = new unsigned char[W*(H + 1) * 4]; - memset(buffer, 0, W * (H + 1) * 4); - - FBitmap bmp(buffer, W * 4, W, H); - - if (translation <= 0 || translation >= STRange_Min) + if (buffer == nullptr) { - // Allow creation of desaturated or special-colormapped textures for the legacy renderer. - FCopyInfo inf = { OP_COPY, BLEND_NONE,{ 0 }, 0, 0 }; - if (translation >= STRange_Desaturate && translation < STRange_Desaturate + 31) // there are 31 ranges of desaturations available - { - inf.blend = (EBlend)(BLEND_DESATURATE1 + translation - STRange_Desaturate); - } - else if (translation >= STRange_Specialcolormap && translation < STRange_Specialcolormap + (int)SpecialColormaps.Size()) - { - inf.blend = (EBlend)(BLEND_SPECIALCOLORMAP1 + translation - STRange_Specialcolormap); - } - int trans = CopyTrueColorPixels(&bmp, exx, exx, 0, translation >= STRange_Min ? &inf : nullptr); - CheckTrans(buffer, W*H, trans); - isTransparent = bTranslucent; - // alpha texture for legacy mode - if (translation == STRange_AlphaTexture) + int exx = !!(flags & CTF_Expand); + + W = w = GetWidth() + 2 * exx; + H = h = GetHeight() + 2 * exx; + + + buffer = new unsigned char[W*(H + 1) * 4]; + memset(buffer, 0, W * (H + 1) * 4); + + FBitmap bmp(buffer, W * 4, W, H); + + if (translation <= 0 || translation >= STRange_Min) { - for (int i = 0; i < W*H; i++) + // Allow creation of desaturated or special-colormapped textures for the legacy renderer. + FCopyInfo inf = { OP_COPY, BLEND_NONE,{ 0 }, 0, 0 }; + if (translation >= STRange_Desaturate && translation < STRange_Desaturate + 31) // there are 31 ranges of desaturations available { - int b = buffer[4 * i]; - int g = buffer[4 * i + 1]; - int r = buffer[4 * i + 2]; - int gray = Luminance(r, g, b); - buffer[4 * i] = 255; - buffer[4 * i + 1] = 255; - buffer[4 * i + 2] = 255; - buffer[4 * i + 3] = (buffer[4 * i + 3] * gray) >> 8; + inf.blend = (EBlend)(BLEND_DESATURATE1 + translation - STRange_Desaturate); + } + else if (translation >= STRange_Specialcolormap && translation < STRange_Specialcolormap + (int)SpecialColormaps.Size()) + { + inf.blend = (EBlend)(BLEND_SPECIALCOLORMAP1 + translation - STRange_Specialcolormap); + } + + int trans = CopyTrueColorPixels(&bmp, exx, exx, 0, translation >= STRange_Min ? &inf : nullptr); + CheckTrans(buffer, W*H, trans); + isTransparent = bTranslucent; + // alpha texture for legacy mode + if (translation == STRange_AlphaTexture) + { + for (int i = 0; i < W*H; i++) + { + int b = buffer[4 * i]; + int g = buffer[4 * i + 1]; + int r = buffer[4 * i + 2]; + int gray = Luminance(r, g, b); + buffer[4 * i] = 255; + buffer[4 * i + 1] = 255; + buffer[4 * i + 2] = 255; + buffer[4 * i + 3] = (buffer[4 * i + 3] * gray) >> 8; + } } } + else + { + // When using translations everything must be mapped to the base palette. + // so use CopyTrueColorTranslated + CopyTrueColorTranslated(&bmp, exx, exx, 0, FUniquePalette::GetPalette(translation)); + isTransparent = 0; + // This is not conclusive for setting the texture's transparency info. + } + + // [BB] The hqnx upsampling (not the scaleN one) destroys partial transparency, don't upsamle textures using it. + // [BB] Potentially upsample the buffer. + if (flags & CTF_ProcessData) + { + buffer = CreateUpsampledTextureBuffer(buffer, W, H, w, h, !!isTransparent); + ProcessData(buffer, w, h, false); + } } - else + if ((flags & CTF_MaybeWarped) && bWarped && w*h <= 256 * 256) // do not software-warp larger textures, especially on the old systems that still need this fallback. { - // When using translations everything must be mapped to the base palette. - // so use CopyTrueColorTranslated - CopyTrueColorTranslated(&bmp, exx, exx, 0, FUniquePalette::GetPalette(translation)); - isTransparent = 0; - // This is not conclusive for setting the texture's transparency info. + // need to do software warping + FWarpTexture *wt = static_cast(this); + unsigned char *warpbuffer = new unsigned char[w*h * 4]; + WarpBuffer((uint32_t*)warpbuffer, (const uint32_t*)buffer, w, h, wt->WidthOffsetMultiplier, wt->HeightOffsetMultiplier, screen->FrameTime, wt->Speed, bWarped); + delete[] buffer; + buffer = warpbuffer; + wt->GenTime[0] = screen->FrameTime; } - // [BB] The hqnx upsampling (not the scaleN one) destroys partial transparency, don't upsamle textures using it. - // [BB] Potentially upsample the buffer. - if (flags & CTF_ProcessData) - { - buffer = CreateUpsampledTextureBuffer(buffer, W, H, w, h, !!isTransparent); - ProcessData(buffer, w, h, false); - } return buffer; } diff --git a/src/textures/textures.h b/src/textures/textures.h index bfb675d6e..d03ef07bf 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -99,9 +99,10 @@ enum ESpecialTranslations : int32_t enum ECreateTexBufferFlags { - CTF_CheckHires = 1, // use external hires replacement if found - CTF_Expand = 2, // create buffer with a one-pixel wide border - CTF_ProcessData = 4 // run postprocessing on the generated buffer. This is only needed when using the data for a hardware texture. + CTF_CheckHires = 1, // use external hires replacement if found + CTF_Expand = 2, // create buffer with a one-pixel wide border + CTF_ProcessData = 4, // run postprocessing on the generated buffer. This is only needed when using the data for a hardware texture. + CTF_MaybeWarped = 8 // may be warped if needed }; @@ -114,7 +115,7 @@ class FScanner; // Texture IDs class FTextureManager; class FTerrainTypeArray; -class FGLTexture; +class FHardwareTexture; class FMaterial; extern int r_spriteadjustSW, r_spriteadjustHW; @@ -481,7 +482,7 @@ public: struct GLTexInfo { FMaterial *Material[2] = { nullptr, nullptr }; - FGLTexture *SystemTexture[2] = { nullptr, nullptr }; + FHardwareTexture *SystemTexture[2] = { nullptr, nullptr }; bool bNoExpand = false; ~GLTexInfo(); diff --git a/src/v_video.h b/src/v_video.h index 030fba56f..fe95c60c3 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -280,6 +280,8 @@ public: class FUniquePalette; +class FHardwareTexture; +class FTexture; // A canvas that represents the actual display. The video code is responsible // for actually implementing this. Built on top of SimpleCanvas, because it @@ -351,6 +353,7 @@ public: // Delete any resources that need to be deleted after restarting with a different IWAD virtual void CleanForRestart() {} virtual void SetTextureFilterMode() {} + virtual FHardwareTexture *CreateHardwareTexture(FTexture *tex) { return nullptr; } // Begin 2D drawing operations. // Returns true if hardware-accelerated 2D has been entered, false if not.