In my opinion, CopyToImage is a single-shot operation, I can't think of a use case that would require updating the same image again and again from a texture.
Well I totally agree with this but I can't help feeling that for rbSFML this will be really bad and slow cause it means that it will create a copy from the return value of the
CopyToImage function and then a copy again from that object to a heap-based object so it can be used in the bindings. Or am I missing something I can do here to remove that second copy?
Still sure it should not be part of the normal frame iteration of a game but this means that this is double as slow just because. I'm not obsessed with optimizing code(Haven't tried optimizing rbSFML at all, will do that when sfml2 is done) but it nags me back in my head when it can be avoided.
The code will be something like:
static VALUE Texture_CopyToImage( VALUE self )
{
// Code code code
VALUE newImage = // Allocate a new Ruby image.
sf::Image *imagePtr = NULL;
Data_Get_Struct( newImage, sf::Image, imagePtr );
*imagePtr = selfPtr->CopyToImage();
return newImage;
}
But I guess if I can manage to do something like this the second copy won't be made?
sf::Image *newImage = new sf::Image( texture->CopyToImage() );
Or does it not matter?