SFML community forums
General => SFML development => Topic started by: Hapax on May 10, 2023, 06:05:30 pm
-
Regarding SFML master (v3-WIP).
I noticed that render states in the virtual draw method of a drawable is now a const reference (instead of by value) and I wonder what the reason behind this decision was as I can't find any information or discussion yet other than an old post saying that it wouldn't happen ;)
Old post: https://en.sfml-dev.org/forums/index.php?topic=17102.0
To be clear, I'm not at all saying it's a wrong decision (just because I had to modify lots of code ;D) but wondered why the decision was changed. Maybe now it's better to be (possibly) more optimised over simplicity?
-
https://github.com/SFML/SFML/pull/2008
The previous version meant all draw calls necessarily copied RenderStates. Now that copy only happens when required. You have to explicitly make a copy if you want a copy but you're not forced to pay the price of that copy if you don't need it.
-
That's what I presumed - optimising for speed rather than simplicity. That does sound like I meant it negatively but I think it's a good choice here with a choice that happens every single draw call. It's trivial to make a copy if one needs it anyway; it's just a new habit to get into (since I almost always do make that copy).
I only noticed it when it refused to compile and wanted to know if it was a decision that's been made for SFML3 or it's being tried out so I think you've answered that now, so thank you. :)