mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 21:11:39 +00:00
- add the hardware texture container to FTexture.
Currently it does not use the translated entries yet. # Conflicts: # src/hwrenderer/textures/hw_material.cpp
This commit is contained in:
parent
e6b4c63b99
commit
fb6ee5046c
5 changed files with 24 additions and 19 deletions
|
@ -515,9 +515,9 @@ FTexture *OpenGLFrameBuffer::WipeStartScreen()
|
|||
const auto &viewport = screen->mScreenViewport;
|
||||
|
||||
auto tex = new FWrapperTexture(viewport.width, viewport.height, 1);
|
||||
tex->GetSystemTexture(0)->CreateTexture(nullptr, viewport.width, viewport.height, 0, false, 0, "WipeStartScreen");
|
||||
tex->GetSystemTexture()->CreateTexture(nullptr, viewport.width, viewport.height, 0, false, 0, "WipeStartScreen");
|
||||
glFinish();
|
||||
static_cast<FHardwareTexture*>(tex->GetSystemTexture(0))->Bind(0, false, false);
|
||||
static_cast<FHardwareTexture*>(tex->GetSystemTexture())->Bind(0, false, false);
|
||||
|
||||
GLRenderer->mBuffers->BindCurrentFB();
|
||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height);
|
||||
|
@ -537,9 +537,9 @@ FTexture *OpenGLFrameBuffer::WipeEndScreen()
|
|||
GLRenderer->Flush();
|
||||
const auto &viewport = screen->mScreenViewport;
|
||||
auto tex = new FWrapperTexture(viewport.width, viewport.height, 1);
|
||||
tex->GetSystemTexture(0)->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeEndScreen");
|
||||
tex->GetSystemTexture()->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeEndScreen");
|
||||
glFinish();
|
||||
static_cast<FHardwareTexture*>(tex->GetSystemTexture(0))->Bind(0, false, false);
|
||||
static_cast<FHardwareTexture*>(tex->GetSystemTexture())->Bind(0, false, false);
|
||||
GLRenderer->mBuffers->BindCurrentFB();
|
||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height);
|
||||
return tex;
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "tarray.h"
|
||||
#include "hwrenderer/textures/hw_ihwtexture.h"
|
||||
|
||||
struct FTextureBuffer;
|
||||
class IHardwareTexture;
|
||||
|
||||
class FHardwareTextureContainer
|
||||
{
|
||||
|
@ -49,10 +51,10 @@ private:
|
|||
unsigned index = hwTex_Translated.FindEx([=](auto &element)
|
||||
{
|
||||
return element.translation == translation;
|
||||
}
|
||||
});
|
||||
if (index < hwTex_Translated.Size())
|
||||
{
|
||||
return &hwTex_Translated[i];
|
||||
return &hwTex_Translated[index];
|
||||
}
|
||||
|
||||
int add = hwTex_Translated.Reserve(1);
|
||||
|
@ -65,7 +67,11 @@ public:
|
|||
|
||||
void Clean(bool all)
|
||||
{
|
||||
if (all) hwDefTex.Delete();
|
||||
if (all)
|
||||
{
|
||||
hwDefTex[0].Delete();
|
||||
hwDefTex[1].Delete();
|
||||
}
|
||||
hwTex_Translated.Clear();
|
||||
|
||||
}
|
||||
|
@ -90,7 +96,7 @@ public:
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
void FHardwareTexture::CleanUnused(SpriteHits &usedtranslations, bool expanded)
|
||||
void CleanUnused(SpriteHits &usedtranslations, bool expanded)
|
||||
{
|
||||
if (usedtranslations.CheckKey(0) == nullptr)
|
||||
{
|
||||
|
|
|
@ -91,7 +91,7 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
|
|||
FBTextureIndex = (FBTextureIndex + 1) % 2;
|
||||
auto &fbtex = FBTexture[FBTextureIndex];
|
||||
|
||||
if (fbtex == nullptr || fbtex->GetSystemTexture(0) == nullptr ||
|
||||
if (fbtex == nullptr || fbtex->GetSystemTexture() == nullptr ||
|
||||
fbtex->GetDisplayWidth() != screen->GetWidth() ||
|
||||
fbtex->GetDisplayHeight() != screen->GetHeight() ||
|
||||
(V_IsTrueColor() ? 1:0) != fbtex->GetColorFormat())
|
||||
|
@ -99,7 +99,7 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
|
|||
// This manually constructs its own material here.
|
||||
fbtex.reset();
|
||||
fbtex.reset(new FWrapperTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()));
|
||||
fbtex->GetSystemTexture(0)->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1);
|
||||
fbtex->GetSystemTexture()->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1);
|
||||
auto mat = FMaterial::ValidateTexture(fbtex.get(), false);
|
||||
mat->AddTextureLayer(PaletteTexture);
|
||||
|
||||
|
@ -107,10 +107,10 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
|
|||
Canvas.reset(new DCanvas(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()));
|
||||
}
|
||||
|
||||
auto buf = fbtex->GetSystemTexture(0)->MapBuffer();
|
||||
auto buf = fbtex->GetSystemTexture()->MapBuffer();
|
||||
if (!buf) I_FatalError("Unable to map buffer for software rendering");
|
||||
SWRenderer->RenderView(player, Canvas.get(), buf);
|
||||
fbtex->GetSystemTexture(0)->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, 0, "swbuffer");
|
||||
fbtex->GetSystemTexture()->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, 0, "swbuffer");
|
||||
|
||||
auto map = swrenderer::CameraLight::Instance()->ShaderColormap();
|
||||
screen->DrawTexture(fbtex.get(), 0, 0, DTA_SpecialColormap, map, TAG_DONE);
|
||||
|
|
|
@ -178,9 +178,6 @@ FTexture::~FTexture ()
|
|||
{
|
||||
if (Material[i] != nullptr) delete Material[i];
|
||||
Material[i] = nullptr;
|
||||
|
||||
if (SystemTexture[i] != nullptr) delete SystemTexture[i];
|
||||
SystemTexture[i] = nullptr;
|
||||
}
|
||||
if (SoftwareTexture != nullptr)
|
||||
{
|
||||
|
@ -793,7 +790,7 @@ FWrapperTexture::FWrapperTexture(int w, int h, int bits)
|
|||
Format = bits;
|
||||
UseType = ETextureType::SWCanvas;
|
||||
bNoCompress = true;
|
||||
SystemTexture[0] = screen->CreateHardwareTexture();
|
||||
SystemTextures.AddHardwareTexture(0, false, screen->CreateHardwareTexture());
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "colormatcher.h"
|
||||
#include "r_data/renderstyle.h"
|
||||
#include "r_data/r_translate.h"
|
||||
#include "hwrenderer/textures/hw_texcontainer.h"
|
||||
#include <vector>
|
||||
|
||||
// 15 because 0th texture is our texture
|
||||
|
@ -344,7 +345,8 @@ protected:
|
|||
FTextureID id;
|
||||
|
||||
FMaterial *Material[2] = { nullptr, nullptr };
|
||||
IHardwareTexture *SystemTexture[2] = { nullptr, nullptr };
|
||||
FHardwareTextureContainer SystemTextures;
|
||||
//IHardwareTexture *SystemTexture[2] = { nullptr, nullptr };
|
||||
FSoftwareTexture *SoftwareTexture = nullptr;
|
||||
|
||||
// None of the following pointers are owned by this texture, they are all controlled by the texture manager.
|
||||
|
@ -710,9 +712,9 @@ class FWrapperTexture : public FTexture
|
|||
int Format;
|
||||
public:
|
||||
FWrapperTexture(int w, int h, int bits = 1);
|
||||
IHardwareTexture *GetSystemTexture(int slot)
|
||||
IHardwareTexture *GetSystemTexture()
|
||||
{
|
||||
return SystemTexture[slot];
|
||||
return SystemTextures.GetHardwareTexture(0, false);
|
||||
}
|
||||
|
||||
int GetColorFormat() const
|
||||
|
|
Loading…
Reference in a new issue