summaryrefslogtreecommitdiff
path: root/src/render/Framebuffer.cpp
blob: b2ff7e68ab121e3257aac4a6e5130391ce449666 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "Framebuffer.hpp"

IFramebuffer::IFramebuffer(const std::string& name) : m_name(name) {}

bool IFramebuffer::alloc(int w, int h, uint32_t format) {
    RASSERT((w > 0 && h > 0), "cannot alloc a FB with negative / zero size! (attempted {}x{})", w, h);

    const bool sizeChanged   = (m_size != Vector2D(w, h));
    const bool formatChanged = (format != m_drmFormat);

    if (m_fbAllocated && !sizeChanged && !formatChanged)
        return true;

    m_size        = {w, h};
    m_drmFormat   = format;
    m_fbAllocated = internalAlloc(w, h, format);
    return m_fbAllocated;
}

bool IFramebuffer::isAllocated() {
    return m_fbAllocated && m_tex;
}

SP<ITexture> IFramebuffer::getTexture() {
    return m_tex;
}

SP<ITexture> IFramebuffer::getStencilTex() {
    return m_stencilTex;
}