Ocean
rendering/WindowFramebuffer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_RENDERING_WINDOW_FRAMEBUFFER_H
9 #define META_OCEAN_RENDERING_WINDOW_FRAMEBUFFER_H
10 
13 
14 namespace Ocean
15 {
16 
17 namespace Rendering
18 {
19 
20 // Forward declaration
21 class WindowFramebuffer;
22 
23 /**
24  * Definition of a smart object reference holding a window framebuffer node.
25  * @see SmartObjectRef, WindowFramebuffer.
26  * @ingroup rendering
27  */
29 
30 /**
31  * This class is the base class for all window framebuffers.
32  * To initialize the framebuffer set the id of the window receiving the framebuffer.<br>
33  * All userdefined framebuffer properties must be set before the id is set.<br>
34  *
35  * Sample code for windows platforms:
36  * @code
37  * void newFramebuffer(const EngineRef engine, HWND window)
38  * {
39  * WindowFramebufferRef framebuffer = engine.createFramebuffer(Framebuffer::FRAMEBUFFER_WINDOW);
40  *
41  * if (!framebuffer)
42  * throw OceanException("Failed to create a new framebuffer");
43  *
44  * framebuffer->setSupportAntialiasing(4);
45  *
46  * if (!framebuffer->setId(size_t(window)))
47  * throw OceanException("Failed to initialize the framebuffer");
48  *
49  * // ...
50  * }
51  * @endcode
52  * @ingroup rendering
53  */
54 class OCEAN_RENDERING_EXPORT WindowFramebuffer : virtual public Framebuffer
55 {
56  public:
57 
58  /**
59  * Returns the type of this framebuffer.
60  * @see Framebuffer::framebufferType().
61  */
62  FramebufferType framebufferType() const override;
63 
64  /**
65  * Returns the platform dependent framebuffer base id or handle.
66  * @return Id or handle of the framebuffer base
67  * @see initializeById().
68  * @exception NotSupportedException Is thrown if this function is not supported
69  */
70  virtual size_t id() const;
71 
72  /**
73  * Sets the platform dependent framebuffer base id or handle and initializes the framebuffer.
74  * This id can be a handle of a window.<br>
75  * E.g. on windows platforms this id must be the window handle (HWND).<br>
76  * The definition of the id will initialize the rendering context for this framebuffer.
77  * @param id Id or handle of the framebuffer base
78  * @param shareFramebuffer Optional framebuffer to share resources with
79  * @return True, if succeeded
80  * @see id().
81  * @exception NotSupportedException Is thrown if this function is not supported
82  */
83  virtual bool initializeById(const size_t id, const FramebufferRef& shareFramebuffer = FramebufferRef());
84 
85  /**
86  * Returns the type of this object.
87  * @see Object::type().
88  */
89  ObjectType type() const override;
90 
91  protected:
92 
93  /**
94  * Creates a new window framebuffer.
95  */
97 
98  /**
99  * Destructs a window framebuffer.
100  */
101  ~WindowFramebuffer() override;
102 };
103 
104 }
105 
106 }
107 
108 #endif // META_OCEAN_RENDERING_WINDOW_FRAMEBUFFER_H
This class is the base class for all rendering framebuffers.
Definition: rendering/Framebuffer.h:48
FramebufferType
Definition of different framebuffer types.
Definition: rendering/Framebuffer.h:55
ObjectType
Definition of different object type.
Definition: Object.h:63
This class is the base class for all window framebuffers.
Definition: rendering/WindowFramebuffer.h:55
FramebufferType framebufferType() const override
Returns the type of this framebuffer.
virtual size_t id() const
Returns the platform dependent framebuffer base id or handle.
virtual bool initializeById(const size_t id, const FramebufferRef &shareFramebuffer=FramebufferRef())
Sets the platform dependent framebuffer base id or handle and initializes the framebuffer.
~WindowFramebuffer() override
Destructs a window framebuffer.
ObjectType type() const override
Returns the type of this object.
WindowFramebuffer()
Creates a new window framebuffer.
SmartObjectRef< WindowFramebuffer > WindowFramebufferRef
Definition of a smart object reference holding a window framebuffer node.
Definition: rendering/WindowFramebuffer.h:21
SmartObjectRef< Framebuffer > FramebufferRef
Definition of a smart object reference holding a framebuffer.
Definition: rendering/Framebuffer.h:31
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15