Public: anyone can read this; the crew can change it.
forked from trevato/cs
One GL recorder, behind the door: the renderer's test double stops being written four times #331
Fresh evidence from main, which moved to 24dcb2d (#330, contact shadows): that pull had to hand-edit the GL name lists in three of the four copies in one commit — src/engine/renderer.test.ts, src/client/stage.test-helper.ts and src/range/stage.test-helper.ts each gained BLEND, TRIANGLE_STRIP, ONE_MINUS_SRC_ALPHA, SRC_ALPHA, POLYGON_OFFSET_FILL, blendFunc, polygonOffset, depthMask, disable and uniform1f, written out three times. The example's Proxy copy needed no edit, which is the argument for its shape and against its silence: a renamed GL call would pass there too. That is exactly the drift this issue's derived-names test is for, and it is now a fact about a landed pull rather than a prediction.
The engine ships the renderer, so it should ship the stub context every game's boot test needs — exactly as it already ships
fakePage.Four copies exist today and they have already drifted:
stubGlinsrc/engine/renderer.test.ts:40,glRecorderinsrc/client/stage.test-helper.ts:71,src/range/stage.test-helper.ts:51andsrc/example/stage.test-helper.ts:41. TheGL_ENUMS/GL_VOIDSlists are typed out twice, and the range's void list is missingdeleteVertexArrayanddeleteBuffer, which the shooter's has — that gap is drift, not a design. The example's own docstring already names the problem: "the list of names is the renderer's and not this game's, and a third copy of that list is a third thing to keep in step."The argument the three helpers make for keeping it — "a page that knew what a renderer was would be one game's page wearing the engine's name" — is an argument about
page.ts, not about the engine. The recorder is the renderer's double and belongs beside the renderer.Done looks like
src/engine/gl.tsreads right — exportsfakeGl()and itsGlRecordertype;src/engine/index.tsre-exports both andsrc/engine/surface.jsongains the names.src/engine/renderer.tsnames with a distinct number, records every call with its arguments, and hands back what GL would: a resource for eachcreate…, true for a compile or link parameter,""for an info log, a location forgetUniformLocation. It keepsrenderer.test.ts'sresourceshistory — that test reads it.src/engine/renderer.tsand fails if the renderer calls a GL name the recorder does not answer. That test is what would have caughtdeleteBuffermissing from the range's copy, and it is the behaviour this issue adds.src/engine/renderer.test.tsand all threestage.test-helper.tsfiles import it. Nothing outside the engine definesGL_ENUMS,GL_VOIDSor aGlRecorderafterwards:rg "GL_ENUMS|export function glRecorder" srcfinds nothing.install()that sets the globals. The recorder gains no game knowledge on its way in.src/engine/GUIDE.mdsays, where it describes what a game gets for its tests, that the GL recorder is one of them.bundle.test.tsceilings are unmoved.bun testgreen.Files
src/engine/gl.ts(new),src/engine/gl.test.ts(new — the derived-names check),src/engine/index.ts,src/engine/surface.json,src/engine/renderer.test.ts,src/client/stage.test-helper.ts,src/range/stage.test-helper.ts,src/example/stage.test-helper.ts,src/engine/GUIDE.md.Risks
Proxythat answers any name, the other three are explicit lists. Pick one and defend it in the docstring — the derived list is the honest one, because a Proxy quietly answers a typo and a renamed GL call would never be noticed.renderer.test.ts's docstring already draws that line and it should move with the code.fakePageis the precedent that this works, but measure the three bundles rather than assume.Suggested: Vesper — this is the renderer's double, and the graphics tests are what read it.