- merged the nearly identical wrapper texture classes for the software render and the wiper.

This commit is contained in:
Christoph Oelckers 2018-10-29 07:39:33 +01:00
parent 6dc47ff328
commit 98e111eba0
7 changed files with 29 additions and 45 deletions

View file

@ -437,7 +437,6 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer)
if (VRMode::GetVRMode(true)->mEyeCount == 1) if (VRMode::GetVRMode(true)->mEyeCount == 1)
mBuffers->BindCurrentFB(); mBuffers->BindCurrentFB();
FDrawInfo di; // For access to the virtual interface. This should be placed elsewhere...
const auto &mScreenViewport = screen->mScreenViewport; const auto &mScreenViewport = screen->mScreenViewport;
glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height);
screen->mViewpoints->Set2D(gl_RenderState, screen->GetWidth(), screen->GetHeight()); screen->mViewpoints->Set2D(gl_RenderState, screen->GetWidth(), screen->GetHeight());

View file

@ -497,28 +497,6 @@ void OpenGLFrameBuffer::PostProcessScene(int fixedcm, const std::function<void()
GLRenderer->PostProcessScene(fixedcm, afterBloomDrawEndScene2D); GLRenderer->PostProcessScene(fixedcm, afterBloomDrawEndScene2D);
} }
//==========================================================================
//
// This is just a wrapper around the hardware texture being extracted below so that it can be passed to the 2D code.
//
//==========================================================================
class FGLWipeTexture : public FTexture
{
public:
FGLWipeTexture(int w, int h)
{
Width = w;
Height = h;
WidthBits = 4;
UseType = ETextureType::SWCanvas;
bNoCompress = true;
SystemTexture[0] = screen->CreateHardwareTexture(this);
}
};
//========================================================================== //==========================================================================
// //
// OpenGLFrameBuffer :: WipeStartScreen // OpenGLFrameBuffer :: WipeStartScreen
@ -533,7 +511,7 @@ FTexture *OpenGLFrameBuffer::WipeStartScreen()
{ {
const auto &viewport = screen->mScreenViewport; const auto &viewport = screen->mScreenViewport;
FGLWipeTexture *tex = new FGLWipeTexture(viewport.width, viewport.height); auto tex = new FWrapperTexture(viewport.width, viewport.height, 1);
tex->SystemTexture[0]->CreateTexture(nullptr, viewport.width, viewport.height, 0, false, 0, "WipeStartScreen"); tex->SystemTexture[0]->CreateTexture(nullptr, viewport.width, viewport.height, 0, false, 0, "WipeStartScreen");
glFinish(); glFinish();
static_cast<FHardwareTexture*>(tex->SystemTexture[0])->Bind(0, false, false); static_cast<FHardwareTexture*>(tex->SystemTexture[0])->Bind(0, false, false);
@ -555,7 +533,7 @@ FTexture *OpenGLFrameBuffer::WipeEndScreen()
{ {
GLRenderer->Flush(); GLRenderer->Flush();
const auto &viewport = screen->mScreenViewport; const auto &viewport = screen->mScreenViewport;
FGLWipeTexture *tex = new FGLWipeTexture(viewport.width, viewport.height); auto tex = new FWrapperTexture(viewport.width, viewport.height, 1);
tex->SystemTexture[0]->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeEndScreen"); tex->SystemTexture[0]->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeEndScreen");
glFinish(); glFinish();
static_cast<FHardwareTexture*>(tex->SystemTexture[0])->Bind(0, false, false); static_cast<FHardwareTexture*>(tex->SystemTexture[0])->Bind(0, false, false);

View file

@ -61,22 +61,6 @@ public:
} }
}; };
class FSWSceneTexture : public FTexture
{
public:
FSWSceneTexture(int w, int h, int bits)
{
Width = w;
Height = h;
WidthBits = bits;
UseType = ETextureType::SWCanvas;
bNoCompress = true;
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.
};
//========================================================================== //==========================================================================
// //
@ -106,7 +90,7 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
{ {
// This manually constructs its own material here. // This manually constructs its own material here.
fbtex.reset(); fbtex.reset();
fbtex.reset(new FSWSceneTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor())); fbtex.reset(new FWrapperTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()));
fbtex->SystemTexture[0]->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1); fbtex->SystemTexture[0]->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1);
auto mat = FMaterial::ValidateTexture(fbtex.get(), false); auto mat = FMaterial::ValidateTexture(fbtex.get(), false);
mat->AddTextureLayer(PaletteTexture.get()); mat->AddTextureLayer(PaletteTexture.get());

View file

@ -8,12 +8,12 @@
#include "c_cvars.h" #include "c_cvars.h"
#include <memory> #include <memory>
class FSWSceneTexture; class FWrapperTexture;
class SWSceneDrawer class SWSceneDrawer
{ {
std::unique_ptr<FTexture> PaletteTexture; std::unique_ptr<FTexture> PaletteTexture;
std::unique_ptr<FSWSceneTexture> FBTexture[2]; std::unique_ptr<FWrapperTexture> FBTexture[2];
int FBTextureIndex = 0; int FBTextureIndex = 0;
bool FBIsTruecolor = false; bool FBIsTruecolor = false;
std::unique_ptr<DSimpleCanvas> Canvas; std::unique_ptr<DSimpleCanvas> Canvas;

View file

@ -186,4 +186,3 @@ bool FCanvasTexture::CheckModified (FRenderStyle)
} }
return false; return false;
} }

View file

@ -1489,6 +1489,23 @@ void FDummyTexture::SetSize (int width, int height)
CalcBitSize (); CalcBitSize ();
} }
//==========================================================================
//
//
//
//==========================================================================
FWrapperTexture::FWrapperTexture(int w, int h, int bits)
{
Width = w;
Height = h;
WidthBits = bits;
UseType = ETextureType::SWCanvas;
bNoCompress = true;
SystemTexture[0] = screen->CreateHardwareTexture(this);
}
//========================================================================== //==========================================================================
// //
// Debug stuff // Debug stuff

View file

@ -789,6 +789,13 @@ public:
friend struct FCanvasTextureInfo; friend struct FCanvasTextureInfo;
}; };
// A wrapper around a hardware texture, to allow using it in the 2D drawing interface.
class FWrapperTexture : public FTexture
{
public:
FWrapperTexture(int w, int h, int bits = 1);
};
extern FTextureManager TexMan; extern FTextureManager TexMan;
#endif #endif