- minor cleanup of FHardwareTexture.

Inlining of a trivial function and removing dependency on the render state, unbinding the render state should be done elsewhere.
This commit is contained in:
Christoph Oelckers 2020-05-29 11:48:29 +02:00
parent a517b04908
commit 5861fdd4bd
3 changed files with 19 additions and 15 deletions

View File

@ -263,6 +263,7 @@ void OpenGLFrameBuffer::Swap()
Finish.Unclock();
camtexcount = 0;
FHardwareTexture::UnbindAll();
gl_RenderState.ClearLastMaterial();
mDebug->Update();
}
@ -321,6 +322,7 @@ void OpenGLFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
}
// unbind everything.
FHardwareTexture::UnbindAll();
gl_RenderState.ClearLastMaterial();
}
IVertexBuffer *OpenGLFrameBuffer::CreateVertexBuffer()

View File

@ -42,14 +42,14 @@
#include "hw_cvars.h"
#include "gl_debug.h"
#include "gl_renderer.h"
#include "gl_renderstate.h"
#include "gl_samplers.h"
#include "gl_hwtexture.h"
namespace OpenGLRenderer
{
TexFilter_s TexFilter[]={
TexFilter_s TexFilter[] = {
{GL_NEAREST, GL_NEAREST, false},
{GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST, true},
{GL_LINEAR, GL_LINEAR, false},
@ -237,11 +237,6 @@ unsigned int FHardwareTexture::Bind(int texunit, bool needmipmap)
return 0;
}
unsigned int FHardwareTexture::GetTextureHandle(int translation)
{
return glTexID;
}
void FHardwareTexture::Unbind(int texunit)
{
if (lastbound[texunit] != 0)
@ -259,7 +254,6 @@ void FHardwareTexture::UnbindAll()
{
Unbind(texunit);
}
gl_RenderState.ClearLastMaterial();
}
//===========================================================================

View File

@ -1,6 +1,10 @@
#pragma once
class FBitmap;
class FTexture;
#include "tarray.h"
#include "hw_ihwtexture.h"
#ifndef __GLTEXTURE_H
#define __GLTEXTURE_H
#ifdef LoadImage
#undef LoadImage
@ -59,14 +63,18 @@ public:
void BindToFrameBuffer(int w, int h);
unsigned int Bind(int texunit, bool needmipmap);
bool BindOrCreate(FTexture *tex, int texunit, int clampmode, int translation, int flags);
bool BindOrCreate(FTexture* tex, int texunit, int clampmode, int translation, int flags);
void AllocateBuffer(int w, int h, int texelsize);
uint8_t *MapBuffer();
uint8_t* MapBuffer();
unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, const char *name);
unsigned int GetTextureHandle(int translation);
unsigned int CreateTexture(unsigned char* buffer, int w, int h, int texunit, bool mipmap, const char* name);
unsigned int GetTextureHandle()
{
return glTexID;
}
int numChannels() { return glTextureBytes; }
};
}
#endif