sculpto
frame_buffer.h
Go to the documentation of this file.
1/*!****************************************************************//*!*
2 * \file frame_buffer.h
3 * \brief Frame buffer interface definition module.
4 *
5 * \author Sabitov Kirill
6 * \date 30 June 2022
7 *********************************************************************/
8
9#pragma once
10
11#include "render_primitive.h"
12
13namespace scl
14{
16 class texture_2d;
17
20 {
21 int Width { 16 }, Height { 16 };
22 int Samples { 1 };
24 bool IsHDR {};
30 frame_buffer_props() = default;
31
32 /*!*
33 * Frame buffer filling constructor.
34 *
35 * \param Width, Height - frame buffer texture size.
36 * \param Samples - frame buffer samples count.
37 * \param IsSwapChainTarget - frame buffer creating in purpose of rendering to screen.
38 * \param ColorAttachmentsCount - frame buffer color attachments count.
39 * \param DepthAttachmentsCount - frame buffer depth attachments count.
40 */
41 frame_buffer_props(int Width, int Height, int Samples = 1, bool IsSwapChainTarget = true, int ColorAttachmentsCount = 1, int DepthAttachmentsCount = 1, bool IsHDR = false) :
44 };
45
47 class frame_buffer: public render_primitive
48 {
49 public:
51 virtual void SetFrameBufferProps(const frame_buffer_props &Props) = 0;
53 virtual const frame_buffer_props &GetFrameBufferProps() const = 0;
55 virtual const shared<texture_2d> &GetColorAttachment(int Index = 0) const = 0;
57 virtual const shared<texture_2d> &GetDepthAttachment(int Index = 0) const = 0;
58
59 public:
61 virtual ~frame_buffer() = default;
62
63 /*!*
64 * Bind frame buffer to current render stage function.
65 *
66 * \param None.
67 * \return None.
68 */
69 virtual void Bind() const = 0;
70
71 /*!*
72 * Unbind frame buffer from current render stage function.
73 *
74 * \param None.
75 * \return None.
76 */
77 virtual void Unbind() const = 0;
78
79 /*!*
80 * Resize frame buffer (resize also could be called by setting frame buffer props).
81 *
82 * \param Width - new frame buffer width.
83 * \param Height - new frame buffer height.
84 * \return None.
85 */
86 virtual void Resize(int Width, int Height) = 0;
87
88 /*!*
89 * Unload frame buffer render target texture from GPU memory function.
90 *
91 * \param None.
92 * \return None.
93 */
94 virtual void Free() = 0;
95
96 /*!*
97 * Clear frame buffer funcrion.
98 *
99 * \param None.
100 * \return None.
101 */
102 virtual void Clear() = 0;
103
104 /*!*
105 * Create frame buffer function.
106 *
107 * \props Props - propsrties (specification) of creating frame buffer.
108 * \return None.
109 */
111 };
112}
virtual ~frame_buffer()=default
virtual const frame_buffer_props & GetFrameBufferProps() const =0
virtual void Resize(int Width, int Height)=0
virtual void Clear()=0
virtual void Bind() const =0
virtual const shared< texture_2d > & GetColorAttachment(int Index=0) const =0
virtual void Free()=0
virtual void SetFrameBufferProps(const frame_buffer_props &Props)=0
virtual void Unbind() const =0
static shared< frame_buffer > Create(const frame_buffer_props &Props)
virtual const shared< texture_2d > & GetDepthAttachment(int Index=0) const =0
Definition: base.h:33
std::shared_ptr< T > shared
Definition: smart_ptr.h:15
Render primitive abstract class definition module.
frame_buffer_props(int Width, int Height, int Samples=1, bool IsSwapChainTarget=true, int ColorAttachmentsCount=1, int DepthAttachmentsCount=1, bool IsHDR=false)
Definition: frame_buffer.h:41