1
Graphics / Re: a simple sprite batch class feedback needed
« on: January 25, 2021, 07:15:45 pm »I recommend to use constructor and destructor (if necessary) to handle initialization and destruction. That way it's enforced by the compiler that your object can only be used when it's fully initialized and you don't need runtme m_active checks.I have decided to remove the .Begin and .End methods, I was copying an API and the more I thought about it, the less I liked that approach. The batch now builds up render op lists, detecting changes that would require a new batch to be started and instead pushes a new list. Nothing gets drawn until flush is called, all lists are then drawn in order.
I recommend using C++ style casts with static_cast<float>(var) and if it's about a whole sf::Vector2<T> type conversion, you could also call the constructor that allows explicit conversions sf::Vector2f(size).Thank you, I've made the changes you suggested.
For a sprite batching, I'd assume, that I could individually position sprites with different texture coordinates, so the x, y parameter for draw() seems a bit limited.Yes that draw method is very limited, only allowing you to draw the full texture at x,y position. That was purely for testing and to keep the posted code as concise as possible. This has been overloaded to allow sub rects, rotation, scaling etc.
Thank you for you help