diff --git a/Kha/Backends/HTML5/kha/SystemImpl.hx b/Kha/Backends/HTML5/kha/SystemImpl.hx
index 7feee51..f2a7f7c 100644
--- a/Kha/Backends/HTML5/kha/SystemImpl.hx
+++ b/Kha/Backends/HTML5/kha/SystemImpl.hx
@@ -227,7 +227,7 @@ class SystemImpl {
}
static inline var maxGamepads: Int = 4;
- static var frame: Framebuffer;
+ public static var frame: Framebuffer;
static var keyboard: Keyboard = null;
static var mouse: kha.input.Mouse;
static var surface: Surface;
@@ -388,7 +388,8 @@ class SystemImpl {
{
alpha: false,
antialias: options.framebuffer.samplesPerPixel > 1,
- stencil: true
+ stencil: true,
+ xrCompatible: true
}); // preserveDrawingBuffer: true } ); Warning: preserveDrawingBuffer can cause huge performance issues on mobile browsers
SystemImpl.gl.pixelStorei(GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
@@ -417,7 +418,8 @@ class SystemImpl {
{
alpha: false,
antialias: options.framebuffer.samplesPerPixel > 1,
- stencil: true
+ stencil: true,
+ xrCompatible: true
}); // preserveDrawingBuffer: true } ); WARNING: preserveDrawingBuffer causes huge performance issues (on mobile browser)!
SystemImpl.gl.pixelStorei(GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
SystemImpl.gl.getExtension("OES_texture_float");
@@ -547,6 +549,12 @@ class SystemImpl {
];
function animate(timestamp) {
+ if (untyped Browser.window._khaSkipWindowRender == true) {
+ if (requestAnimationFrame != null)
+ requestAnimationFrame(animate);
+ return;
+ }
+
if (requestAnimationFrame == null)
Browser.window.setTimeout(animate, 1000.0 / 60.0);
else
diff --git a/Kha/Backends/HTML5/kha/js/graphics4/Graphics.hx b/Kha/Backends/HTML5/kha/js/graphics4/Graphics.hx
index dcaf6f9..357ac5c 100644
--- a/Kha/Backends/HTML5/kha/js/graphics4/Graphics.hx
+++ b/Kha/Backends/HTML5/kha/js/graphics4/Graphics.hx
@@ -1,738 +1,741 @@
-package kha.js.graphics4;
-
-import js.html.webgl.GL2;
-import kha.graphics4.StencilValue;
-import kha.arrays.Float32Array;
-import kha.arrays.Int32Array;
-import js.html.webgl.GL;
-import kha.graphics4.BlendingFactor;
-import kha.graphics4.BlendingOperation;
-import kha.graphics4.CompareMode;
-import kha.graphics4.CubeMap;
-import kha.graphics4.CullMode;
-import kha.graphics4.IndexBuffer;
-import kha.graphics4.MipMapFilter;
-import kha.graphics4.PipelineState;
-import kha.graphics4.StencilAction;
-import kha.graphics4.TextureAddressing;
-import kha.graphics4.TextureFilter;
-import kha.graphics4.Usage;
-import kha.graphics4.VertexBuffer;
-import kha.graphics4.VertexStructure;
-import kha.Image;
-import kha.math.FastMatrix3;
-import kha.math.FastMatrix4;
-import kha.math.FastVector2;
-import kha.math.FastVector3;
-import kha.math.FastVector4;
-import kha.WebGLImage;
-
-class Graphics implements kha.graphics4.Graphics {
- var currentPipeline: PipelineState = null;
- var depthTest: Bool = false;
- var depthMask: Bool = false;
- var colorMaskRed: Bool = true;
- var colorMaskGreen: Bool = true;
- var colorMaskBlue: Bool = true;
- var colorMaskAlpha: Bool = true;
- var indicesCount: Int;
- var renderTarget: Canvas;
- var renderTargetFrameBuffer: Dynamic;
- var renderTargetMSAA: Dynamic;
- var renderTargetTexture: Dynamic;
- var isCubeMap: Bool = false;
- var isDepthAttachment: Bool = false;
- var instancedExtension: Dynamic;
- var blendMinMaxExtension: Dynamic;
-
- static var current: Graphics = null;
- static var useVertexAttributes: Int = 0;
-
- public function new(renderTarget: Canvas = null) {
- this.renderTarget = renderTarget;
- init();
- if (SystemImpl.gl2) {
- instancedExtension = true;
- }
- else {
- instancedExtension = SystemImpl.gl.getExtension("ANGLE_instanced_arrays");
- blendMinMaxExtension = SystemImpl.gl.getExtension("EXT_blend_minmax");
- }
- }
-
- function init() {
- if (renderTarget == null)
- return;
- isCubeMap = Std.isOfType(renderTarget, CubeMap);
- if (isCubeMap) {
- var cubeMap: CubeMap = cast(renderTarget, CubeMap);
- renderTargetFrameBuffer = cubeMap.frameBuffer;
- renderTargetTexture = cubeMap.texture;
- isDepthAttachment = cubeMap.isDepthAttachment;
- }
- else {
- var image: WebGLImage = cast(renderTarget, WebGLImage);
- renderTargetFrameBuffer = image.frameBuffer;
- renderTargetMSAA = image.MSAAFrameBuffer;
- renderTargetTexture = image.texture;
- }
- }
-
- public function begin(additionalRenderTargets: Array