Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(text): SDF text now renders end-to-end — bind atlas by GL id (REARCH_GUI P1.3 pixel-verified)

esengineceeaa118c807
diff --git a/desktop/scripts/headless-verify.mjs b/desktop/scripts/headless-verify.mjs
index 29aa39a48..c753e95c8 100644
--- a/desktop/scripts/headless-verify.mjs
+++ b/desktop/scripts/headless-verify.mjs
@@ -18,7 +18,7 @@
*/
import { app, BrowserWindow } from 'electron';
import http from 'node:http';
-import { readFile } from 'node:fs/promises';
+import { readFile, writeFile } from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
@@ -108,6 +108,20 @@ app.whenReady().then(async () => {
return { w: c.width, h: c.height, totalPixels: px.length / 4, nonZeroPixels: nonZero, min, max, spread, rendered: spread > 16 };
})()`);
const drawCalls = await exec('window.__estellaHeadless.api.getStats().drawCalls');
+ // Optional PNG dump (ESTELLA_VERIFY_OUT) of the engine framebuffer (not the
+ // page) so the rendered frame can be eyeballed. GL readback is bottom-up → flip.
+ if (process.env.ESTELLA_VERIFY_OUT) {
+ const dataUrl = await exec(`(() => {
+ const c = window.__estellaHeadless.api.captureViewport();
+ const cv = document.createElement('canvas'); cv.width = c.width; cv.height = c.height;
+ const ctx = cv.getContext('2d'); const img = ctx.createImageData(c.width, c.height);
+ const w = c.width, h = c.height, src = c.rgba;
+ for (let y = 0; y < h; y++) { const sy = (h - 1 - y) * w * 4; img.data.set(src.subarray(sy, sy + w * 4), y * w * 4); }
+ ctx.putImageData(img, 0, 0);
+ return cv.toDataURL('image/png');
+ })()`);
+ await writeFile(process.env.ESTELLA_VERIFY_OUT, Buffer.from(dataUrl.split(',')[1], 'base64'));
+ }
finish({ ok: true, entityCount, drawCalls, capture }, server);
} catch (e) {
finish({ ok: false, error: String((e && e.stack) || e) }, server);
diff --git a/sdk/src/ui/text/atlas-page-store.ts b/sdk/src/ui/text/atlas-page-store.ts
index d402f0594..d929fc3b2 100644
--- a/sdk/src/ui/text/atlas-page-store.ts
+++ b/sdk/src/ui/text/atlas-page-store.ts
@@ -7,24 +7,35 @@
*/
import type { ESEngineModule } from '../../wasm';
import { createTextureFromPixels, updateTextureSubregion } from '../../runtimeAssets';
+import { requireResourceManager } from '../../resourceManager';
import type { AtlasPageStore } from './glyph-atlas';
export class EngineAtlasPageStore implements AtlasPageStore {
+ // pageId is the GL texture id (what the batch binds); uploads need the engine
+ // handle, so keep the mapping.
+ private readonly handleByGlId = new Map<number, number>();
+
constructor(private readonly module: ESEngineModule) {}
createPage(size: number): number {
// Blank (transparent) RGBA8 page; linear filtering keeps SDF text smooth
// when scaled, clamp avoids edge bleed at the page border.
const pixels = new Uint8Array(size * size * 4);
- return createTextureFromPixels(
+ const handle = createTextureFromPixels(
this.module,
{ width: size, height: size, pixels },
/* flipY */ false,
{ filterMode: 'linear', wrapMode: 'clamp' },
);
+ // The batch binds by GL texture id (mirrors how spine resolves its atlas
+ // pages); submitTextBatch gets this id as the page id.
+ const glId = requireResourceManager().getTextureGLId(handle);
+ this.handleByGlId.set(glId, handle);
+ return glId;
}
uploadSubRegion(pageId: number, x: number, y: number, w: number, h: number, pixels: Uint8Array): void {
- updateTextureSubregion(this.module, pageId, x, y, w, h, pixels);
+ const handle = this.handleByGlId.get(pageId) ?? pageId;
+ updateTextureSubregion(this.module, handle, x, y, w, h, pixels);
}
}