I have written the following code:
string imageName = "levelImage";
sf::RenderTexture r;
for(vector<GameObject*>::const_iterator i = gameObjects.begin(); i != gameObjects.end(); ++i) {
(*i)->render(r);
}
r.getTexture().copyToImage().saveToFile(imageName);
Which should create an image of all my gameObjects. However, I am getting the error message: "failed to save image: "levelImage.png"" I am almost certain the problem is not within the for loop btw.