Commit Graph
5 Commits
Author SHA1 Message Date
Dark98 02c3d8fb10 feat(web-audio): implement Class56 MIDI player with FluidSynth and TimGM6mb.sf2
Enables authentic General MIDI music playback in `2006Scape-Web` over both HTTP and HTTPS by implementing the missing `Class56_Sub1_Sub1` web adapter and wiring `js-synthesizer` (`libfluidsynth-2.3.0.js`) with the `TimGM6mb.sf2` SoundFont.

### Java MIDI Pipeline Bridge
- `Class56_Sub1_Sub1.java`:
  - Added `org.scape2006.web` implementation of `Class56` forwarding `method827`, `method828`, `method830`, `method831`, `method832`, and `method833` to `DesktopHooks.playMidiBytes`, `setSignlinkVolume`, and `stopSignlinkMidi`.
- `build.gradle`:
  - Patched `Game.constructMusic()` in `syncSharedSources` to instantiate `new Class56_Sub1_Sub1()` directly instead of `Class.forName("Class56_Sub1_Sub1").newInstance()`, preventing `musicIsntNull()` from returning `false`.

### FluidSynth Web Audio & Caching
- `src/main/webapp/libfluidsynth-2.3.0.js`, `js-synthesizer.min.js`, `TimGM6mb.sf2`:
  - Bundled FluidSynth WASM/JS synthesizer and General MIDI SoundFont (`5.8M`) locally for offline and plain-HTTP LAN compatibility.
- `src/main/webapp/index.html`:
  - Wired `window.scapeWebAudio` (`ensureFluidSynth`, `playMidi`, `setMidiVolume`, `stopMidi`) to load `TimGM6mb.sf2`, loop tracks via `setPlayerLoop(-1)`, and resume pending MIDI on first user gesture.
- `src/main/webapp/sw.js`:
  - Added `libfluidsynth-2.3.0.js`, `js-synthesizer.min.js`, and `TimGM6mb.sf2` to `SHELL_ASSETS` and bumped `CACHE_VERSION` to `2006scape-web-v5`.
2026-12-01 14:53:04 +00:00
Dark98 4bcb91c3a2 fix(web): fix Android Chrome black screen and Fixed-mode WebGL2 viewport scissor
Resolves the Android Chrome black screen after closing the welcome back interface and prevents Fixed-mode 317HD `gl.clear` from wiping surrounding HUD/border regions.

### WebGL2 Context & Fixed-Mode Scissoring
- `WebGL2.java`:
  - Enabled `preserveDrawingBuffer: true` and removed `desynchronized: true` on the `#gl-canvas` WebGL2 context to prevent Android Chrome from clearing or failing to composite between frames.
  - Added `SCISSOR_TEST` (`0x0C11`) and `scissor(x, y, width, height)` bindings.
- `WebHd317Renderer.java`:
  - Wrapped Pass 2 (`gl.clear` and 3D scene draw) in `GL_SCISSOR_TEST` (`gl.scissor(vpX, vpY, width, height)`) so Fixed-mode stone borders, chatbox, and tab areas are preserved.
  - Reused `HD317Pipeline.backend` in `ensureOverlayReady()` to avoid creating duplicate `WebHd317Renderer` instances.
- `RSImageProducer.java`:
  - Removed `desynchronized: true` from `#game-canvas`'s 2D context so Android Chrome composites `#game-canvas` transparently over `#gl-canvas`.

### Service Worker Caching
- `src/main/webapp/sw.js`:
  - Bumped `CACHE_VERSION` to `2006scape-web-v3` and switched `js/client.js` to network-first (with cache fallback) so client updates take effect immediately when online.
2026-11-30 22:41:05 +00:00
Dark98 ededb882a0 refactor(web): rename 117HD WebGL2 renderer and UI references to 317HD
Renames `WebHd117Renderer` and all remaining `117HD` symbols, build exclusions, and UI labels in `2006Scape-Web` to `317HD`.

### WebGL2 Renderer & Build
- `WebHd317Renderer.java`:
  - Renamed from `WebHd117Renderer.java` and updated class/log references to `WebHd317Renderer` / `317HD`.
- `build.gradle`, `WebLauncher.java`, `RSImageProducer.java`, `DesktopHooks.java`, `WebGL2.java`:
  - Updated `DesktopHd117Renderer.java` exclusion to `DesktopHd317Renderer.java` and updated pipeline/renderer call sites to `HD317Pipeline` and `WebHd317Renderer`.
- `src/main/webapp/index.html`:
  - Updated UI label from `117HD (WebGL2)` to `317HD (WebGL2)`.
2026-11-30 21:57:21 +00:00
Dark98 33235cec55 perf(web): eliminate putImageData via WebGL2 quad, sync frame pacing, and add PWA/Service Worker
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.
2026-11-30 21:54:39 +00:00
Dark98 3331ab745b feat(web): add 2006Scape TeaVM WebGL2 client with mobile support and classic 2006 UI
Initializes the TeaVM-based 2006Scape-Web client repository with WebGL2 117HD rendering, WebSocket networking, SpessaSynth MIDI/PCM audio, and mobile-compatible touch/viewport controls. Preserves Revision 377 cache preloading via IndexedDB and localStorage-backed script and config persistence.

### Core Web Runtime & Rendering
- WebLauncher & DesktopHooks:
  - Added TeaVM entry point with URL/localStorage option parsing, async 377 cache preloading, and WebSocket port routing.
  - Implemented DesktopHooks.boxReflectValue using JSWrapper.isJava/maybeUnwrap to box TeaVM reflection primitives, plus localStorage persistence for plugin settings and imported scripts.
- WebHd117Renderer & RSImageProducer:
  - Implemented WebGL2 117HD rendering with 4x4 chunked static scenery VBOs and 0x010203 transparency sentinel so 0x000000 black UI elements stay opaque.
- WebReflectionSupplier:
  - Exposed PluginContext, PluginGraphics, ScriptInterpreter, ID lists, and Math/System/String/collection methods for TeaVM runtime reflection.

### Mobile & Classic 2006 Web UI
- index.html & RSApplet:
  - Styled the page to match the classic 2006 RuneScape webclient with optional classic navbar (auto-hidden below 765px), 1999-2006 Jagex footer, and responsive Fixed/Resizable/Fullscreen scaling.
  - Added Options modal (auto-login, server, world, 117HD, display mode, navbar) with scrollable body in mobile landscape.
  - Implemented Android-parity touch controls (tap, 450ms long-press right-click, 1-finger camera drag, 2-finger pinch zoom clamped to -1..8, and auto-keyboard on input fields).
2026-11-30 20:45:03 +00:00