Fix OpenGL context caching on macOS (#737)
This commit is contained in:
parent
89133cf1e1
commit
84ecb32c98
1
FL/mac.H
1
FL/mac.H
@ -214,6 +214,7 @@ public:
|
||||
static void GLcontext_flushbuffer(NSOpenGLContext*);
|
||||
static void GLcontext_release(NSOpenGLContext*);
|
||||
static void GLcontext_makecurrent(NSOpenGLContext*);
|
||||
static NSOpenGLContext* GLcontext_getcurrent();
|
||||
static void GL_cleardrawable(void);
|
||||
static void gl_start(NSOpenGLContext*);
|
||||
void destroy(void);
|
||||
|
||||
@ -409,6 +409,11 @@ static GLContext cached_context;
|
||||
static Fl_Window* cached_window;
|
||||
|
||||
void fl_set_gl_context(Fl_Window* w, GLContext context) {
|
||||
#ifdef __APPLE_QUARTZ__
|
||||
// macOS may switch buffers during swapping, so we override the
|
||||
// cached context with the actual current context (#737)
|
||||
cached_context = Fl_X::GLcontext_getcurrent();
|
||||
#endif
|
||||
if (context != cached_context || w != cached_window) {
|
||||
cached_context = context;
|
||||
cached_window = w;
|
||||
@ -439,6 +444,11 @@ void fl_no_gl_context() {
|
||||
}
|
||||
|
||||
void fl_delete_gl_context(GLContext context) {
|
||||
#ifdef __APPLE_QUARTZ__
|
||||
// macOS may switch buffers during swapping, so we override the
|
||||
// cached context with the actual current context (#737)
|
||||
cached_context = Fl_X::GLcontext_getcurrent();
|
||||
#endif
|
||||
if (cached_context == context) fl_no_gl_context();
|
||||
# if defined(USE_X11)
|
||||
glXDestroyContext(fl_display, context);
|
||||
|
||||
@ -3094,6 +3094,11 @@ void Fl_X::GLcontext_makecurrent(NSOpenGLContext* ctxt)
|
||||
[ctxt makeCurrentContext];
|
||||
}
|
||||
|
||||
NSOpenGLContext* Fl_X::GLcontext_getcurrent()
|
||||
{
|
||||
return [NSOpenGLContext currentContext];
|
||||
}
|
||||
|
||||
void Fl_Window::fullscreen_x() {
|
||||
_set_fullscreen();
|
||||
if (fl_mac_os_version < 101000) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user