mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 05:46:48 +08:00
Reduced amount of glClears used in the rendering process
Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
a13d2f265b
commit
c9f8624b8b
@ -97,11 +97,11 @@ CTexture::CTexture (void* fileData)
|
||||
{
|
||||
// bind the texture to assign information to it
|
||||
glBindTexture (GL_TEXTURE_2D, this->m_textureID [index]);
|
||||
|
||||
// set mipmap levels
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, this->m_header->mipmapCount - 1);
|
||||
|
||||
// TODO: ADD SUPPORT FOR .tex-json FILES AS THEY ALSO HAVE FLAGS LIKE THESE ONES
|
||||
// setup texture wrapping and filtering
|
||||
if (this->m_header->flags & TextureFlags::ClampUVs)
|
||||
{
|
||||
@ -127,9 +127,6 @@ CTexture::CTexture (void* fileData)
|
||||
|
||||
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, 8.0f);
|
||||
|
||||
// TODO: USE THIS ONE
|
||||
// uint32_t blockSize = (internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) ? 8 : 16;
|
||||
|
||||
auto cur = (*imgCur).second.begin ();
|
||||
auto end = (*imgCur).second.end ();
|
||||
|
||||
@ -141,6 +138,7 @@ CTexture::CTexture (void* fileData)
|
||||
void* dataptr = (*cur)->uncompressedData;
|
||||
uint32_t width = (*cur)->width;
|
||||
uint32_t height = (*cur)->height;
|
||||
uint32_t bufferSize = (*cur)->uncompressedSize;
|
||||
GLenum textureFormat = GL_RGBA;
|
||||
|
||||
if (this->m_header->freeImageFormat != FREE_IMAGE_FORMAT::FIF_UNKNOWN)
|
||||
@ -157,6 +155,7 @@ CTexture::CTexture (void* fileData)
|
||||
dataptr = FreeImage_GetBits (converted);
|
||||
width = FreeImage_GetWidth (converted);
|
||||
height = FreeImage_GetHeight (converted);
|
||||
bufferSize = FreeImage_GetMemorySize (converted);
|
||||
textureFormat = GL_BGRA;
|
||||
}
|
||||
else
|
||||
@ -172,7 +171,8 @@ CTexture::CTexture (void* fileData)
|
||||
case GL_RGBA8:
|
||||
case GL_RG8:
|
||||
case GL_R8:
|
||||
glTexImage2D (GL_TEXTURE_2D, level, internalFormat,
|
||||
glTexImage2D (
|
||||
GL_TEXTURE_2D, level, internalFormat,
|
||||
width, height, 0,
|
||||
textureFormat, GL_UNSIGNED_BYTE,
|
||||
dataptr
|
||||
@ -183,10 +183,12 @@ CTexture::CTexture (void* fileData)
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
||||
glCompressedTexImage2D (
|
||||
GL_TEXTURE_2D, level, internalFormat,
|
||||
(*cur)->width, (*cur)->height, 0,
|
||||
(*cur)->uncompressedSize, dataptr
|
||||
width, height, 0,
|
||||
bufferSize, dataptr
|
||||
);
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error ("Cannot load texture, unknown format");
|
||||
}
|
||||
|
||||
// freeimage buffer won't be used anymore, so free memory
|
||||
|
@ -298,6 +298,11 @@ void CImage::complexRender ()
|
||||
CFBO* drawTo = this->m_mainFBO;
|
||||
ITexture* asInput = this->getTexture ();
|
||||
|
||||
// clear the main framebuffer
|
||||
glBindFramebuffer (GL_FRAMEBUFFER, this->m_mainFBO->getFramebuffer ());
|
||||
// attach the main texture
|
||||
glClear (GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// do the first pass render into the main framebuffer
|
||||
auto cur = this->m_copyMaterial->getPasses ().begin ();
|
||||
auto end = this->m_copyMaterial->getPasses ().end ();
|
||||
|
@ -70,9 +70,6 @@ void CPass::render (CFBO* drawTo, ITexture* input, GLuint position, GLuint texco
|
||||
// set proper viewport based on what we're drawing to
|
||||
glViewport (0, 0, drawTo->getRealWidth (), drawTo->getRealHeight ());
|
||||
|
||||
if (drawTo != this->m_material->getImage ()->getScene ()->getFBO())
|
||||
glClear (GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// set texture blending
|
||||
if (this->m_pass->getBlendingMode () == "translucent")
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user