11package processing .webgpu ;
22
3- import org .lwjgl .glfw .GLFW ;
4- import org .lwjgl .glfw .GLFWErrorCallback ;
5- import org .lwjgl .glfw .GLFWFramebufferSizeCallback ;
6- import org .lwjgl .glfw .GLFWNativeCocoa ;
7- import org .lwjgl .glfw .GLFWNativeWin32 ;
8- import org .lwjgl .glfw .GLFWWindowPosCallback ;
3+ import org .lwjgl .glfw .*;
94import org .lwjgl .system .MemoryUtil ;
105import org .lwjgl .system .Platform ;
116
@@ -30,6 +25,7 @@ public class PSurfaceGLFW implements PSurface {
3025 protected PGraphics graphics ;
3126
3227 protected long window ;
28+ protected long display ;
3329 protected boolean running = false ;
3430
3531 protected boolean paused ;
@@ -78,6 +74,8 @@ public void initFrame(PApplet sketch) {
7874 throw new RuntimeException ("Failed to create GLFW window" );
7975 }
8076
77+ display = GLFW .glfwGetPrimaryMonitor ();
78+
8179 windowCount .incrementAndGet ();
8280
8381 // event callbacks
@@ -87,11 +85,12 @@ public void initFrame(PApplet sketch) {
8785 PWebGPU .init ();
8886
8987 long windowHandle = getWindowHandle ();
88+ long displayHandle = getDisplayHandle ();
9089 int width = sketch .sketchWidth ();
9190 int height = sketch .sketchHeight ();
9291 float scaleFactor = sketch .sketchPixelDensity ();
9392
94- webgpu .initWebGPUSurface (windowHandle , width , height , scaleFactor );
93+ webgpu .initWebGPUSurface (windowHandle , displayHandle , width , height , scaleFactor );
9594 }
9695 }
9796
@@ -123,6 +122,24 @@ public long getWindowHandle() {
123122 return GLFWNativeCocoa .glfwGetCocoaWindow (window );
124123 } else if (Platform .get () == Platform .WINDOWS ) {
125124 return GLFWNativeWin32 .glfwGetWin32Window (window );
125+ } else if (Platform .get () == Platform .LINUX ) {
126+ // TODO: need to check if x11 or wayland
127+ return GLFWNativeWayland .glfwGetWaylandWindow (window );
128+ } else {
129+ throw new UnsupportedOperationException ("Window handle retrieval not implemented for this platform" );
130+ }
131+ }
132+
133+ public long getDisplayHandle () {
134+ if (Platform .get () == Platform .MACOSX ) {
135+ // TODO: Currently unsupported
136+ return 0 ;
137+ } else if (Platform .get () == Platform .WINDOWS ) {
138+ // TODO: Currently unsupported
139+ return 0 ;
140+ } else if (Platform .get () == Platform .LINUX ) {
141+ // TODO: need to check if x11 or wayland
142+ return GLFWNativeWayland .glfwGetWaylandDisplay ();
126143 } else {
127144 throw new UnsupportedOperationException ("Window handle retrieval not implemented for this platform" );
128145 }
0 commit comments