Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Cant use Vectors for RenderTextures?  (Read 1424 times)

0 Members and 1 Guest are viewing this topic.

LucasShadow

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Cant use Vectors for RenderTextures?
« 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;
 }
 

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Cant use Vectors for RenderTextures?
« Reply #1 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.
Laurent Gomila - SFML developer