Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text renders at low resolution when FontScalingGlobal is set to 0.5 #7

Open
pboyer opened this issue Jun 22, 2018 · 5 comments
Open

Comments

@pboyer
Copy link

pboyer commented Jun 22, 2018

Usage of this library interferes with ImGui's text rendering quality. This seems to result in text being rendered at half the expected resolution. I'm using a retina display.

Left: ImGui 1.62 WIP, built from source
Font: Roboto-Medium.ttf, Size: 32.0f, FontScalingGlobal: 0.5

Left: ImGui 1.60 WIP as used from floooh/oryol-imgui with MSAA 4
Font: Roboto-Medium.ttf, Size: 32.0f, FontScalingGlobal: 0.5

screen shot 2018-06-22 at 4 54 53 pm

Let me know and I can cook up a more reproducible gist.

@pboyer
Copy link
Author

pboyer commented Jun 22, 2018

Note that the problem doesn't occur when trying out the same configuration with the ImGui 1.60 samples. That is, the issue doesn't have to do with the ImGui version.

This suggests the issue has to do with the font texture configuration in oryol or oryol-imgui or the way those systems obtain the font texture from dear imgui.

@pboyer pboyer changed the title Text renders at low font size Text renders at low resolution when FontScalingGlobal is set to 0.5 Jun 22, 2018
@floooh
Copy link
Owner

floooh commented Jun 22, 2018

Did you enable HighDPI mode like here?

https://github.com/floooh/oryol/blob/fa3401ba0ce963e2b17ae224780a93dd8c49193f/code/Samples/TestInput/TestInput.cc#L70

Otherwise Oryol will render at half resolution on Retina displays to preserve pixel fillrate.

Also, Sokol has a HighDPI-Sample for Imgui, does the following produce the expected result?

> mkdir ~/scratch
> cd ~/scratch
> git clone https://github.com/floooh/sokol-samples
> cd sokol-samples
> ./fips set config sapp-metal-osx-make-release
> ./fips build
> ./fips run imgui-highdpi-sapp

It should look like this:
screenshot 2018-06-23 at 01 06 47

Upscaled text from this demo:

screenshot 2018-06-23 at 01 08 06

I'm not using FontGlobalScale in this demo though, instead I scale the vertices and cliprects, and set OversampleH and OversampleV in ImFontConfig to the value 2, so that the font glyphs are rendered with twice the resolution. The complete sokol-demo is here: https://github.com/floooh/sokol-samples/blob/master/sapp/imgui-highdpi-sapp.cc

In Oryol it would work similar as long as the GfxSetup::HighDPI flag is set.

@floooh
Copy link
Owner

floooh commented Jun 22, 2018

PS: I also updated the fips-imgui repository (used by oryol-imgui) to the latest ImGui master-branch version (1.62+).

@floooh
Copy link
Owner

floooh commented Jun 22, 2018

...wait, the way how I'm doing the Retina-scaling in the sokol-sample doesn't work in oryol-imgui, since this doesn't support vertex- and clip-rect-scaling in the ImGui-draw-hook. I'll most likely implement this after I merged the sokol-gfx Gfx backend in Oryol back to master, but this is most likely a few weeks away. For now your best bet is to try the GfxSetup::HighDPI flag to render in full Retina resolution, and then use ImGui FontScaling to increase the text size (otherwise everything will be very tiny).

Cheers!

@pboyer
Copy link
Author

pboyer commented Jun 23, 2018

I tried setting the HighDPI flag. It seemed to have no effect. Here's my setup:

    this->gfxSetup = GfxSetup::WindowMSAA4(1280, 800, "Foobar");
    this->gfxSetup.HighDPI = true;
    this->gfxSetup.DefaultPassAction = PassAction::Clear(glm::vec4(0.0f, 0.0f, 0.0f, 1.0f));
    Gfx::Setup(this->gfxSetup);

Here's a comparison where I modulate the font size and FontGlobalScale. In each, HighDPI is set to true.

screen shot 2018-06-22 at 8 08 05 pm

I'll keep digging around. Thanks again for the quick feedback @floooh!

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

No branches or pull requests

2 participants