Settings: say whether the card can draw the map without setting it up

Settings › Map drawing said "This browser cannot" by calling glInit(), so opening Settings on the title screen or in a
puzzle, where the map is drawn in 2D, made the WebGL context and its 64 MB atlas. It now says what is known without
asking the card (glCan()): a card given up or a browser without WebGL2 cannot; a card not tried yet counts as able.
A card that turns out to be the processor's is still named once the game draws its first frame, in Diagnostic info
and in Settings. Test in webgl-context-restore.
This commit is contained in:
Antoine 2026-11-05 00:05:11 +01:00
parent 351b3aa522
commit b7a9ec3e3c
No known key found for this signature in database
GPG key ID: 728FF1CE15732B05
3 changed files with 22 additions and 1 deletions

View file

@ -143,3 +143,21 @@ test('a game started with Always 2D never makes a context', () => {
assert.equal(ev('__made'), 0);
assert.deepEqual(errors, []);
});
// Settings said whether the card could draw the map by setting it up: opening them on the title screen or in a puzzle
// made the context and its 64 MB atlas for a map drawn in 2D. It now says what is known without asking the card.
test('opening Settings never makes a context, and still says when the card cannot', () => {
const { ev, errors } = open();
ev('window.WebGL2RenderingContext=function(){};window.__made=0;const c=document.getElementById("mapgl"),gc=c.getContext;c.getContext=t=>{__made++;return gc(t);};');
const note = () => ev("settingsHtml().includes(tr('settings.this_browser_cannot_so_the_map'))");
ev('const s=S;S=null;window.__S=s;');
assert.equal(note(), false, 'title screen: a card not tried yet counts as able');
ev('S=__S;');
assert.equal(note(), false);
assert.equal(ev('__made'), 0, 'no context made by Settings');
ev('glKill(new Error("no graphics card, only SwiftShader"))');
assert.equal(note(), true, 'a card given up: Settings says so');
ev('delete window.WebGL2RenderingContext;GLX.dead=false;');
assert.equal(note(), true, 'no WebGL2 in this browser: Settings says so');
assert.deepEqual(errors, []);
});