| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 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 |
|
| 47 |
struct GLWindow { |
| 48 |
bool use_vsync = false; |
| 49 |
|
| 50 |
|
| 51 |
HDC hDC; |
| 52 |
HWND hwnd; |
| 53 |
|
| 54 |
int gldisplay_id = 0; |
| 55 |
}; |
| 56 |
|
| 57 |
struct GLDisplay { |
| 58 |
|
| 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 |