stride3d / stride3d/stride

feat: Surface Monitor DPI Scaling in GraphicsOutput and Improve DPI Awareness

Open
#2,906 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C#
Stars
7.8k
Forks
1.2k
Avg merge
2d 17h
Merged PRs (30d)
49

Description

Is your feature request related to a problem? Please describe.
Font rendering becomes blurry or incorrectly scaled on high-DPI monitors when display scaling is above 100%. The issue is not with the font but with how DPI scaling is handled. As a workaround, manual hacks or Silk.NET APIs (such as GetMonitorContentScale) can be used, but this is not ideal.

Describe the solution you'd like
Expose monitor DPI scaling information (e.g., using GetMonitorContentScale from Silk.NET, SDL API, Windows DXGI, or platform equivalents) probably from GraphicsOutput. This would allow consumers (toolkits, samples, games) to adjust font and UI rendering appropriately for different DPI settings. Ideally, the engine could also detect when the window moves between screens and update scaling automatically. DPI awareness should be opt-in at first, surfacing the information and allowing users to handle it as needed, with further engine support potentially added later.

Describe alternatives you've considered

  • Manual hacks to resize window and font for sharpness
  • Using Silk.NET or platform APIs directly in user code
  • Relying on game/system DPI settings without explicit detection

Additional context

  • Silk.NET exposes monitor scaling through GetMonitorContentScale
  • DXGI (Windows), SDL (cross-platform), and other APIs provide similar data
  • Box2D.NET samples correctly handle font scaling across different DPI settings and screens
  • Implementation should be cross-platform, with Windows, Linux, and Mac support as feasible
  • See discussion: https://stackoverflow.com/a/54628671/1745070
  • Example workaround in Stride Community Toolkit
  • Fonts should scale as the monitor DPI or scaling factor changes, similar to how Box2D.NET does it
  • Consider how other engines handle DPI and allow opt-in behavior
  • The developer should decide and control how the game behaves when DPI is changed. Maybe all gets resized, maybe just game UI, maybe just some entities?

Here are some questions that can aid in the description of the feature request:

  • Use cases include rendering sharp fonts, UI, and content across multiple monitors and DPI settings
  • Expected options: ability to query DPI scaling, opt-in DPI-aware mode, possibly engine-managed scaling in the future
  • Pseudocode: GraphicsOutput.GetMonitorContentScale() -> float uiScale
  • Editor impact: DPI scaling info accessible, but opt-in rendering adjustments
  • May require updates to GraphicsOutput, platform abstraction, and documentation
  • Example project [WIP]: Stride Community Toolkit ImGui sample

Screen: Current State on 4K with 175% Scale. Click on the image to see it better.

Image 1

  • blurred font
  • blurred shapes
Image

Image 2 - Adding a helper WindowsDpiManager.EnablePerMonitorV2(); which enables DPI awareness

  • sharp font - here is where we would need DPI and the game would need to resize the font (make it bigger) based on the developer choice (maybe not)
  • sharp shapes - here is where we would need DPI and make some adjustments maybe in the thickness of the outlines, again the developer has to decide?
Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating GraphicsOutput and the platform abstraction used for monitor or display information. Review the Silk.NET, DXGI, SDL, and WindowsDpiManager references in the issue, then define the cross-platform API and opt-in behavior; done should include a clear DPI-scaling result and documented handling expectations across supported platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
computer-graphics, game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.