What does void Texture::Update(const Window& window) exactly do? The documentation says "Update the texture from the contents of a window" which is not really more information than I am given by the function signature
It copies the current contents of the window to the texture. What else can I say? Maybe "copy" is more relevant than "update" in the comments?
If it performs a screenshot, what's the difference to Image RenderWindow::Capture() const? Only the indirection via sf::Image?
Texture and Image are two different things, therefore updating a texture and updating an image (from a window) are also two different things. Both are optimized, using one to implement the other would be very ineficient.
Finally, I'd say that:
- The main purpose of Texture::Update(Window&) is to implement real-time post-effects with shaders, everything stays on the GPU
- The main purpose of RenderWindow::Capture() is to take screenshots of the application, it downloads the pixels to the system memory
Does it load the image anyway without regarding the GPU capacity like i've mentioned before?
Are you talking about texture size or memory capacity? For the first one it returns an error, but for the second one it prints a warning in the error output.
Another question, how do sf::Texture's methods void Update(const Image&) and bool LoadFromImage(const Image&) differ? The difference I have seen until now is that the former requires that the texture be created beforehand. Can't Update() fail? Maybe you should emphasize those points more explicitly in the documentation
Update only copies pixels, it doesn't create anything nor perform any check. It's a fast function that can be used to stream contents to a texture in real-time, like a video.
LoadFromXxx create the texture.
Can't Update() fail?
It does nothing if the texture has not been created yet.
It crashes if one of the parameters is wrong (size doesn't match, etc.) -- it provides maximum performances so you are responsible for providing correct parameters.
And doesn't sf::Texture have a CreateMaskFromColor() anymore? Is it because the sf::Image doesn't really exist after loading, so this would have to be specified at texture creation time?
Absolutely. sf::Texture only knows how to upload and download pixels to the graphics card. If you have custom processing to apply to these pixels, you must do it before providing the pixels to sf::Texture.
Unfortunately, this leads to unnecessary, expensive copies
Where are those copies?
is it me or i cannot compile this build?
Oops, I'll fix this ASAP, sorry.