Replaces `ctx2d.putImageData` with a WebGL2 texture quad in both 117HD and SD modes, aligns the TeaVM game loop with `requestAnimationFrame`, and adds PWA manifest and Service Worker asset caching for mobile/iOS Safari. ### WebGL2 Compositing & SD/HD Rendering - `WebHd117Renderer.java`, `WebGL2.java`: - Decoupled `ensureOverlayContext()` / `ensureOverlayReady()` so the WebGL2 2D overlay quad initializes without compiling 3D shadow/scene shaders when 117HD is off. - Added `drawHudPixels` and `drawHudCanvas` compositing onto `#gl-canvas` with `useBlend` control (disabling `GL_BLEND` for opaque SD frames). - `RSImageProducer.java`, `DesktopHooks.java`: - Routed `RSImageProducer.drawGraphics` and modern HUD draws (`drawModernMinimap`, `drawModernChat`, `drawModernTab`) through the WebGL2 quad whenever `ensureOverlayReady()` succeeds, clearing `#game-canvas` once to avoid `putImageData` overhead. ### Frame Pacing & Mobile PWA - `RSApplet.java`: - Added TeaVM `@Async` `awaitAnimationFrame()` backed by `window.requestAnimationFrame` for `delay <= 16` and capped catch-up ticks per frame (`loopTicks >= 2`). - `index.html`, `manifest.webmanifest`, `sw.js`: - Added Apple Web App meta tags, `manifest.webmanifest`, and `sw.js` Service Worker registration with shell precaching, network-first navigation, and stale-while-revalidate static asset caching.
134 lines
5.2 KiB
Java
134 lines
5.2 KiB
Java
package org.scape2006.web;
|
|
|
|
import org.teavm.jso.JSBody;
|
|
import org.teavm.jso.JSObject;
|
|
import org.teavm.jso.dom.html.HTMLCanvasElement;
|
|
import org.teavm.jso.typedarrays.Float32Array;
|
|
import org.teavm.jso.typedarrays.Uint8Array;
|
|
|
|
/**
|
|
* TeaVM JSO bindings for WebGL 2.0 (OpenGL ES 3.0) used by WebHd117Renderer.
|
|
*/
|
|
public interface WebGL2 extends JSObject {
|
|
|
|
int COLOR_BUFFER_BIT = 0x00004000;
|
|
int DEPTH_BUFFER_BIT = 0x00000100;
|
|
int TRIANGLES = 0x0004;
|
|
int TRIANGLE_STRIP = 0x0005;
|
|
int LEQUAL = 0x0203;
|
|
int ONE = 1;
|
|
int SRC_ALPHA = 0x0302;
|
|
int ONE_MINUS_SRC_ALPHA = 0x0303;
|
|
int DEPTH_TEST = 0x0B71;
|
|
int BLEND = 0x0BE2;
|
|
int POLYGON_OFFSET_FILL = 0x8037;
|
|
int FLOAT = 0x1406;
|
|
int UNSIGNED_BYTE = 0x1401;
|
|
int UNSIGNED_INT = 0x1405;
|
|
int RGBA = 0x1908;
|
|
int RGBA8 = 0x8058;
|
|
int DEPTH_COMPONENT = 0x1902;
|
|
int DEPTH_COMPONENT24 = 0x81A6;
|
|
int TEXTURE_2D = 0x0DE1;
|
|
int TEXTURE_2D_ARRAY = 0x8C1A;
|
|
int TEXTURE0 = 0x84C0;
|
|
int TEXTURE1 = 0x84C1;
|
|
int TEXTURE2 = 0x84C2;
|
|
int TEXTURE_MIN_FILTER = 0x2801;
|
|
int TEXTURE_MAG_FILTER = 0x2800;
|
|
int TEXTURE_WRAP_S = 0x2802;
|
|
int TEXTURE_WRAP_T = 0x2803;
|
|
int NEAREST = 0x2600;
|
|
int LINEAR = 0x2601;
|
|
int LINEAR_MIPMAP_LINEAR = 0x2703;
|
|
int REPEAT = 0x2901;
|
|
int CLAMP_TO_EDGE = 0x812F;
|
|
int ARRAY_BUFFER = 0x8892;
|
|
int STATIC_DRAW = 0x88E4;
|
|
int STREAM_DRAW = 0x88E0;
|
|
int FRAMEBUFFER = 0x8D40;
|
|
int RENDERBUFFER = 0x8D41;
|
|
int COLOR_ATTACHMENT0 = 0x8CE0;
|
|
int DEPTH_ATTACHMENT = 0x8D00;
|
|
int NONE = 0;
|
|
int VERTEX_SHADER = 0x8B31;
|
|
int FRAGMENT_SHADER = 0x8B30;
|
|
int COMPILE_STATUS = 0x8B81;
|
|
int LINK_STATUS = 0x8B82;
|
|
|
|
interface Buffer extends JSObject {}
|
|
interface Framebuffer extends JSObject {}
|
|
interface Renderbuffer extends JSObject {}
|
|
interface Program extends JSObject {}
|
|
interface Shader extends JSObject {}
|
|
interface Texture extends JSObject {}
|
|
interface UniformLocation extends JSObject {}
|
|
|
|
@JSBody(params = {"canvas"}, script =
|
|
"return canvas.getContext('webgl2', { alpha: false, antialias: false, preserveDrawingBuffer: false, powerPreference: 'high-performance', desynchronized: true });")
|
|
static WebGL2 getContext(HTMLCanvasElement canvas) {
|
|
return null;
|
|
}
|
|
|
|
void viewport(int x, int y, int width, int height);
|
|
void clearColor(float r, float g, float b, float a);
|
|
void clear(int mask);
|
|
void enable(int cap);
|
|
void disable(int cap);
|
|
void depthFunc(int func);
|
|
void depthMask(boolean flag);
|
|
void blendFunc(int sfactor, int dfactor);
|
|
void polygonOffset(float factor, float units);
|
|
|
|
Shader createShader(int type);
|
|
void shaderSource(Shader shader, String source);
|
|
void compileShader(Shader shader);
|
|
boolean getShaderParameter(Shader shader, int pname);
|
|
String getShaderInfoLog(Shader shader);
|
|
void deleteShader(Shader shader);
|
|
|
|
Program createProgram();
|
|
void attachShader(Program program, Shader shader);
|
|
void linkProgram(Program program);
|
|
boolean getProgramParameter(Program program, int pname);
|
|
String getProgramInfoLog(Program program);
|
|
void useProgram(Program program);
|
|
|
|
UniformLocation getUniformLocation(Program program, String name);
|
|
void uniform1i(UniformLocation loc, int v);
|
|
void uniform1f(UniformLocation loc, float v);
|
|
void uniform3f(UniformLocation loc, float x, float y, float z);
|
|
void uniform4fv(UniformLocation loc, Float32Array v);
|
|
void uniformMatrix4fv(UniformLocation loc, boolean transpose, Float32Array value);
|
|
|
|
Buffer createBuffer();
|
|
void bindBuffer(int target, Buffer buffer);
|
|
void bufferData(int target, int size, int usage);
|
|
void bufferData(int target, Float32Array data, int usage);
|
|
void bufferSubData(int target, int offset, Float32Array data);
|
|
void enableVertexAttribArray(int index);
|
|
void disableVertexAttribArray(int index);
|
|
void vertexAttribPointer(int index, int size, int type, boolean normalized, int stride, int offset);
|
|
void drawArrays(int mode, int first, int count);
|
|
|
|
Texture createTexture();
|
|
void activeTexture(int texture);
|
|
void bindTexture(int target, Texture texture);
|
|
void texParameteri(int target, int pname, int param);
|
|
void texImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, Uint8Array pixels);
|
|
void texImage2D(int target, int level, int internalformat, int format, int type, HTMLCanvasElement canvas);
|
|
void texImage3D(int target, int level, int internalformat, int width, int height, int depth, int border, int format, int type, Uint8Array pixels);
|
|
void generateMipmap(int target);
|
|
|
|
Framebuffer createFramebuffer();
|
|
void bindFramebuffer(int target, Framebuffer fb);
|
|
void framebufferTexture2D(int target, int attachment, int textarget, Texture texture, int level);
|
|
Renderbuffer createRenderbuffer();
|
|
void bindRenderbuffer(int target, Renderbuffer rb);
|
|
void renderbufferStorage(int target, int internalformat, int width, int height);
|
|
void framebufferRenderbuffer(int target, int attachment, int renderbuffertarget, Renderbuffer rb);
|
|
void drawBuffers(int[] buffers);
|
|
|
|
void readPixels(int x, int y, int width, int height, int format, int type, Uint8Array pixels);
|
|
}
|