Skip to content

High density framebuffer and supersampling support#2801

Open
riccardobl wants to merge 6 commits into
jMonkeyEngine:masterfrom
riccardobl:highdpi
Open

High density framebuffer and supersampling support#2801
riccardobl wants to merge 6 commits into
jMonkeyEngine:masterfrom
riccardobl:highdpi

Conversation

@riccardobl
Copy link
Copy Markdown
Member

@riccardobl riccardobl commented May 24, 2026

This PR adds hidpi and supersampling support to every backend.
Up until now jme had some limited support for high dpi framebuffers (that we called RetinaFramebuffer and was built specifically for macos), this PR adds a DisplayScaleMode AppSettings that extends and improves the support for high dpi to every platform and adds supersampling support.

Possible values:

  • DISPLAY_SCALE_DISABLED : disables high dpi support (current default)
  • DISPLAY_SCALE_NATIVE_PIXELS : same behavior as the current RetinaFramebuffer setting, basically the engine sees the high dpi framebuffer as a generic big framebuffer, the camera sizes match the full high dpi framebuffer size, apps need to be aware of that, eg. to scale ui elements accordingly.
  • DISPLAY_SCALE_DPI_AWARE : proper high dpi support. The camera is sized accordingly to the logical framebuffer size, but the underlying render target is bigger. This means apps can render normally as if they were targeting an unscaled framebuffer and the engine will do the scaling underneath.
  • any value >1.0f : this is like DISPLAY_SCALE_DPI_AWARE but with supersampling, if you specify for example 2f, the engine will render at twice the maximum resolution for the default framebuffer, and then scale down with linear filtering. This is basically an alternative to antialiasing.

Suggested setting for new apps is DISPLAY_SCALE_DPI_AWARE or 1.2f, but it is defaulted to DISPLAY_SCALE_DISABLED for backward compatibility.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive high-DPI and display scaling model across the Android, iOS, and Desktop (LWJGL3) backends, effectively separating logical application coordinates from physical framebuffer pixels. Key changes include the addition of new scaling mode constants in AppSettings, a DisplayScaleUtils utility for coordinate resolution, and updates to JmeContext, RenderManager, and various input handlers to support DPI-aware rendering and input. The implementation also supports emulated render scaling and enhances the sRGB blit path to accommodate these scaling modes. New unit tests and a manual diagnostic example have been added to verify the functionality. I have no feedback to provide as there were no review comments to assess.

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.

1 participant