Update NSView-backed OpenGL context on resize

bzip2
Graham 5 years ago
parent 49a4cb3084
commit fb429421ed
  1. 12
      gl-natives/src/main/c/jaggl.c

@ -151,6 +151,7 @@ static CGLContextObj jaggl_context;
static CGLPixelFormatObj jaggl_pix; static CGLPixelFormatObj jaggl_pix;
static NSWindow *jaggl_window; static NSWindow *jaggl_window;
static NSView *jaggl_view; static NSView *jaggl_view;
static id<NSObject> jaggl_view_observer;
static NSOpenGLContext *jaggl_context_appkit; static NSOpenGLContext *jaggl_context_appkit;
static JagGLLayer *jaggl_layer; static JagGLLayer *jaggl_layer;
static bool jaggl_double_buffered; static bool jaggl_double_buffered;
@ -723,6 +724,13 @@ JNIEXPORT jboolean JNICALL Java_jaggl_context_destroy(JNIEnv *env, jclass cls) {
[jaggl_layer release]; [jaggl_layer release];
jaggl_layer = NULL; jaggl_layer = NULL;
} }
} else {
if (jaggl_view_observer) {
[[NSNotificationCenter defaultCenter] removeObserver:jaggl_view_observer];
jaggl_view_observer = nil;
}
jaggl_view = NULL;
} }
}); });
@ -1160,6 +1168,10 @@ JNIEXPORT jboolean JNICALL Java_jaggl_context_choosePixelFormat1(JNIEnv *env, jc
} else { } else {
struct jaggl_legacy_dsi *platformInfo = (struct jaggl_legacy_dsi *) dsi->platformInfo; struct jaggl_legacy_dsi *platformInfo = (struct jaggl_legacy_dsi *) dsi->platformInfo;
jaggl_view = platformInfo->view; jaggl_view = platformInfo->view;
jaggl_view_observer = [[NSNotificationCenter defaultCenter] addObserverForName:NSViewFrameDidChangeNotification object:jaggl_view queue:nil usingBlock:^(NSNotification *note) {
[jaggl_context_appkit update];
}];
} }
result = JNI_TRUE; result = JNI_TRUE;

Loading…
Cancel
Save