Browse Source

Render: Make Framebuffer class more flexible

master
Riyyi 4 months ago
parent
commit
4dbac7ee38
  1. 15
      src/inferno/render/framebuffer.cpp
  2. 3
      src/inferno/render/framebuffer.h

15
src/inferno/render/framebuffer.cpp

@ -4,7 +4,8 @@
* SPDX-License-Identifier: MIT
*/
#include <cstdint> // int8_t
#include <cstddef> // size_t
#include <cstdint> // uint8_t, uint32_t
#include "glad/glad.h"
#include "ruc/meta/assert.h"
@ -16,8 +17,16 @@ namespace Inferno {
std::shared_ptr<Framebuffer> Framebuffer::create(const Properties& properties)
{
VERIFY((properties.attachments.size() > 0 && !properties.renderToScreen) || properties.renderToScreen,
"cant have attachments on the default framebuffer");
auto result = std::shared_ptr<Framebuffer>(new Framebuffer(properties));
if (!properties.renderToScreen) {
result->m_id = UINT_MAX;
glGenFramebuffers(1, &result->m_id);
}
result->createTextures();
return result;
@ -25,6 +34,10 @@ std::shared_ptr<Framebuffer> Framebuffer::create(const Properties& properties)
Framebuffer::~Framebuffer()
{
if (m_renderToScreen) {
return;
}
glDeleteFramebuffers(1, &m_id);
}

3
src/inferno/render/framebuffer.h

@ -10,11 +10,11 @@
#include <cstdint> // uint8_t
#include <initializer_list>
#include <memory> // std::shared_ptr
#include <vector>
#include "glm/ext/vector_float4.hpp" // glm::vec4
#include "inferno/asset/texture.h"
#include "ruc/format/log.h"
namespace Inferno {
@ -41,7 +41,6 @@ public:
: type(type)
{
}
~TypeProperties() {};
Type type;
};

Loading…
Cancel
Save