Ocean
win/WindowContext.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_PLATFORM_GL_WIN_WINDOW_CONTEXT_H
9 #define META_OCEAN_PLATFORM_GL_WIN_WINDOW_CONTEXT_H
10 
12 
14 
16 
17 namespace Ocean
18 {
19 
20 namespace Platform
21 {
22 
23 namespace GL
24 {
25 
26 namespace Win
27 {
28 
29 /**
30  * This class implements an OpenGL context based on a window.
31  * @ingroup platformglwin
32  */
33 class OCEAN_PLATFORM_GL_WIN_EXPORT WindowContext :
34  public Platform::Win::Window,
35  public Context
36 {
37  public:
38 
39  /**
40  * Creates a new main window.
41  * @param applicationInstance Application instance
42  * @param name name of the application window
43  * @param isChild True, if the window is intended to be child window
44  */
45  WindowContext(HINSTANCE applicationInstance, const std::wstring& name, const bool isChild);
46 
47  /**
48  * Destructs the main window.
49  */
50  ~WindowContext() override;
51 
52  /**
53  * Creates the OpenGL context for this framebuffer.
54  * @see Context::createOpenGLContext().
55  */
56  bool createOpenGLContext(const bool initializeOpenGL33, const unsigned int multisamples) override;
57 
58  /**
59  * Makes the OpenGL rendering context of this framebuffer the calling thread's current rendering context or makes the calling thread's current rendering context not longer current.
60  * @see Context::makeCurrent().
61  */
62  void makeCurrent(const bool state = true) override;
63 
64  /**
65  * Swaps the foreground and background buffer if this context has two buffers.
66  * @see Context::swapBuffers().
67  */
68  bool swapBuffers() override;
69 
70  protected:
71 
72  /**
73  * Event function if the windows has been initialized successfully.
74  * @see Window::onInitialized().
75  */
76  void onInitialized() override;
77 
78  /**
79  * Allows the modification of the window class before the registration.
80  * @see Window::modifyWindowClass().
81  */
82  void modifyWindowClass(WNDCLASS& windowClass) override;
83 };
84 
85 }
86 
87 }
88 
89 }
90 
91 }
92 
93 #endif // META_OCEAN_PLATFORM_GL_WIN_WINDOW_CONTEXT_H
This class encapsulates an OpenGL context.
Definition: platform/gl/Context.h:29
This class implements an OpenGL context based on a window.
Definition: win/WindowContext.h:36
WindowContext(HINSTANCE applicationInstance, const std::wstring &name, const bool isChild)
Creates a new main window.
~WindowContext() override
Destructs the main window.
void onInitialized() override
Event function if the windows has been initialized successfully.
bool swapBuffers() override
Swaps the foreground and background buffer if this context has two buffers.
void modifyWindowClass(WNDCLASS &windowClass) override
Allows the modification of the window class before the registration.
bool createOpenGLContext(const bool initializeOpenGL33, const unsigned int multisamples) override
Creates the OpenGL context for this framebuffer.
void makeCurrent(const bool state=true) override
Makes the OpenGL rendering context of this framebuffer the calling thread's current rendering context...
This class is the base class for all windows.
Definition: Window.h:31
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15