piston icon indicating copy to clipboard operation
piston copied to clipboard

Text is blurry

Open krankur opened this issue 5 years ago • 10 comments

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 https://github.com/PistonDevelopers/piston_window/issues/179, but it didn't work for me. screen shot 2018-09-01 at 10 38 58 pm

krankur avatar Sep 01 '18 17:09 krankur

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

bvssvni avatar Sep 20 '18 16:09 bvssvni

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.

krankur avatar Sep 22 '18 08:09 krankur

Yeah seeing this on macOS 10.14.6 on the retina screen.

Sakari369 avatar Aug 28 '19 08:08 Sakari369

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.

jeanlauliac avatar Dec 14 '19 23:12 jeanlauliac

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?

bvssvni avatar Dec 15 '19 15:12 bvssvni

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

nthparameter avatar Dec 27 '19 17:12 nthparameter

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);

jeanlauliac avatar Dec 27 '19 18:12 jeanlauliac

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?

filippo-orru avatar Jan 16 '20 11:01 filippo-orru

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

bvssvni avatar Jan 17 '20 14:01 bvssvni

@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.

filippo-orru avatar Jan 17 '20 18:01 filippo-orru