diff --git a/src/gl/scene/gl_swscene.cpp b/src/gl/scene/gl_swscene.cpp index 4a028111b..08e2a20b2 100644 --- a/src/gl/scene/gl_swscene.cpp +++ b/src/gl/scene/gl_swscene.cpp @@ -29,7 +29,7 @@ #include "gl/system/gl_debug.h" #include "gl/data/gl_vertexbuffer.h" #include "gl/shaders/gl_shader.h" -#include "gl/textures/gl_hwtexture.h" +#include "hwrenderer/textures/hw_ihwtexture.h" #include "gl_swscene.h" #include "w_wad.h" #include "d_player.h" diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index b4a1721b6..ec77414e7 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -388,11 +388,17 @@ void OpenGLFrameBuffer::SetTextureFilterMode() if (GLRenderer != nullptr && GLRenderer->mSamplerManager != nullptr) GLRenderer->mSamplerManager->SetTextureFilterMode(); } -FHardwareTexture *OpenGLFrameBuffer::CreateHardwareTexture(FTexture *tex) +IHardwareTexture *OpenGLFrameBuffer::CreateHardwareTexture(FTexture *tex) { return new FHardwareTexture(tex->bNoCompress); } +void OpenGLFrameBuffer::UnbindTexUnit(int no) +{ + FHardwareTexture::Unbind(no); +} + + void OpenGLFrameBuffer::UpdatePalette() { diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h index d21ee0230..3061d7598 100644 --- a/src/gl/system/gl_framebuffer.h +++ b/src/gl/system/gl_framebuffer.h @@ -43,7 +43,8 @@ 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; + IHardwareTexture *CreateHardwareTexture(FTexture *tex) override; + void UnbindTexUnit(int no) 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.h b/src/gl/textures/gl_hwtexture.h index 758ecb7c9..87facf5e7 100644 --- a/src/gl/textures/gl_hwtexture.h +++ b/src/gl/textures/gl_hwtexture.h @@ -11,10 +11,10 @@ #include "tarray.h" #include "gl/system/gl_interface.h" +#include "hwrenderer/textures/hw_ihwtexture.h" class FCanvasTexture; class AActor; -typedef TMap SpriteHits; // For error catching while changing parameters. @@ -23,7 +23,7 @@ enum EInvalid Invalid = 0 }; -class FHardwareTexture +class FHardwareTexture : public IHardwareTexture { public: enum diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 942a256e1..d6446eedf 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -20,23 +20,15 @@ //-------------------------------------------------------------------------- // -#include "gl/system/gl_system.h" #include "w_wad.h" #include "m_png.h" #include "sbar.h" #include "stats.h" #include "r_utility.h" +#include "hwrenderer/textures/hw_ihwtexture.h" -#include "gl/system/gl_interface.h" -#include "gl/system/gl_framebuffer.h" -#include "gl/renderer/gl_renderer.h" -#include "gl/textures/gl_hwtexture.h" -#include "gl/textures/gl_material.h" -#include "gl/shaders/gl_shader.h" +#include "gl_material.h" -EXTERN_CVAR(Bool, gl_render_precise) -EXTERN_CVAR(Int, gl_lightmode) -EXTERN_CVAR(Bool, gl_precache) EXTERN_CVAR(Bool, gl_texture_usehires) //=========================================================================== @@ -95,10 +87,10 @@ float FTexCoordInfo::TextureAdjustWidth() const if (mWorldPanning) { float tscale = fabs(mTempScale.X); - if (tscale == 1.f) return mRenderWidth; + if (tscale == 1.f) return (float)mRenderWidth; else return mWidth / fabs(tscale); } - else return mWidth; + else return (float)mWidth; } @@ -108,11 +100,11 @@ float FTexCoordInfo::TextureAdjustWidth() const // // //=========================================================================== -FHardwareTexture * FMaterial::ValidateSysTexture(FTexture * tex, bool expand) +IHardwareTexture * FMaterial::ValidateSysTexture(FTexture * tex, bool expand) { if (tex && tex->UseType!=ETextureType::Null) { - FHardwareTexture *gltex = tex->gl_info.SystemTexture[expand]; + IHardwareTexture *gltex = tex->gl_info.SystemTexture[expand]; if (gltex == nullptr) { gltex = tex->gl_info.SystemTexture[expand] = screen->CreateHardwareTexture(tex); @@ -272,8 +264,8 @@ void FMaterial::SetSpriteRect() auto leftOffset = tex->GetLeftOffsetHW(); auto topOffset = tex->GetTopOffsetHW(); - float fxScale = tex->Scale.X; - float fyScale = tex->Scale.Y; + float fxScale = (float)tex->Scale.X; + float fyScale = (float)tex->Scale.Y; // mSpriteRect is for positioning the sprite in the scene. mSpriteRect.left = -leftOffset / fxScale; @@ -468,7 +460,7 @@ void FMaterial::Bind(int clampmode, int translation) // unbind everything from the last texture that's still active for(int i=maxbound+1; i<=mMaxBound;i++) { - FHardwareTexture::Unbind(i); + screen->UnbindTexUnit(i); mMaxBound = maxbound; } } @@ -508,12 +500,12 @@ void FMaterial::GetTexCoordInfo(FTexCoordInfo *tci, float x, float y) const if (x == 1.f) { tci->mRenderWidth = mRenderWidth; - tci->mScale.X = tex->Scale.X; + tci->mScale.X = (float)tex->Scale.X; tci->mTempScale.X = 1.f; } else { - float scale_x = x * tex->Scale.X; + float scale_x = x * (float)tex->Scale.X; tci->mRenderWidth = xs_CeilToInt(mWidth / scale_x); tci->mScale.X = scale_x; tci->mTempScale.X = x; @@ -522,12 +514,12 @@ void FMaterial::GetTexCoordInfo(FTexCoordInfo *tci, float x, float y) const if (y == 1.f) { tci->mRenderHeight = mRenderHeight; - tci->mScale.Y = tex->Scale.Y; + tci->mScale.Y = (float)tex->Scale.Y; tci->mTempScale.Y = 1.f; } else { - float scale_y = y * tex->Scale.Y; + float scale_y = y * (float)tex->Scale.Y; tci->mRenderHeight = xs_CeilToInt(mHeight / scale_y); tci->mScale.Y = scale_y; tci->mTempScale.Y = y; @@ -572,7 +564,7 @@ void FMaterial::BindToFrameBuffer() { // must create the hardware texture first mBaseLayer->BindOrCreate(sourcetex, 0, 0, 0, 0); - FHardwareTexture::Unbind(0); + screen->UnbindTexUnit(0); ClearLastTexture(); } mBaseLayer->BindToFrameBuffer(mWidth, mHeight); diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index 7fe2b7ed0..3ee1d935c 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -11,6 +11,7 @@ EXTERN_CVAR(Bool, gl_precache) struct FRemapTable; class FTextureShader; +class IHardwareTexture; enum { @@ -63,7 +64,7 @@ class FMaterial static TArray mMaterials; static int mMaxBound; - FHardwareTexture *mBaseLayer; + IHardwareTexture *mBaseLayer; TArray mTextureLayers; int mShaderIndex; @@ -80,7 +81,7 @@ class FMaterial float mSpriteU[2], mSpriteV[2]; FloatRect mSpriteRect; - FHardwareTexture * ValidateSysTexture(FTexture * tex, bool expand); + IHardwareTexture * ValidateSysTexture(FTexture * tex, bool expand); bool TrimBorders(uint16_t *rect); public: diff --git a/src/textures/textures.h b/src/textures/textures.h index 7474961d4..3e46f92b1 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -117,7 +117,7 @@ class FScanner; // Texture IDs class FTextureManager; class FTerrainTypeArray; -class FHardwareTexture; +class IHardwareTexture; class FMaterial; extern int r_spriteadjustSW, r_spriteadjustHW; @@ -484,7 +484,7 @@ public: struct GLTexInfo { FMaterial *Material[2] = { nullptr, nullptr }; - FHardwareTexture *SystemTexture[2] = { nullptr, nullptr }; + IHardwareTexture *SystemTexture[2] = { nullptr, nullptr }; bool bNoExpand = false; ~GLTexInfo(); diff --git a/src/v_video.h b/src/v_video.h index fe95c60c3..468a03784 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -280,7 +280,7 @@ public: class FUniquePalette; -class FHardwareTexture; +class IHardwareTexture; class FTexture; // A canvas that represents the actual display. The video code is responsible @@ -353,7 +353,8 @@ 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; } + virtual IHardwareTexture *CreateHardwareTexture(FTexture *tex) { return nullptr; } + virtual void UnbindTexUnit(int no) {} // Begin 2D drawing operations. // Returns true if hardware-accelerated 2D has been entered, false if not.