AUI Framework  master
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
RenderbufferRenderTarget.h
    1/*
    2 * AUI Framework - Declarative UI toolkit for modern C++20
    3 * Copyright (C) 2020-2025 Alex2772 and Contributors
    4 *
    5 * SPDX-License-Identifier: MPL-2.0
    6 *
    7 * This Source Code Form is subject to the terms of the Mozilla Public
    8 * License, v. 2.0. If a copy of the MPL was not distributed with this
    9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
   10 */
   11
   12#pragma once
   13
   14
   15#include <AUI/Util/kAUI.h>
   16#include <AUI/GL/Framebuffer.h>
   17#include <AUI/GL/GLEnums.h>
   18#include <AUI/GL/Renderbuffer.h>
   19#include <memory>
   20
   21namespace gl {
   22
   23
   24    template<InternalFormat internalFormat /* = GL_DEPTH_COMPONENT24 */,
   25             Multisampling multisampling = Multisampling::DISABLED>
   26    class RenderbufferRenderTarget final: public Framebuffer::IRenderTarget {
   27    public:
   28        RenderbufferRenderTarget() {
   29        }
   30
   31    protected:
   32        void attach(Framebuffer& to, GLenum attachmentType) override {
   33            glGetError();
   34            onFramebufferResize(to.supersampledSize());
   35            if (glGetError() != GL_NO_ERROR) {
   36                throw AException("unable to initialize renderbuffer storage");
   37            }
   38            to.bind();
   39            glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachmentType, GL_RENDERBUFFER, mRenderbuffer.handle());
   40            if (glGetError() != GL_NO_ERROR) {
   41                throw AException("unable to create renderbuffer target");
   42            }
   43        }
   44
   45        void onFramebufferResize(glm::u32vec2 size) override {
   46            mRenderbuffer.storage(size, internalFormat);
   47        }
   48
   49    private:
   50        Renderbuffer<multisampling> mRenderbuffer;
   51    };
   52}
Abstract AUI exception.
Definition AException.h:28
Definition Framebuffer.h:35
Definition Renderbuffer.h:20