mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
~ use glClear instead of allocating pixels for FBOs creation
Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
4744304a3d
commit
332507351f
@ -8,8 +8,6 @@ CFBO::CFBO (std::string name, ITexture::TextureFormat format, float scale, uint3
|
||||
m_scale (scale)
|
||||
{
|
||||
// create an empty texture that'll be free'd so the FBO is transparent
|
||||
uint32_t* pixels = new uint32_t [textureWidth * textureHeight] {0xFFFFFFFF};
|
||||
|
||||
GLenum drawBuffers [1] = {GL_COLOR_ATTACHMENT0};
|
||||
// create the main framebuffer
|
||||
glGenFramebuffers (1, &this->m_framebuffer);
|
||||
@ -19,9 +17,7 @@ CFBO::CFBO (std::string name, ITexture::TextureFormat format, float scale, uint3
|
||||
// bind the new texture to set settings on it
|
||||
glBindTexture (GL_TEXTURE_2D, this->m_texture);
|
||||
// give OpenGL an empty image
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
||||
|
||||
delete pixels;
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
||||
|
||||
// set filtering parameters, otherwise the texture is not rendered
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
@ -38,6 +34,9 @@ CFBO::CFBO (std::string name, ITexture::TextureFormat format, float scale, uint3
|
||||
// ensure first framebuffer is okay
|
||||
if (glCheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||
throw std::runtime_error ("Framebuffers are not properly set");
|
||||
|
||||
// clear the framebuffer
|
||||
glClear (GL_COLOR_BUFFER_BIT);
|
||||
|
||||
this->m_resolution = {
|
||||
textureWidth, textureHeight,
|
||||
|
Loading…
Reference in New Issue
Block a user