Ocean
rendering/Factory.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_FACTORY_H
9 #define META_OCEAN_RENDERING_FACTORY_H
10 
12 #include "ocean/rendering/Node.h"
14 
15 namespace Ocean
16 {
17 
18 namespace Rendering
19 {
20 
21 /**
22  * This class implements a node and object factory.<br>
23  * A factory instance can be received from the associated engine instance.<br>
24  * However, there is no guarantee that all objects are supported for a specific render engine.<br>
25  * Therefore, all factory functions will throw an exception if the selected object is not supported.
26  * @see Engine, NotSupportedException
27  * @ingroup rendering
28  */
29 class OCEAN_RENDERING_EXPORT Factory
30 {
31  public:
32 
33  /**
34  * Destructor
35  */
36  inline virtual ~Factory();
37 
38  /**
39  * Creates a new absolute transform.
40  * @return New absolute transform
41  * @exception NotSupportedException Is thrown if this function is not supported
42  */
44 
45  /**
46  * Creates a new attribute set object.
47  * @return New attribute set
48  * @exception NotSupportedException Is thrown if this function is not supported
49  */
50  virtual ObjectRef createAttributeSet() const;
51 
52  /**
53  * Creates a new billboard object.
54  * @return New billboard
55  * @exception NotSupportedException Is thrown if this function is not supported
56  */
57  virtual NodeRef createBillboard() const;
58 
59  /**
60  * Creates a new blend attribute object.
61  * @return New blend attribute
62  * @exception NotSupportedException Is thrown if this function is not supported
63  */
65 
66  /**
67  * Creates a new box object.
68  * @return New box
69  * @exception NotSupportedException Is thrown if this function is not supported
70  */
71  virtual ObjectRef createBox() const;
72 
73  /**
74  * Creates a new cone object.
75  * @return New cone
76  * @exception NotSupportedException Is thrown if this function is not supported
77  */
78  virtual ObjectRef createCone() const;
79 
80  /**
81  * Creates a new cylinder object.
82  * @return New cylinder
83  * @exception NotSupportedException Is thrown if this function is not supported
84  */
85  virtual ObjectRef createCylinder() const;
86 
87  /**
88  * Creates a new depth attribute object.
89  * @return New depth attribute
90  * @exception NotSupportedException Is thrown if this function is not supported
91  */
93 
94  /**
95  * Creates a new directional light object.
96  * @return New directional light
97  * @exception NotSupportedException Is thrown if this function is not supported
98  */
100 
101  /**
102  * Creates a new frame texture object.
103  * @return New texture
104  * @exception NotSupportedException Is thrown if this function is not supported
105  */
107 
108  /**
109  * Creates a new geometry object.
110  * @return New geometry
111  * @exception NotSupportedException Is thrown if this function is not supported
112  */
113  virtual NodeRef createGeometry() const;
114 
115  /**
116  * Creates a new group object.
117  * @return New group
118  * @exception NotSupportedException Is thrown if this function is not supported
119  */
120  virtual NodeRef createGroup() const;
121 
122  /**
123  * Creates a new lines object.
124  * @return New lines
125  * @exception NotSupportedException Is thrown if this function is not supported
126  */
127  virtual ObjectRef createLines() const;
128 
129  /**
130  * Creates a new line strips object.
131  * @return New line strips
132  * @exception NotSupportedException Is thrown if this function is not supported
133  */
134  virtual ObjectRef createLineStrips() const;
135 
136  /**
137  * Creates a new LOD object.
138  * @return new LOD
139  * @exception NotSupportedException Is thrown if this function is not supported
140  */
141  virtual NodeRef createLOD() const;
142 
143  /**
144  * Creates a new material object.
145  * @return New material
146  * @exception NotSupportedException Is thrown if this function is not supported
147  */
148  virtual ObjectRef createMaterial() const;
149 
150  /**
151  * Creates a new media texture object.
152  * @return New texture
153  * @exception NotSupportedException Is thrown if this function is not supported
154  */
156 
157  /**
158  * Creates a new parallel view object.
159  * @return New parallel view
160  * @exception NotSupportedException Is thrown if this function is not supported
161  */
162  virtual ObjectRef createParallelView() const;
163 
164  /**
165  * Creates a new perspective view object.
166  * @return New perspective view
167  * @exception NotSupportedException Is thrown if this function is not supported
168  */
170 
171  /**
172  * Creates a new phantom attribute object.
173  * @return New phantom attribute
174  * @exception NotSupportedException Is thrown if this function is not supported
175  */
177 
178  /**
179  * Creates a new point light object.
180  * @return New light
181  * @exception NotSupportedException Is thrown if this function is not supported
182  */
183  virtual ObjectRef createPointLight() const;
184 
185  /**
186  * Creates a new points object.
187  * @return New points
188  * @exception NotSupportedException Is thrown if this function is not supported
189  */
190  virtual ObjectRef createPoints() const;
191 
192  /**
193  * Creates a new primitive attribute object.
194  * @return New attribute
195  * @exception NotSupportedException Is thrown if this function is not supported
196  */
198 
199  /**
200  * Creates a new quads object.
201  * @return New quads
202  * @exception NotSupportedException Is thrown if this function is not supported
203  */
204  virtual ObjectRef createQuads() const;
205 
206  /**
207  * Creates a new quad strips object.
208  * @return New quad strips
209  * @exception NotSupportedException Is thrown if this function is not supported
210  */
211  virtual ObjectRef createQuadStrips() const;
212 
213  /**
214  * Creates a new scene object.
215  * @return New scene
216  * @exception NotSupportedException Is thrown if this function is not supported
217  */
218  virtual NodeRef createScene() const;
219 
220  /**
221  * Creates a new shader program object.
222  * @return New shader program
223  * @exception NotSupportedException Is thrown if this function is not supported
224  */
226 
227  /**
228  * Creates a new sky background object.
229  * @return New sky background
230  * @exception NotSupportedException Is thrown if this function is not supported
231  */
232  virtual NodeRef createSkyBackground() const;
233 
234  /**
235  * Creates a new sphere object.
236  * @return New sphere
237  * @exception NotSupportedException Is thrown if this function is not supported
238  */
239  virtual ObjectRef createSphere() const;
240 
241  /**
242  * Creates a new spot light object.
243  * @return New spot light
244  * @exception NotSupportedException Is thrown if this function is not supported
245  */
246  virtual ObjectRef createSpotLight() const;
247 
248  /**
249  * Creates a new stereo attribute object.
250  * @return New stereo attribute
251  * @exception NotSupportedException Is thrown if this function is not supported
252  */
254 
255  /**
256  * Creates a new stereo view object.
257  * @return New stereo view
258  * @exception NotSupportedException Is thrown if this function is not supported
259  */
260  virtual ObjectRef createStereoView() const;
261 
262  /**
263  * Creates a new switch object.
264  * @return New switch
265  * @exception NotSupportedException Is thrown if this function is not supported
266  */
267  virtual NodeRef createSwitch() const;
268 
269  /**
270  * Creates a new text object.
271  * @return The new text framebuffer object
272  * @exception NotSupportedException Is thrown if this function is not supported
273  */
274  virtual ObjectRef createText() const;
275 
276  /**
277  * Creates a new texture framebuffer object.
278  * @return The new texture framebuffer object
279  * @exception NotSupportedException Is thrown if this function is not supported
280  */
282 
283  /**
284  * Creates a new texture attribute object.
285  * @return New texture attribute
286  * @exception NotSupportedException Is thrown if this function is not supported
287  */
288  virtual ObjectRef createTextures() const;
289 
290  /**
291  * Creates a new transform object.
292  * @return New transform
293  * @exception NotSupportedException Is thrown if this function is not supported
294  */
295  virtual NodeRef createTransform() const;
296 
297  /**
298  * Creates a new triangles object.
299  * @return New triangles
300  * @exception NotSupportedException Is thrown if this function is not supported
301  */
302  virtual ObjectRef createTriangles() const;
303 
304  /**
305  * Creates a new triangle fans object.
306  * @return New triangle fans
307  * @exception NotSupportedException Is thrown if this function is not supported
308  */
309  virtual ObjectRef createTriangleFans() const;
310 
311  /**
312  * Creates a new triangle strips object.
313  * @return New triangle strips
314  * @exception NotSupportedException Is thrown if this function is not supported
315  */
317 
318  /**
319  * Creates a new undistorted background node.
320  * @return New undistorted background
321  * @exception NotSupportedException Is thrown if this function is not supported
322  */
324 
325  /**
326  * Creates a new vertex set object.
327  * @return New vertex set
328  * @exception NotSupportedException Is thrown if this function is not supported
329  */
330  virtual ObjectRef createVertexSet() const;
331 
332  /**
333  * Creates a new object specified by the object type name.
334  * This function may be overloaded if a rendering plugin supports more than the standard objects.
335  * @param type The type of the object to be created, must be valid
336  * @return New rendering object if available, otherwise an empty object reference
337  * @exception NotSupportedException Is thrown if this function is not supported
338  */
339  virtual ObjectRef createObject(const std::string& type) const;
340 
341  protected:
342 
343  /**
344  * Protected default constructor creating a new Factory.
345  */
347 
348  /**
349  * Disabled copy constructor.
350  * @param factory Object which would be copied
351  */
352  Factory(const Factory& factory) = delete;
353 
354  /**
355  * Creates a new object reference by a given object.
356  * @param object The object to create a object reference from, must be valid
357  * @return Created object reference
358  */
359  inline ObjectRef createReference(Object* object) const;
360 
361  /**
362  * Disabled copy operator.
363  * @param factory Object which would be copied
364  * @return Reference to this object
365  */
366  Factory& operator=(const Factory& factory) = delete;
367 };
368 
370 {
371  // Nothing else to do.
372 }
373 
375 {
376  ocean_assert(object != nullptr);
377  return ObjectRefManager::get().registerObject(object);
378 }
379 
380 }
381 
382 }
383 
384 #endif // META_OCEAN_RENDERING_FACTORY_H
This class implements a node and object factory.
Definition: rendering/Factory.h:30
virtual ObjectRef createMediaTexture2D() const
Creates a new media texture object.
virtual NodeRef createTransform() const
Creates a new transform object.
Factory & operator=(const Factory &factory)=delete
Disabled copy operator.
virtual ~Factory()
Destructor.
Definition: rendering/Factory.h:369
virtual ObjectRef createLines() const
Creates a new lines object.
Factory()
Protected default constructor creating a new Factory.
virtual ObjectRef createParallelView() const
Creates a new parallel view object.
ObjectRef createReference(Object *object) const
Creates a new object reference by a given object.
Definition: rendering/Factory.h:374
virtual ObjectRef createDirectionalLight() const
Creates a new directional light object.
virtual NodeRef createBillboard() const
Creates a new billboard object.
virtual ObjectRef createQuads() const
Creates a new quads object.
virtual ObjectRef createTextures() const
Creates a new texture attribute object.
virtual NodeRef createScene() const
Creates a new scene object.
virtual ObjectRef createCylinder() const
Creates a new cylinder object.
virtual NodeRef createGeometry() const
Creates a new geometry object.
virtual NodeRef createSwitch() const
Creates a new switch object.
virtual ObjectRef createQuadStrips() const
Creates a new quad strips object.
virtual ObjectRef createAttributeSet() const
Creates a new attribute set object.
virtual ObjectRef createPhantomAttribute() const
Creates a new phantom attribute object.
virtual ObjectRef createBox() const
Creates a new box object.
virtual ObjectRef createPoints() const
Creates a new points object.
virtual ObjectRef createTriangleFans() const
Creates a new triangle fans object.
virtual NodeRef createSkyBackground() const
Creates a new sky background object.
virtual ObjectRef createAbsoluteTransform() const
Creates a new absolute transform.
virtual ObjectRef createPerspectiveView() const
Creates a new perspective view object.
virtual NodeRef createGroup() const
Creates a new group object.
virtual ObjectRef createTriangles() const
Creates a new triangles object.
virtual ObjectRef createObject(const std::string &type) const
Creates a new object specified by the object type name.
virtual ObjectRef createDepthAttribute() const
Creates a new depth attribute object.
virtual ObjectRef createSpotLight() const
Creates a new spot light object.
virtual ObjectRef createFrameTexture2D() const
Creates a new frame texture object.
virtual ObjectRef createPointLight() const
Creates a new point light object.
virtual ObjectRef createTextureFramebuffer() const
Creates a new texture framebuffer object.
virtual ObjectRef createStereoView() const
Creates a new stereo view object.
virtual ObjectRef createStereoAttribute() const
Creates a new stereo attribute object.
virtual ObjectRef createMaterial() const
Creates a new material object.
Factory(const Factory &factory)=delete
Disabled copy constructor.
virtual ObjectRef createCone() const
Creates a new cone object.
virtual NodeRef createLOD() const
Creates a new LOD object.
virtual ObjectRef createVertexSet() const
Creates a new vertex set object.
virtual ObjectRef createSphere() const
Creates a new sphere object.
virtual ObjectRef createShaderProgram() const
Creates a new shader program object.
virtual ObjectRef createText() const
Creates a new text object.
virtual ObjectRef createPrimitiveAttribute() const
Creates a new primitive attribute object.
virtual ObjectRef createBlendAttribute() const
Creates a new blend attribute object.
virtual ObjectRef createLineStrips() const
Creates a new line strips object.
virtual ObjectRef createTriangleStrips() const
Creates a new triangle strips object.
virtual NodeRef createUndistortedBackground() const
Creates a new undistorted background node.
This class is the base class for all rendering objects.
Definition: Object.h:54
static ObjectRefManager & get()
Returns a reference to the unique object.
Definition: Singleton.h:115
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15