Photon Editor Library 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
OpenglFramebuffer.h
Go to the documentation of this file.
1#pragma once
2
6
7#include "ThirdParty/glad2.h"
8
9#include <Common/primitive_type.h>
10#include <Math/TVector4.h>
11
12#include <array>
13#include <string>
14
15namespace ph::editor::ghi
16{
17
18class OpenglTexture;
19
21{
22public:
23 GLenum internalFormat = GL_NONE;
25
26 bool isAttached() const
27 {
28 return !handle.isEmpty();
29 }
30};
31
33{
34public:
35 GLenum internalFormat = GL_NONE;
36 GLenum attachmentType = GL_NONE;
38
39 bool isAttached() const
40 {
41 return !handle.isEmpty();
42 }
43};
44
46{
47public:
48 // Can actually allow more. Standard requires at least 8 (which should be enough for most use cases).
49 inline static constexpr GLuint MAX_COLOR_ATTACHMENTS = 8;
50
51 GLuint framebufferID = 0;
52 GLsizei widthPx = 0;
53 GLsizei heightPx = 0;
54 GLsizei numSamples = 1;
55 std::array<OpenglColorAttachment, MAX_COLOR_ATTACHMENTS> colorAttachments;
57
58 void createBuffer(const FramebufferDesc& desc);
59
60 void attachColor(
61 uint32 attachmentIdx,
62 const OpenglTexture& colorTexture,
63 TextureHandle handle);
64
66 const OpenglTexture& depthStencilTexture,
67 TextureHandle handle);
68
69 void bind();
70 void unbind();
71 void clearColor(uint32 attachmentIdx, const math::Vector4F& color);
72 void clearDepthStencil(float32 depth, uint8 stencil);
73 void destroy();
74 bool checkCompleteness();
75
76 bool hasResource() const;
77
78private:
79 void createDeviceColorTexture(uint32 attachmentIndex);
80 void createDeviceDepthStencilTexture();
81 static std::string getFramebufferStatusInfo(GLuint framebufferID);
82};
83
84}// end namespace ph::editor::ghi
bool isEmpty() const
Definition TWeakHandle.h:62
Definition ghi_infos.h:124
Definition OpenglFramebuffer.h:21
TextureHandle handle
Definition OpenglFramebuffer.h:24
GLenum internalFormat
Definition OpenglFramebuffer.h:23
bool isAttached() const
Definition OpenglFramebuffer.h:26
Definition OpenglFramebuffer.h:33
TextureHandle handle
Definition OpenglFramebuffer.h:37
bool isAttached() const
Definition OpenglFramebuffer.h:39
GLenum attachmentType
Definition OpenglFramebuffer.h:36
GLenum internalFormat
Definition OpenglFramebuffer.h:35
Definition OpenglFramebuffer.h:46
static constexpr GLuint MAX_COLOR_ATTACHMENTS
Definition OpenglFramebuffer.h:49
GLsizei heightPx
Definition OpenglFramebuffer.h:53
std::array< OpenglColorAttachment, MAX_COLOR_ATTACHMENTS > colorAttachments
Definition OpenglFramebuffer.h:55
bool checkCompleteness()
Definition OpenglFramebuffer.cpp:292
void bind()
Definition OpenglFramebuffer.cpp:214
GLuint framebufferID
Definition OpenglFramebuffer.h:51
OpenglDepthStencilAttachment depthStencilAttachment
Definition OpenglFramebuffer.h:56
void createBuffer(const FramebufferDesc &desc)
Definition OpenglFramebuffer.cpp:36
bool hasResource() const
Definition OpenglFramebuffer.cpp:306
void attachDepthStencil(const OpenglTexture &depthStencilTexture, TextureHandle handle)
Definition OpenglFramebuffer.cpp:158
void attachColor(uint32 attachmentIdx, const OpenglTexture &colorTexture, TextureHandle handle)
Definition OpenglFramebuffer.cpp:97
void clearDepthStencil(float32 depth, uint8 stencil)
Definition OpenglFramebuffer.cpp:243
void unbind()
Definition OpenglFramebuffer.cpp:220
GLsizei numSamples
Definition OpenglFramebuffer.h:54
void clearColor(uint32 attachmentIdx, const math::Vector4F &color)
Definition OpenglFramebuffer.cpp:225
GLsizei widthPx
Definition OpenglFramebuffer.h:52
void destroy()
Definition OpenglFramebuffer.cpp:281
Definition OpenglTexture.h:18
Definition PlatformDisplay.h:13