| 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(MACOS_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 |
#import <AppKit/AppKit.h> |
| 40 |
#import <ApplicationServices/ApplicationServices.h> |
| 41 |
#import <CoreVideo/CoreVideo.h> |
| 42 |
|
| 43 |
GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wdeprecated-declarations") |
| 44 |
|
| 45 |
typedef CGLError (*CGLEnablePtr)(CGLContextObj ctx, CGLContextEnable pname); |
| 46 |
typedef CGLError (*CGLSetParameterPtr)(CGLContextObj ctx, CGLContextParameter pname, const GLint *params); |
| 47 |
typedef CGLContextObj (*CGLGetCurrentContextPtr)(void); |
| 48 |
|
| 49 |
class GLManagerLegacy_MacOS { |
| 50 |
struct GLWindow { |
| 51 |
id window_view = nullptr; |
| 52 |
NSOpenGLContext *context = nullptr; |
| 53 |
}; |
| 54 |
|
| 55 |
RBMap<DisplayServer::WindowID, GLWindow> windows; |
| 56 |
|
| 57 |
NSOpenGLContext *shared_context = nullptr; |
| 58 |
DisplayServer::WindowID current_window = DisplayServer::INVALID_WINDOW_ID; |
| 59 |
|
| 60 |
Error create_context(GLWindow &win); |
| 61 |
|
| 62 |
bool framework_loaded = false; |
| 63 |
bool use_vsync = false; |
| 64 |
CGLEnablePtr CGLEnable = nullptr; |
| 65 |
CGLSetParameterPtr CGLSetParameter = nullptr; |
| 66 |
CGLGetCurrentContextPtr CGLGetCurrentContext = nullptr; |
| 67 |
|
| 68 |
public: |
| 69 |
Error window_create(DisplayServer::WindowID p_window_id, id p_view, int p_width, int p_height); |
| 70 |
void window_destroy(DisplayServer::WindowID p_window_id); |
| 71 |
void window_resize(DisplayServer::WindowID p_window_id, int p_width, int p_height); |
| 72 |
|
| 73 |
void release_current(); |
| 74 |
void swap_buffers(); |
| 75 |
|
| 76 |
void window_make_current(DisplayServer::WindowID p_window_id); |
| 77 |
|
| 78 |
void window_set_per_pixel_transparency_enabled(DisplayServer::WindowID p_window_id, bool p_enabled); |
| 79 |
|
| 80 |
Error initialize(); |
| 81 |
|
| 82 |
void set_use_vsync(bool p_use); |
| 83 |
bool is_using_vsync() const; |
| 84 |
|
| 85 |
NSOpenGLContext *get_context(DisplayServer::WindowID p_window_id); |
| 86 |
|
| 87 |
GLManagerLegacy_MacOS(); |
| 88 |
~GLManagerLegacy_MacOS(); |
| 89 |
}; |
| 90 |
|
| 91 |
GODOT_CLANG_WARNING_PUSH |
| 92 |
|
| 93 |
#endif |