sculpto
gl_frame_buffer.h
Go to the documentation of this file.
1/*!****************************************************************//*!*
2 * \file gl_frame_buffer.h
3 * \brief OpenGL frame buffer class definition class.
4 *
5 * \author Sabitov Kirill
6 * \date 30 June 2022
7 *********************************************************************/
8
9#pragma once
10
11#include "gl.h"
12#include "gl_texture.h"
14
15namespace scl
16{
19 {
20 private:
21 frame_buffer_props Props {};
22 GLuint Id {};
23 std::vector<shared<texture_2d>> ColorAttachments {};
24 shared<texture_2d> DepthAttachment {};
25 u32 ClearConfig {};
26
27 public:
29 void SetFrameBufferProps(const frame_buffer_props &Props);
33 const shared<texture_2d> &GetColorAttachment(int Index) const override;
35 const shared<texture_2d> &GetDepthAttachment(int Index) const override;
36
37 private:
38 /*!*
39 * Recreate frame buffer according to new frame buffer properties function.
40 *
41 * \param None.
42 * \return None.
43 */
44 void Invalidate();
45
46 public:
48 render_primitive::handle GetHandle() const override { return Id; }
49
50 /*!*
51 * OpenGL frame buffer constructor.
52 *
53 * \param Props - frame buffer properties.
54 */
56
58 ~gl_frame_buffer() override;
59
60 /*!*
61 * Bind frame buffer to current render stage function.
62 *
63 * \param None.
64 * \return None.
65 */
66 void Bind() const override;
67
68 /*!*
69 * Unbind frame buffer from current render stage function.
70 *
71 * \param None.
72 * \return None.
73 */
74 void Unbind() const override;
75
76 /*!*
77 * Resize frame buffer (resize also could be called by setting frame buffer props).
78 *
79 * \param Width - new frame buffer width.
80 * \param Height - new frame buffer height.
81 * \return None.
82 */
83 void Resize(int Width, int Height) override;
84
85 /*!*
86 * Unload frame buffer render target texture from GPU memory function.
87 *
88 * \param None.
89 * \return None.
90 */
91 void Free() override;
92
93 /*!*
94 * Clear frame buffer funcrion.
95 *
96 * \param None.
97 * \return None.
98 */
99 void Clear() override;
100 };
101}
const shared< texture_2d > & GetColorAttachment(int Index) const override
void SetFrameBufferProps(const frame_buffer_props &Props)
void Bind() const override
gl_frame_buffer(const frame_buffer_props &Props)
void Resize(int Width, int Height) override
const frame_buffer_props & GetFrameBufferProps() const
void Unbind() const override
const shared< texture_2d > & GetDepthAttachment(int Index) const override
render_primitive::handle GetHandle() const override
Frame buffer interface implementation module.
OpenGL texture class definition module.
Definition: base.h:33
std::shared_ptr< T > shared
Definition: smart_ptr.h:15
uint32_t u32
Definition: math_common.h:21