- removed the intermediate FGLTexture class.

This wasn't serving any real purpose anymore, and all its remaining functionality could be moved to FHardwareTexture
This commit is contained in:
Christoph Oelckers 2018-04-24 20:41:52 +02:00
commit c37ff22a05
11 changed files with 166 additions and 294 deletions

View file

@ -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<FCanvasTexture*>(tex)->NeedUpdate();
GLRenderer->mSamplerManager->Bind(texunit, clampmode, 255);
return true;
}