Debian Codegraph @

platform/windows/gl_manager_windows_native.h

raw symbols SCIP
1 /**************************************************************************/
2 /* gl_manager_windows_native.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #if defined(WINDOWS_ENABLED) && defined(GLES3_ENABLED)
34
35 #include "core/os/os.h"
36 #include "core/templates/local_vector.h"
37 #include "servers/display/display_server.h"
38
39 #include <windows.h>
40
41 typedef bool(APIENTRY *PFNWGLSWAPINTERVALEXTPROC)(int interval);
42 typedef int(APIENTRY *PFNWGLGETSWAPINTERVALEXTPROC)(void);
43
44 class GLManagerNative_Windows {
45 private:
46 // any data specific to the window
47 struct GLWindow {
48 bool use_vsync = false;
49
50 // windows specific
51 HDC hDC;
52 HWND hwnd;
53
54 int gldisplay_id = 0;
55 };
56
57 struct GLDisplay {
58 // windows specific
59 HGLRC hRC;
60 };
61
62 RBMap<DisplayServer::WindowID, GLWindow> _windows;
63 LocalVector<GLDisplay> _displays;
64
65 GLWindow *_current_window = nullptr;
66
67 PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = nullptr;
68
69 GLWindow &get_window(unsigned int id) { return _windows[id]; }
70 const GLWindow &get_window(unsigned int id) const { return _windows[id]; }
71
72 const GLDisplay &get_current_display() const { return _displays[_current_window->gldisplay_id]; }
73 const GLDisplay &get_display(unsigned int id) { return _displays[id]; }
74
75 bool direct_render;
76 int glx_minor, glx_major;
77
78 private:
79 void _nvapi_setup_profile();
80 int _find_or_create_display(GLWindow &win);
81 Error _create_context(GLWindow &win, GLDisplay &gl_display);
82
83 public:
84 Error window_create(DisplayServer::WindowID p_window_id, HWND p_hwnd, HINSTANCE p_hinstance, int p_width, int p_height);
85 void window_destroy(DisplayServer::WindowID p_window_id);
86 void window_resize(DisplayServer::WindowID p_window_id, int p_width, int p_height) {}
87
88 void release_current();
89 void swap_buffers();
90
91 void window_make_current(DisplayServer::WindowID p_window_id);
92
93 Error initialize();
94
95 void set_use_vsync(DisplayServer::WindowID p_window_id, bool p_use);
96 bool is_using_vsync(DisplayServer::WindowID p_window_id) const;
97
98 HDC get_hdc(DisplayServer::WindowID p_window_id);
99 HGLRC get_hglrc(DisplayServer::WindowID p_window_id);
100
101 GLManagerNative_Windows();
102 ~GLManagerNative_Windows();
103 };
104
105 #endif // WINDOWS_ENABLED && GLES3_ENABLED