SFML: Generate a background image

Posted by BlackMamba on Game Development See other posts from Game Development or by BlackMamba
Published on 2013-09-16T21:58:29Z Indexed on 2013/10/22 4:10 UTC
Read the original article Hit count: 1412

Filed under:
|
|
|
|

I want to generate a background, which is used in the game, on every instance of the game based on certain conditions. To do so, I'm using a sf::RenderTexture and a sf::Texture like this:

sf::RenderTexture image;
std::vector<sf::Texture> textures;
sf::Texture texture;
// instantiating the vector of textures and the image not shown here
for (int i = 0; i < certainSize; ++i)
{
    if(certainContition)
    {
        texture.setTexture("file");
        texture.setPosition(pos1, pos2);
    } else
    {
        ...
    }
image.draw(texture);
}

The point here is that I draw single textures on a sf::RenderTexture, but because textures always are on the graphic cards memory, I can't exceed a certain map size which I have to.
I also considered using an sf::Image, but I can't find a way to draw an image (i.e. a texture) to it.
The third way I found was using an sf::VertexArray, but this seems to be a bit too low-level for my rather simple purposes.
So is there a common way to dynamically generate a background image based on other existing images?

© Game Development or respective owner

Related posts about c++

Related posts about textures