floooh / v6502r

visual6502 remixed
297 stars 30 forks source link

Antialiasing on high pixel density displays #7

Closed verhovsky closed 1 year ago

verhovsky commented 1 year ago

I have a retina (i.e. high pixel density) monitor and it seems like v6502r isn't using all the pixels. Compare the anti aliasing on the purple wire with the antialiasing of text in my terminal window:

Screenshot 2023-01-12 at 1 22 07 PM

even straight lines are visibly blurry because of the anti aliasing when they could be pixel perfect. Here's a better comparison of an SVG file open in Chrome vs v6502r running locally:

Screenshot 2023-01-12 at 1 37 19 PM

I only changed the Contrast theme to be pure white and compiled it with ./fips build && ./fips run v6502r. The v6502r window is a bit darker on top because macOS adds a drop shadow under windows.

Looking at https://floooh.github.io/sokol-html5/shadows-sapp.html it seems like this might be a problem with sokol itself.

floooh commented 1 year ago

On high-dpi displays rendering happens at half resolution with 4x MSAA to keep pixel fillrate down for lower-end devices.

You can render at full resolution by adding .high_dpi = true, to the sokol-app initialization block here:

https://github.com/floooh/v6502r/blob/c3bc950c2d15b8682ebc08377881f5361ac6a74a/src/main.c#L168-L185

...on my Mac this yields:

Screenshot 2023-01-13 at 11 55 06

...versus the default of rendering at half resolution with upscaling:

Screenshot 2023-01-13 at 11 59 52

(the differences are easier to spot if you click on the images)

floooh commented 1 year ago

FYI: I'm adding a cmdline arg to optionally enable high-dpi, on the native version it would look like this:

> v6502r highdpi=true

...or when started via fips:

> ./fips run v6502r -- highdpi=true

...and on the web it can be activated with an URL arg like this:

https://floooh.github.io/visual6502remix/index.html?highdpi=true

(I'll let you know here when the wasm version has been updated)

verhovsky commented 1 year ago

The text is still not high dpi.

floooh commented 1 year ago

The text is still not high dpi.

Yes that's how it is, proper 'high-dpi' text would require embedding a different font, and for really high quality text, a different text renderer would need to be integrated, but I'm not going there ;)

The WASM versions have been updated and are available under those URLs:

https://floooh.github.io/visualz80remix/index.html?highdpi=true

https://floooh.github.io/visual6502remix/index.html?highdpi=true

https://floooh.github.io/visual2a03remix/index.html?highdpi=true