This commit (https://github.com/SFML/SFML/commit/4dfad062e43d7c6ef5161d52dd79ce8934ee4e68#diff-eed237ea11c4606e0756807ab9ebb412) has made all the renderables use a vertex buffer if available. Which is great; however, before this change drawables were quite lightweight, and we could create one of these drawables at the last moment. For instance...
loop {
// construct sprite
sf::Sprite sprite {...};
target.draw(sprite);
}
But now, afaict, this will call glGenBuffers and then glDeleteBuffers every frame. If this change is to be preserved I think the docs should not call sf::Sprite lightweight anymore.
For what it's worth, I'm doing something very similar in my own engine:
pub fn draw_image(ctx: &mut Context, image: &Image, params: DrawImageParams) {
let mut sprite = SfSprite::with_texture(&image.texture);
sprite.set_position(SfVector2f::from(params.position));
if let Some(clip_rect) = params.clip_rect {
sprite.set_texture_rect(&clip_rect.into());
}
if let Some(color) = params.color {
sprite.set_color(&color.into());
}
if let Some(scale) = params.scale {
sprite.set_scale(scale);
}
ctx.window.draw_sprite(&sprite, SfRenderStates::default())
}
Regardless of whether or not this is a "correct" usage of sf::Sprite, it seems like a pretty major change to deprecate this pattern in a minor version.