Just™ Game Engine
framebuffer.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 Konstanty Misiak
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7#pragma once
8#include "jng/core/base.hpp"
10
11namespace jng {
12
13 class Framebuffer final
14 {
15 public:
16 struct Properties {
20 std::vector<TextureSpecification> attachmentsSpecifications;
21
22 bool swapChainTarget = false;
23 };
24
25 explicit Framebuffer(const Properties& properties);
27
28 void bind() const;
29 void unbind() const;
30
31 void resize(u32 width, u32 height);
32 u32 readPixel(u32 colorAttachmentIndex, u32 x, u32 y) const;
33 void clearAttachment(u32 attachmentIndex, int value) const;
34 void clearAttachment(u32 attachmentIndex, float value) const;
35
36 const std::vector<Ref<Texture>>& getAttachments() const { return m_attachments; }
37 const Properties& getProperties() const { return m_properties; }
38 private:
39 void recreate();
40
41 Properties m_properties;
42 u32 m_ID;
43 std::vector<Ref<Texture>> m_attachments;
44 u32 m_colorAttachmentID;
45 u32 m_depthAttachmentID;
46 };
47
48} // namespace jng
Definition: framebuffer.hpp:14
void bind() const
Definition: framebuffer_ogl.cpp:55
void resize(u32 width, u32 height)
Definition: framebuffer_ogl.cpp:68
const std::vector< Ref< Texture > > & getAttachments() const
Definition: framebuffer.hpp:36
Framebuffer(const Properties &properties)
Definition: framebuffer_ogl.cpp:42
void clearAttachment(u32 attachmentIndex, int value) const
Definition: framebuffer_ogl.cpp:87
~Framebuffer()
Definition: framebuffer_ogl.cpp:48
void unbind() const
Definition: framebuffer_ogl.cpp:62
u32 readPixel(u32 colorAttachmentIndex, u32 x, u32 y) const
Definition: framebuffer_ogl.cpp:76
const Properties & getProperties() const
Definition: framebuffer.hpp:37
Definition: base.hpp:11
uint32_t u32
Definition: base.hpp:41
Definition: framebuffer.hpp:16
u32 height
Definition: framebuffer.hpp:18
bool swapChainTarget
Definition: framebuffer.hpp:22
std::vector< TextureSpecification > attachmentsSpecifications
Definition: framebuffer.hpp:20
u32 samples
Definition: framebuffer.hpp:19
u32 width
Definition: framebuffer.hpp:17