13 #import <Cocoa/Cocoa.h>
15 #include <unordered_map>
19 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
24 static std::unordered_map<int, NSOpenGLContext*> inst;
28 inline bool AtLeastVersion(SDL_version sdl_ver,
int major,
int minor,
int patch)
30 return ((sdl_ver.major > major) ||
31 (sdl_ver.major == major && sdl_ver.minor > minor) ||
32 (sdl_ver.major == major && sdl_ver.minor == minor && sdl_ver.patch >= patch));
41 [NSApp nextEventMatchingMask:NSEventMaskAny
42 untilDate:[NSDate dateWithTimeIntervalSinceNow:0.500]
43 inMode:NSDefaultRunLoopMode
52 NSPoint loc = {0., 0.};
53 [NSApp postEvent:[NSEvent otherEventWithType:NSEventTypeApplicationDefined
68 static bool first_call =
true;
69 static bool value =
false;
73 SDL_GetVersion(&sdl_ver);
84 NSOpenGLContext* ctx = [NSOpenGLContext currentContext];
86 dispatch_sync(dispatch_get_main_queue(), ^{ [ctx update]; });
94 NSOpenGLContext* ctx = [NSOpenGLContext currentContext];
96 [NSOpenGLContext clearCurrentContext];
105 [ctx makeCurrentContext];
115 std::lock_guard<std::mutex> lk{
swap_mtx};
116 [[NSOpenGLContext currentContext] flushBuffer];
bool AtLeastVersion(SDL_version sdl_ver, int major, int minor, int patch)
std::unordered_map< int, NSOpenGLContext * > & GetContextMap()