diff --git a/webfx-kit/webfx-kit-webgl-gwt/pom.xml b/webfx-kit/webfx-kit-webgl-gwt/pom.xml index ebe4fda92..041bb9fff 100644 --- a/webfx-kit/webfx-kit-webgl-gwt/pom.xml +++ b/webfx-kit/webfx-kit-webgl-gwt/pom.xml @@ -27,11 +27,6 @@ 0.1.0-SNAPSHOT - - com.google.elemental2 - elemental2-core - - com.google.elemental2 elemental2-dom @@ -66,6 +61,18 @@ 0.1.0-SNAPSHOT + + dev.webfx + webfx-platform-typedarray + 0.1.0-SNAPSHOT + + + + dev.webfx + webfx-platform-typedarray-gwt + 0.1.0-SNAPSHOT + + \ No newline at end of file diff --git a/webfx-kit/webfx-kit-webgl-gwt/src/main/java/dev/webfx/kit/webgl/spi/impl/gwt/GwtArrayBuffer.java b/webfx-kit/webfx-kit-webgl-gwt/src/main/java/dev/webfx/kit/webgl/spi/impl/gwt/GwtArrayBuffer.java deleted file mode 100644 index 31cb30105..000000000 --- a/webfx-kit/webfx-kit-webgl-gwt/src/main/java/dev/webfx/kit/webgl/spi/impl/gwt/GwtArrayBuffer.java +++ /dev/null @@ -1,23 +0,0 @@ -package dev.webfx.kit.webgl.spi.impl.gwt; - -import dev.webfx.kit.webgl.ArrayBuffer; -import elemental2.core.ArrayBufferView; - -/** - * @author Bruno Salmon - */ -public class GwtArrayBuffer implements ArrayBuffer { - - final elemental2.core.ArrayBuffer jsArrayBuffer; - final ArrayBufferView jsArrayBufferView; - - public GwtArrayBuffer(elemental2.core.ArrayBuffer jsArrayBuffer) { - this.jsArrayBuffer = jsArrayBuffer; - this.jsArrayBufferView = null; - } - - public GwtArrayBuffer(ArrayBufferView jsArrayBufferView) { - this.jsArrayBuffer = null; - this.jsArrayBufferView = jsArrayBufferView; - } -} diff --git a/webfx-kit/webfx-kit-webgl-gwt/src/main/java/dev/webfx/kit/webgl/spi/impl/gwt/GwtWebGLProvider.java b/webfx-kit/webfx-kit-webgl-gwt/src/main/java/dev/webfx/kit/webgl/spi/impl/gwt/GwtWebGLProvider.java index 918cddddb..804beaea0 100644 --- a/webfx-kit/webfx-kit-webgl-gwt/src/main/java/dev/webfx/kit/webgl/spi/impl/gwt/GwtWebGLProvider.java +++ b/webfx-kit/webfx-kit-webgl-gwt/src/main/java/dev/webfx/kit/webgl/spi/impl/gwt/GwtWebGLProvider.java @@ -2,11 +2,7 @@ import dev.webfx.kit.mapper.peers.javafxgraphics.NodePeer; import dev.webfx.kit.mapper.peers.javafxgraphics.gwt.html.HtmlCanvasPeer; -import dev.webfx.kit.webgl.ArrayBuffer; import dev.webfx.kit.webgl.spi.WebGLProvider; -import elemental2.core.Float32Array; -import elemental2.core.Uint16Array; -import elemental2.core.Uint8Array; import elemental2.dom.HTMLCanvasElement; import elemental2.webgl.WebGLRenderingContext; import javafx.scene.Node; @@ -68,7 +64,6 @@ public dev.webfx.kit.webgl.WebGLRenderingContext getContext(Node webglNode) { if (jsContext == null) return null; dev.webfx.kit.webgl.WebGLRenderingContext gln = new GwtWebGLRenderingContext(jsContext); - //gln = new WebGLRenderingContextLogger(gln); webglNode.getProperties().put("webglContext", gln); return gln; } @@ -84,19 +79,4 @@ private WebGLRenderingContext getWebGLRenderingContext(Canvas canvas) { return null; } - @Override - public ArrayBuffer createFloat32Array(double... array) { - Float32Array float32Array = Float32Array.from(array); - return new GwtArrayBuffer(float32Array); - } - - @Override - public ArrayBuffer createUint16Array(double... array) { - return new GwtArrayBuffer(new Uint16Array(array)); - } - - @Override - public ArrayBuffer Uint8Array(double... array) { - return new GwtArrayBuffer(new Uint8Array(array)); - } } diff --git a/webfx-kit/webfx-kit-webgl-gwt/src/main/java/dev/webfx/kit/webgl/spi/impl/gwt/GwtWebGLRenderingContext.java b/webfx-kit/webfx-kit-webgl-gwt/src/main/java/dev/webfx/kit/webgl/spi/impl/gwt/GwtWebGLRenderingContext.java index e5d8ab0c5..569164041 100644 --- a/webfx-kit/webfx-kit-webgl-gwt/src/main/java/dev/webfx/kit/webgl/spi/impl/gwt/GwtWebGLRenderingContext.java +++ b/webfx-kit/webfx-kit-webgl-gwt/src/main/java/dev/webfx/kit/webgl/spi/impl/gwt/GwtWebGLRenderingContext.java @@ -3,6 +3,8 @@ import dev.webfx.kit.mapper.peers.javafxgraphics.gwt.html.HtmlGraphicsContext; import dev.webfx.kit.mapper.peers.javafxmedia.spi.gwt.GwtMediaPlayerPeer; import dev.webfx.kit.webgl.*; +import dev.webfx.platform.typedarray.TypedArray; +import dev.webfx.platform.typedarray.spi.impl.gwt.GwtTypedArray; import elemental2.dom.HTMLImageElement; import elemental2.dom.HTMLVideoElement; import javafx.scene.image.Image; @@ -95,8 +97,8 @@ public void bindBuffer(int target, WebGLBuffer buffer) { } @Override - public void bufferData(int target, ArrayBuffer data, int usage) { - GwtArrayBuffer gwtArrayBuffer = (GwtArrayBuffer) data; + public void bufferData(int target, TypedArray data, int usage) { + GwtTypedArray gwtArrayBuffer = (GwtTypedArray) data; if (gwtArrayBuffer.jsArrayBuffer != null) gl.bufferData(target, gwtArrayBuffer.jsArrayBuffer, usage); else @@ -180,8 +182,8 @@ public void texImage2D(int target, int level, int internalformat, int format, in } @Override - public void texImage2D(int target, int level, int internalformat, int format, int type, int img, int format0, int type0, ArrayBuffer pixels) { - GwtArrayBuffer gwtArrayBuffer = (GwtArrayBuffer) pixels; + public void texImage2D(int target, int level, int internalformat, int format, int type, int img, int format0, int type0, TypedArray pixels) { + GwtTypedArray gwtArrayBuffer = (GwtTypedArray) pixels; gl.texImage2D(target, level, internalformat, format, type, img, format0, type0, gwtArrayBuffer.jsArrayBufferView); } diff --git a/webfx-kit/webfx-kit-webgl/pom.xml b/webfx-kit/webfx-kit-webgl/pom.xml index b62d3605b..27653e1a6 100644 --- a/webfx-kit/webfx-kit-webgl/pom.xml +++ b/webfx-kit/webfx-kit-webgl/pom.xml @@ -33,6 +33,12 @@ 0.1.0-SNAPSHOT + + dev.webfx + webfx-platform-typedarray + 0.1.0-SNAPSHOT + + dev.webfx webfx-platform-util diff --git a/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/ArrayBuffer.java b/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/ArrayBuffer.java deleted file mode 100644 index 7019c0386..000000000 --- a/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/ArrayBuffer.java +++ /dev/null @@ -1,7 +0,0 @@ -package dev.webfx.kit.webgl; - -/** - * @author Bruno Salmon - */ -public interface ArrayBuffer { -} diff --git a/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/WebGL.java b/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/WebGL.java index 2620aefab..2e087a5cd 100644 --- a/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/WebGL.java +++ b/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/WebGL.java @@ -1,7 +1,7 @@ package dev.webfx.kit.webgl; -import dev.webfx.platform.util.serviceloader.SingleServiceProvider; import dev.webfx.kit.webgl.spi.WebGLProvider; +import dev.webfx.platform.util.serviceloader.SingleServiceProvider; import javafx.scene.Node; import java.util.ServiceLoader; @@ -42,16 +42,4 @@ public static WebGLRenderingContext getContext(Node webglNode) { return getProvider().getContext(webglNode); } - public static ArrayBuffer createFloat32Array(double... array) { - return getProvider().createFloat32Array(array); - } - - public static ArrayBuffer createUint16Array(double... array) { - return getProvider().createUint16Array(array); - } - - public static ArrayBuffer createUint8Array(double... array) { - return getProvider().Uint8Array(array); - } - } diff --git a/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/WebGLRenderingContext.java b/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/WebGLRenderingContext.java index ddcb4bddc..892042d43 100644 --- a/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/WebGLRenderingContext.java +++ b/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/WebGLRenderingContext.java @@ -1,5 +1,6 @@ package dev.webfx.kit.webgl; +import dev.webfx.platform.typedarray.TypedArray; import javafx.scene.image.Image; /** @@ -327,7 +328,7 @@ public interface WebGLRenderingContext { void blendFuncSeparate(int srcRGB, int dstRGB, int srcAlpha, int dstAlpha); */ - void bufferData(int target, ArrayBuffer data, int usage); /*{ + void bufferData(int target, TypedArray data, int usage); /*{ bufferData( target, Js.uncheckedCast(data), usage); }*/ @@ -1026,7 +1027,7 @@ void texImage2D( int img, int format0, int type0, - ArrayBuffer pixels);/* { + TypedArray pixels);/* { texImage2D( target, level, diff --git a/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/spi/WebGLProvider.java b/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/spi/WebGLProvider.java index 4986d052a..46f2cbadc 100644 --- a/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/spi/WebGLProvider.java +++ b/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/spi/WebGLProvider.java @@ -1,6 +1,5 @@ package dev.webfx.kit.webgl.spi; -import dev.webfx.kit.webgl.ArrayBuffer; import dev.webfx.kit.webgl.WebGLRenderingContext; import javafx.scene.Node; @@ -21,10 +20,4 @@ public interface WebGLProvider { WebGLRenderingContext getContext(Node webglNode); - ArrayBuffer createFloat32Array(double... array); - - ArrayBuffer createUint16Array(double... array); - - ArrayBuffer Uint8Array(double... array); - } diff --git a/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/spi/impl/WebGLRenderingContextLogger.java b/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/spi/impl/WebGLRenderingContextLogger.java index 0a1f9c2ae..61630c8ca 100644 --- a/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/spi/impl/WebGLRenderingContextLogger.java +++ b/webfx-kit/webfx-kit-webgl/src/main/java/dev/webfx/kit/webgl/spi/impl/WebGLRenderingContextLogger.java @@ -1,6 +1,7 @@ package dev.webfx.kit.webgl.spi.impl; import dev.webfx.kit.webgl.*; +import dev.webfx.platform.typedarray.TypedArray; import javafx.scene.image.Image; import javafx.scene.media.MediaView; @@ -33,7 +34,7 @@ public void bindBuffer(int target, WebGLBuffer buffer) { } @Override - public void bufferData(int target, ArrayBuffer data, int usage) { + public void bufferData(int target, TypedArray data, int usage) { log("bufferData(target = " + target +", data = " + data + ", usage = " + usage + ")"); gl.bufferData(target, data, usage); } @@ -215,7 +216,7 @@ public void texImage2D(int target, int level, int internalformat, int format, in } @Override - public void texImage2D(int target, int level, int internalformat, int format, int type, int img, int format0, int type0, ArrayBuffer pixels) { + public void texImage2D(int target, int level, int internalformat, int format, int type, int img, int format0, int type0, TypedArray pixels) { gl.texImage2D(target, level, internalformat, format, type, img, format0, type0, pixels); } diff --git a/webfx-kit/webfx-kit-webgl/src/main/java/module-info.java b/webfx-kit/webfx-kit-webgl/src/main/java/module-info.java index ccd3dc597..6dbb706d5 100644 --- a/webfx-kit/webfx-kit-webgl/src/main/java/module-info.java +++ b/webfx-kit/webfx-kit-webgl/src/main/java/module-info.java @@ -7,6 +7,7 @@ requires javafx.graphics; requires javafx.media; requires webfx.platform.console; + requires webfx.platform.typedarray; requires webfx.platform.util; // Exported packages