Ocean
windows/GLESWindowFramebuffer.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_GLES_WINDOWS_GLES_WINDOW_FRAMEBUFFER_H
9 #define META_OCEAN_RENDERING_GLES_WINDOWS_GLES_WINDOW_FRAMEBUFFER_H
10 
14 
16 
17 #ifndef _WINDOWS
18  #error This file is available on Windows platforms only!
19 #endif
20 
21 #include <gl/wglext.h>
22 
23 namespace Ocean
24 {
25 
26 namespace Rendering
27 {
28 
29 namespace GLESceneGraph
30 {
31 
32 namespace Windows
33 {
34 
35 /**
36  * This class is the base class for all GLESceneGraph window framebuffers for Windows platforms.
37  * @ingroup renderinggles
38  */
39 class OCEAN_RENDERING_GLES_EXPORT GLESWindowFramebuffer :
40  virtual public GLESFramebuffer,
41  virtual public WindowFramebuffer
42 {
43  friend class GLESEngineWindows;
44 
45  public:
46 
47  /**
48  * Sets the platform dependent framebuffer base id or handle and initializes the framebuffer.
49  * @see WindowFramebuffer::initializeById().
50  */
51  bool initializeById(const size_t id, const FramebufferRef& shareFramebuffer = FramebufferRef()) override;
52 
53  /**
54  * Returns whether the framebuffer supports hardware anti-aliasing.
55  * @see Framebuffer::isAntialiasingSupported().
56  */
57  bool isAntialiasingSupported(const unsigned int buffers) const override;
58 
59  /**
60  * Returns whether the framebuffer uses hardware anti-aliasing.
61  * @see Framebuffer::isAntialiasing().
62  */
63  bool isAntialiasing() const override;
64 
65  /**
66  * Sets the preferred pixel format of this framebuffer.
67  * @see Framebuffer::setPreferredPixelFormat().
68  */
69  void setPreferredPixelFormat(const FrameType::PixelFormat pixelFormat) override;
70 
71  /**
72  * Sets whether this framebuffer will support hardware anti-aliasing.
73  * @see setSupportAntialiasing().
74  */
75  bool setSupportAntialiasing(const unsigned int buffers) override;
76 
77  /**
78  * Renders the next frame into the framebuffer.
79  * @see Framebuffer::render().
80  */
81  void render() override;
82 
83  /**
84  * Makes this framebuffer to the current one.
85  * @see Framebuffer::makeCurrent().
86  */
87  void makeCurrent() override;
88 
89  private:
90 
91  /**
92  * Creates a new GLESceneGraph window framebuffer.
93  */
95 
96  /**
97  * Destructs a GLESceneGraph window framebuffer.
98  */
100 
101  /**
102  * Initialize the OpenGL ES display and context.
103  * @return True, if succeeded
104  */
105  bool initializeContext() override;
106 
107  /**
108  * Releases the framebuffer.
109  * @see Framebuffer::release().
110  */
111  void release() override;
112 
113  /**
114  * Acquires all OpenGL function pointers.
115  * @return True, if succeeded
116  */
118 
119  private:
120 
121  /// The OpenGL context handle.
122  HGLRC contextHandle_ = nullptr;
123 
124  /// The window handle.
125  HWND windowHandle_ = nullptr;
126 
127  /// The device context.
128  HDC windowDC_ = nullptr;
129 
130  /// The function pointer to wglCreateContextAttribsARB.
131  PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB_ = nullptr;
132 
133  /// The function pointer to wglChoosePixelFormatARB.
134  PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB_ = nullptr;
135 
136  /// True to enable vertical synchronization; False, to disable vertical synchronization
137  bool framebufferVerticalSynchronization = true;
138 
139  /// Preferred pixel format which should be used during context initialization.
140  FrameType::PixelFormat framebufferPreferredPixelFormat = FrameType::FORMAT_RGBA32;
141 
142  /// The Number of preferred multi-sampling anti-aliasing buffers.
143  unsigned int antialiasingBuffers_ = 4u;
144 };
145 
146 }
147 
148 }
149 
150 }
151 
152 }
153 
154 #endif // META_OCEAN_RENDERING_GLES_WINDOWS_GLES_WINDOW_FRAMEBUFFER_H
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition: Frame.h:183
@ FORMAT_RGBA32
Pixel format with byte order RGBA and 32 bits per pixel.
Definition: Frame.h:382
This class implements a base for all GLESceneGraph framebuffers.
Definition: rendering/glescenegraph/GLESFramebuffer.h:34
This class implements the engine for Windows platforms.
Definition: GLESEngineWindows.h:31
This class is the base class for all GLESceneGraph window framebuffers for Windows platforms.
Definition: windows/GLESWindowFramebuffer.h:42
bool setSupportAntialiasing(const unsigned int buffers) override
Sets whether this framebuffer will support hardware anti-aliasing.
void makeCurrent() override
Makes this framebuffer to the current one.
void render() override
Renders the next frame into the framebuffer.
GLESWindowFramebuffer()
Creates a new GLESceneGraph window framebuffer.
void setPreferredPixelFormat(const FrameType::PixelFormat pixelFormat) override
Sets the preferred pixel format of this framebuffer.
bool isAntialiasingSupported(const unsigned int buffers) const override
Returns whether the framebuffer supports hardware anti-aliasing.
void release() override
Releases the framebuffer.
bool acquireGLFunctions()
Acquires all OpenGL function pointers.
bool initializeContext() override
Initialize the OpenGL ES display and context.
~GLESWindowFramebuffer() override
Destructs a GLESceneGraph window framebuffer.
bool initializeById(const size_t id, const FramebufferRef &shareFramebuffer=FramebufferRef()) override
Sets the platform dependent framebuffer base id or handle and initializes the framebuffer.
bool isAntialiasing() const override
Returns whether the framebuffer uses hardware anti-aliasing.
This class is the base class for all window framebuffers.
Definition: rendering/WindowFramebuffer.h:55
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