SFML community forums

Help => Graphics => Topic started by: LucasShadow on May 31, 2012, 06:27:34 am

Title: Cant use Vectors for RenderTextures?
Post by: LucasShadow on May 31, 2012, 06:27:34 am
I am trying to make an array of rendertextures using vectors (with SFML 2.0), but I am getting some odd errors involving:

sf::NonCopyable& sf::NonCopyable::operator=(const sf::NonCopyable&)' is private
 
 

Is using a vector not possible for what I am trying to do? Below is a minimal example that reproduces the errors:

#include <SFML/Graphics.hpp>

 int main()
 {
     sf::RenderWindow App(sf::VideoMode(800, 600), "RenderTexture");

     ///Number of chunks along the x and y axis of the map
     int NumberOfChunks = 3;

     ///Vector for the rendertexture
     std::vector<sf::RenderTexture> bg; bg.resize(NumberOfChunks * NumberOfChunks);

     ///Create the size of the rendertexture
     for(int i = 0; i < NumberOfChunks * NumberOfChunks; i++) bg[i].create(3, 3);

     ///Some code here that assigns stuff drawn to the rendertextures

     ///Display the rendertextures
     for(int i = 0; i < NumberOfChunks * NumberOfChunks; i++) bg[i].display();

     ///Assign the rendertextures to sprites
     std::vector<sf::Sprite> WorldChunk; WorldChunk.resize(NumberOfChunks * NumberOfChunks);

     ///Some code here the positions the sprites

     while (App.isOpen())
     {
         sf::Event Event;
         while (App.pollEvent(Event))
         {
             if (Event.type == sf::Event::Closed)
                 App.close();
         }

         App.clear();

         ///Display the sprites
         for(int i = 0; i < NumberOfChunks * NumberOfChunks; i++) App.draw(WorldChunk[i]);

         App.display();
     }
     return EXIT_SUCCESS;
 }
 
Title: Re: Cant use Vectors for RenderTextures?
Post by: Laurent on May 31, 2012, 08:07:18 am
RenderTexture is not copyable, and using a vector requires its elements to be copyable (because... you store copies).

You must use pointers to dynamically allocated instances.