SFML community forums

General => SFML projects => Topic started by: foo on December 02, 2022, 11:35:33 pm

Title: Swoosh 2 alpha release
Post by: foo on December 02, 2022, 11:35:33 pm
Swoosh 2 (https://github.com/TheMaverickProgrammer/Swoosh/tree/feature/swoosh2) is ready for use but not yet merged into master. Use branch feature/swoosh2 (https://github.com/TheMaverickProgrammer/Swoosh/tree/feature/swoosh2) for the latest changes.



What is Swoosh (https://twitter.com/swooshlib)?
See More:
(click to show/hide)

Swoosh 2 changes the way we render graphics. Traditionally, SFML sprites are drawn directly to the target surface or window. With Swoosh 2, we submit render events with data in them and let the user-defined renderer decide how to draw. It's convenient to think of render events for sfml drawables as "tags". By tagging the drawables, we can tell the renderer how we'd like to draw them.

Swoosh 2 comes with a simple composite renderer, SimpleRenderer (https://github.com/TheMaverickProgrammer/Swoosh/blob/feature/swoosh2/src/Swoosh/Renderers/SimpleRenderer.h), and a few event types to begin migrating from the previous version:
Swoosh 2 can let you define multiple renderers and switch between them on the fly. I think a video speaks for itself. In the following video, I switch between the simple renderer that comes with Swoosh and a deferred renderer for 3D lighting effects. The deferred render (https://github.com/TheMaverickProgrammer/Swoosh/blob/feature/swoosh2/ExampleDemo/CustomRenderer.h) is available for your own use in the Example Project that comes with the fork.

(https://i3.ytimg.com/vi/bDfssxAn44A/hqdefault.jpg) (https://www.youtube.com/watch?v=bDfssxAn44A)
Click the image to go to the YouTube video



Having multiple render options for SFML projects is powerful and brings a lot of utility.

One render option can be used to increase performance on embedded machines by discarding some events entirely, especially since SFML 2 is still very behind on modern graphics support on PC and mobile.

Another renderer can be used for debugging your application. Or you can get creative and make the renderer an in-game effect that changes how your player sees the world around them.

The most powerful aspect about Swoosh 2's new renderer pipeline is that you do not need to change what you submit to draw so all of your scene's code stays the same.

See the Example Project draw step source code (https://github.com/TheMaverickProgrammer/Swoosh/blob/feature/swoosh2/ExampleDemo/Scenes/GameplayScene.h#L494) to see this fact in action.