Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I implement clipping using SFML 2.1 2d drawing API?

Tags:

c++

c#

sfml

I am implementing a simplistic GUI library for a game.

My solution uses SFML 2.1 2d API.

As you can imagine, the ui elements are organized in a hierarchical structure. Children are expected to render within the bounds of their parents.

I could live with the need to trust children to render outside their parent. However, to implement scrolling in a simple manner, I'd like to clip whatever children render.

Is there a way to achieve this using the SFML 2d api ?

For now, I could only come up with drawing to a texture and use that texture for a shape or sprite. I am concerned with performance (even though, the texture would only be regenerated when UI content changes).

like image 286
TiMoch Avatar asked Feb 17 '26 06:02

TiMoch


1 Answers

Unfortunately this features isn't yet implemented, but you're not the only one waiting for it, see the first issue ever created on SFML's GitHub issue tracker.

In the meantime the only way is to either use OpenGL directly or via a sf::RenderTexture.

like image 151
Lukas Avatar answered Feb 18 '26 18:02

Lukas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!