Skip to content

feat(utilities): forward render context options through createGame - #692

Merged
stormmuller merged 3 commits into
devfrom
claude/amazing-gauss-x2q1rr
Oct 3, 2026
Merged

stormmuller merged 3 commits into
devfrom
claude/amazing-gauss-x2q1rr

Conversation

@stormmuller

Copy link
Copy Markdown
Member

Summary

createGame built its render context with createRenderContext(canvas) and took no options. A game set up with createGame therefore always rendered at the display's full devicePixelRatio and couldn't set maxPixelRatio. On a 2× display, that means every full-screen pass covers 4× the pixels.

This PR adds an optional second argument to createGame, typed as the new exported CreateGameOptions. Its renderContext field is forwarded unchanged to createRenderContext:

const { renderContext } = createGame('game', {
  renderContext: { maxPixelRatio: 1.5 },
});

Existing calls with one argument behave exactly as before; the render context gets {}, so all defaults are kept. Defaults follow the repo's default…Options convention.

  • src/utilities/create-game.ts: new CreateGameOptions interface and options parameter, forwarded to createRenderContext
  • src/utilities/create-game.test.ts: tests for the default (no options) and the forwarded options
  • Docs: ecs/game.md shows the new argument, and the high-DPI section of rendering/world-units-and-cameras.md shows how to cap the pixel ratio through createGame
  • CHANGELOG.md: an Added entry under [Unreleased]

Related issue(s)

Fixes defect report 009: "createGame can't pass RenderContextOptions, so a game can't cap its render resolution".

Verification checklist

  • npm run check-types passes with 0 errors
  • npm test passes (226 files, 1733 tests)
  • npm run lint passes with 0 errors (2 existing TODO warnings in material.ts)
  • npm run cspell passes with 0 errors
  • npm run check-exports passes
  • Any new/changed public API is exported from the module's index.ts (CreateGameOptions is exported via the existing export * from './create-game.js')
  • Documentation under /documentation-site/docs/docs is updated
  • Demos that use createGame: no code changes needed, since the change is backward compatible. Ran npm run build, then the docs-site typecheck and build, and loaded the particles, ecs and text demos in Chromium. All three rendered. The only console errors were external resources that the sandbox's proxy blocked.

Changelog

  • A bullet has been added under ## [Unreleased] in CHANGELOG.md

🤖 Generated with Claude Code

https://claude.ai/code/session_012jXdrrhDQTunF1wimhhC5t


Generated by Claude Code

createGame now takes an optional options object whose renderContext field
is passed to createRenderContext, so games built on createGame can set
maxPixelRatio (and the other RenderContextOptions).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012jXdrrhDQTunF1wimhhC5t
@codecov

codecov Bot commented Oct 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@stormmuller
stormmuller enabled auto-merge (squash) October 3, 2026 10:08
@stormmuller
stormmuller merged commit 3c000a1 into dev Oct 3, 2026
12 checks passed
@stormmuller
stormmuller deleted the claude/amazing-gauss-x2q1rr branch October 3, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants