22
33import processing .core .NativeLibrary ;
44
5+ import java .lang .foreign .Arena ;
56import java .lang .foreign .MemorySegment ;
67
78import static java .lang .foreign .MemorySegment .NULL ;
89import static processing .ffi .processing_h .*;
10+ import processing .ffi .Color ;
911
1012/**
1113 * PWebGPU provides the native interface layer for libProcessing's WebGPU support.
@@ -47,6 +49,16 @@ public static long createSurface(long windowHandle, int width, int height, float
4749 return windowId ;
4850 }
4951
52+ /**
53+ * Destroys a WebGPU surface.
54+ *
55+ * @param windowId The window ID returned from createSurface
56+ */
57+ public static void destroySurface (long windowId ) {
58+ processing_destroy_surface (windowId );
59+ checkError ();
60+ }
61+
5062 /**
5163 * Updates a window's size.
5264 *
@@ -55,7 +67,7 @@ public static long createSurface(long windowHandle, int width, int height, float
5567 * @param height New physical window height in pixels
5668 */
5769 public static void windowResized (long windowId , int width , int height ) {
58- processing_window_resized (windowId , width , height );
70+ processing_resize_surface (windowId , width , height );
5971 checkError ();
6072 }
6173
@@ -75,6 +87,20 @@ public static void exit() {
7587 checkError ();
7688 }
7789
90+ public static void backgroundColor (long windowId , float r , float g , float b , float a ) {
91+ try (Arena arena = Arena .ofConfined ()) {
92+ MemorySegment color = Color .allocate (arena );
93+
94+ Color .r (color , r );
95+ Color .g (color , g );
96+ Color .b (color , b );
97+ Color .a (color , a );
98+
99+ processing_background_color (windowId , color );
100+ checkError ();
101+ }
102+ }
103+
78104 /**
79105 * Checks for errors from the native library and throws a PWebGPUException if an error occurred.
80106 */
0 commit comments