PistonDevelopers / conrod

An easy-to-use, 2D GUI library written entirely in Rust.
Other
3.35k stars 296 forks source link

Add Sdl2 backend #1451

Open TonalidadeHidrica opened 2 years ago

TonalidadeHidrica commented 2 years ago

This is the Take 3 of providing SDL2 backend for cornod.

I didn't use OpenGL

When it comes to using SDL2, there are a big choice: to use OpenGL or not to use. In the prior art,

In this PR, I took the course of not using it, because I wanted to keep the dependencies minimal.

I checked that all the features of DemoApp works, but feel free to pointing out anything I am missing.

Credits go to:

About Rust version

Since I could not find the information of MSRV, I developed conrod_sdl2 crate with 1.57.0 and Rust 2021 Edition. If I should use older ones, I would update the code.

About the addition to the dependency

I added thiserror to minimize the boilerplates on error handling, and smallvec for a iterator-friendly container of up-to-two events. If this matters, let me know and I'll think the other way.

Notes on graphics

When you run all_sdl2, you will see the thin diagonal lines as well as horizontal and vertical noize-like lines. These are probably due to overlapping extremely-thin transparent triangles. Unlike GL families, triangles in SDL seems not be cut out for forming complex polygons from many triangles. I think this is inevitable, as long as we use pure SDL2. image

elrnv commented 2 years ago

Nice work! I'm happy you found the old PRs useful, and thank you for the mention :)