-
-
Notifications
You must be signed in to change notification settings - Fork 106
wayland support #1337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
wayland support #1337
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c39fb34
Implement basic rendering flow
tychedelia c198e16
Fix naming.
tychedelia 42a1928
Actually fix rename.
tychedelia 1fbaaea
Add `display_handle` argument to create_surface
catilac 7286377
Add support for wayland wm
catilac 6dbbfde
Update PWebGPU to pass a display handle
catilac f84f52e
Pass display pointer in wayland
catilac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import processing.core.PApplet; | ||
|
|
||
| public class WebGPU extends PApplet { | ||
| public void settings() { | ||
| size(600, 400, WEBGPU); | ||
| } | ||
|
|
||
| public void draw() { | ||
| background(200); | ||
|
|
||
| noStroke(); | ||
| fill(255, 0, 0); | ||
| rect(50, 50, 80, 80); | ||
|
|
||
| fill(0, 255, 0); | ||
| rect(150, 50, 80, 80); | ||
|
|
||
| fill(0, 0, 255); | ||
| rect(250, 50, 80, 80); | ||
|
|
||
| fill(255, 0, 0, 128); | ||
| rect(50, 150, 80, 80); | ||
|
|
||
| fill(0, 255, 0, 128); | ||
| rect(150, 150, 80, 80); | ||
|
|
||
| fill(0, 0, 255, 128); | ||
| rect(250, 150, 80, 80); | ||
|
|
||
| stroke(0); | ||
| strokeWeight(4); | ||
| fill(255, 200, 0); | ||
| rect(50, 250, 80, 80); | ||
|
|
||
| fill(200, 0, 255); | ||
| rect(150, 250, 80, 80); | ||
|
|
||
| noFill(); | ||
| stroke(255, 0, 255); | ||
| strokeWeight(6); | ||
| rect(250, 250, 80, 80); | ||
|
|
||
| noStroke(); | ||
| fill(255, 0, 0, 100); | ||
| rect(400, 100, 100, 100); | ||
|
|
||
| fill(0, 255, 0, 100); | ||
| rect(440, 140, 100, 100); | ||
|
|
||
| fill(0, 0, 255, 100); | ||
| rect(420, 180, 100, 100); | ||
| } | ||
|
|
||
| public static void main(String[] args) { | ||
| PApplet.disableAWT = true; | ||
| PApplet.main(WebGPU.class.getName()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,6 @@ | ||
| package processing.webgpu; | ||
|
|
||
| import org.lwjgl.glfw.GLFW; | ||
| import org.lwjgl.glfw.GLFWErrorCallback; | ||
| import org.lwjgl.glfw.GLFWFramebufferSizeCallback; | ||
| import org.lwjgl.glfw.GLFWNativeCocoa; | ||
| import org.lwjgl.glfw.GLFWNativeWin32; | ||
| import org.lwjgl.glfw.GLFWWindowPosCallback; | ||
| import org.lwjgl.glfw.*; | ||
| import org.lwjgl.system.MemoryUtil; | ||
| import org.lwjgl.system.Platform; | ||
|
|
||
|
|
@@ -30,6 +25,7 @@ public class PSurfaceGLFW implements PSurface { | |
| protected PGraphics graphics; | ||
|
|
||
| protected long window; | ||
| protected long display; | ||
| protected boolean running = false; | ||
|
|
||
| protected boolean paused; | ||
|
|
@@ -78,6 +74,8 @@ public void initFrame(PApplet sketch) { | |
| throw new RuntimeException("Failed to create GLFW window"); | ||
| } | ||
|
|
||
| display = GLFW.glfwGetPrimaryMonitor(); | ||
|
|
||
| windowCount.incrementAndGet(); | ||
|
|
||
| // event callbacks | ||
|
|
@@ -87,11 +85,12 @@ public void initFrame(PApplet sketch) { | |
| PWebGPU.init(); | ||
|
|
||
| long windowHandle = getWindowHandle(); | ||
| long displayHandle = getDisplayHandle(); | ||
| int width = sketch.sketchWidth(); | ||
| int height = sketch.sketchHeight(); | ||
| float scaleFactor = sketch.sketchPixelDensity(); | ||
|
|
||
| webgpu.initWebGPUSurface(windowHandle, width, height, scaleFactor); | ||
| webgpu.initWebGPUSurface(windowHandle, displayHandle, width, height, scaleFactor); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -123,6 +122,24 @@ public long getWindowHandle() { | |
| return GLFWNativeCocoa.glfwGetCocoaWindow(window); | ||
| } else if (Platform.get() == Platform.WINDOWS) { | ||
| return GLFWNativeWin32.glfwGetWin32Window(window); | ||
| } else if (Platform.get() == Platform.LINUX) { | ||
| // TODO: need to check if x11 or wayland | ||
| return GLFWNativeWayland.glfwGetWaylandWindow(window); | ||
| } else { | ||
| throw new UnsupportedOperationException("Window handle retrieval not implemented for this platform"); | ||
| } | ||
| } | ||
|
|
||
| public long getDisplayHandle() { | ||
| if (Platform.get() == Platform.MACOSX) { | ||
| // TODO: Currently unsupported | ||
| return 0; | ||
| } else if (Platform.get() == Platform.WINDOWS) { | ||
| // TODO: Currently unsupported | ||
| return 0; | ||
| } else if (Platform.get() == Platform.LINUX) { | ||
| // TODO: need to check if x11 or wayland | ||
| return GLFWNativeWayland.glfwGetWaylandDisplay(); | ||
|
Comment on lines
+141
to
+142
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think i'll add x11 to this if we can test in the short term. otherwise it could go in another PR. |
||
| } else { | ||
| throw new UnsupportedOperationException("Window handle retrieval not implemented for this platform"); | ||
| } | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wasn't sure what to do here since we don't use display handle on MacOS and windows yet.