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 is blurry #1240

Open
krankur opened this issue Sep 1, 2018 · 10 comments
Open

Text is blurry #1240

krankur opened this issue Sep 1, 2018 · 10 comments

Comments

@krankur
Copy link

krankur commented Sep 1, 2018

I am developing a game in Piston and need to display text in order to show the score. I followed the instructions given here https://github.com/PistonDevelopers/piston-examples/blob/master/src/hello_world.rs and was able to render the text successfully, but it looks blurry. I have tried the solution provided here PistonDevelopers/piston_window#179, but it didn't work for me.
screen shot 2018-09-01 at 10 38 58 pm

@bvssvni
Copy link
Member

bvssvni commented Sep 20, 2018

Try swap the graphics backend to opengl-graphics: https://github.com/PistonDevelopers/opengl_graphics/blob/master/examples/text_test.rs

@krankur
Copy link
Author

krankur commented Sep 22, 2018

I tried using opengl-graphics, but it didn't make a difference. You can have a look at my code here. The blurriness is more obvious with a light background, so finally I switched to a dark background.

@Sakari369
Copy link

Yeah seeing this on macOS 10.14.6 on the retina screen.

@jeanlauliac
Copy link

jeanlauliac commented Dec 14, 2019

Same here. Could it be that it is not taking the pixel ratio of the screen when building the glyphs? Which might explain it being blurry on Retina screen? I don't have a non-retina screen to check that assumption though. I'm happy to look into it, would love some guidance as to where the glyphs are built.

@bvssvni
Copy link
Member

bvssvni commented Dec 15, 2019

I believe you can fix the blur using a scale transform and larger test. Ideally this should be detected and handled by the text rendering. Ideas?

@nthparameter
Copy link

I'm also interested in rendering sharp text. If someone finds a solution (on online guide) please post a it (or a link) here.

@jeanlauliac
Copy link

jeanlauliac commented Dec 27, 2019

I confirm that rendering twice the size but with zoom(0.5) on the transform works. So for the time being I'll put that problem aside ;)

Example of my code:

        let text_tr = context.transform.trans(10.0, 100.0).zoom(0.5);
        text::Text::new_color([0.9, 0.9, 0.9, 1.0], 28)
            .draw(
                "Hello world!",
                &mut self.glyphs,
                &context.draw_state,
                text_tr,
                g2d,
            )
            .unwrap();

        self.glyphs.factory.encoder.flush(device);

@filippo-orru
Copy link

I'd love to have sharp text.
Previously, I used opengl and fixed the problem by disabling windows scaling and letting the application be rather small (unaffected by my windows scale factor of 125%).
Now I've switched to using piston_window with opengl 3.2 and the text is blurry and the game appears to be much slower. The renders apparently take more time than previously (around 20-30ms, way too much).
Any help with this?

@bvssvni
Copy link
Member

bvssvni commented Jan 17, 2020

@ffactory-ofcl make sure you run in release mode when benchmarking. The performance in debug mode is unreliable.

@filippo-orru
Copy link

@bvssvni I know that it is but it shouldn't lag this bad. I only draw at most 50 polygons and 60 rectangles in any given frame. It's a simple tetris clone and before I updated from a few pistoncore packages to piston_window, everything was fine, even in debug. No need to benchmark either. Now, it's supposedly still OpenGL 3.2 but laggy. For now, I've started to port it to ggez instead of piston.

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

6 participants