Skip to content

Commit

Permalink
macOS: Multiple windows broken with OpenGL backend (closes HumbleUI#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsky committed Aug 20, 2021
1 parent e7b4441 commit ca107e3
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Alpha. Expect API breakages.
| | Windows | macOS | X11 |
|------------|---------|-------|-----|
| Raster || [#81](https://github.com/jetbrains/jwm/issues/81) ||
| OpenGL || [#118](https://github.com/jetbrains/jwm/issues/118) ||
| OpenGL || ||
| DirectX 11 ||||
| DirectX 12 ||||
| Metal ||||
Expand Down
2 changes: 2 additions & 0 deletions examples/java/org/jetbrains/jwm/examples/SkijaLayerGL.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class SkijaLayerGL extends LayerGL implements SkijaLayer {

@Override
public Canvas beforePaint() {
makeCurrent();

if (_directContext == null)
_directContext = DirectContext.makeGL();

Expand Down
4 changes: 4 additions & 0 deletions linux/cc/LayerGL.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_jwm_LayerGL__1nResize
instance->resize(width, height);
}

extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_jwm_LayerGL__1nMakeCurrent
(JNIEnv* env, jobject obj) {
}

extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_jwm_LayerGL__1nSwapBuffers
(JNIEnv* env, jobject obj) {
jwm::LayerGL* instance = reinterpret_cast<jwm::LayerGL*>(jwm::classes::Native::fromJava(env, obj));
Expand Down
6 changes: 6 additions & 0 deletions macos/cc/LayerGL.mm
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ void close() {
(JNIEnv* env, jobject obj, jint width, jint height) {
}

extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_jwm_LayerGL__1nMakeCurrent
(JNIEnv* env, jobject obj) {
jwm::LayerGL* instance = reinterpret_cast<jwm::LayerGL*>(jwm::classes::Native::fromJava(env, obj));
[instance->fGLContext makeCurrentContext];
}

extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_jwm_LayerGL__1nResize
(JNIEnv* env, jobject obj, jint width, jint height) {
jwm::LayerGL* instance = reinterpret_cast<jwm::LayerGL*>(jwm::classes::Native::fromJava(env, obj));
Expand Down
6 changes: 6 additions & 0 deletions shared/java/org/jetbrains/jwm/LayerGL.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public int getHeight() {
return _height;
}

public void makeCurrent() {
assert _onUIThread();
_nMakeCurrent();
}

@Override
public void swapBuffers() {
assert _onUIThread();
Expand All @@ -66,6 +71,7 @@ public void close() {
@ApiStatus.Internal public static native long _nMake();
@ApiStatus.Internal public native void _nAttach(Window window);
@ApiStatus.Internal public native void _nReconfigure();
@ApiStatus.Internal public native void _nMakeCurrent();
@ApiStatus.Internal public native void _nResize(int width, int height);
@ApiStatus.Internal public native void _nSwapBuffers();
@ApiStatus.Internal public native void _nClose();
Expand Down
4 changes: 4 additions & 0 deletions windows/cc/LayerWGL.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_jwm_LayerGL__1nResize
instance->resize(width, height);
}

extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_jwm_LayerGL__1nMakeCurrent
(JNIEnv* env, jobject obj) {
}

extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_jwm_LayerGL__1nSwapBuffers
(JNIEnv* env, jobject obj) {
jwm::LayerWGL* instance = reinterpret_cast<jwm::LayerWGL*>(jwm::classes::Native::fromJava(env, obj));
Expand Down

0 comments on commit ca107e3

Please sign in to comment.