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

Author Topic: Why can't I use sf::RenderTexture as a class's member?  (Read 1278 times)

0 Members and 1 Guest are viewing this topic.

smguyk

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
Why can't I use sf::RenderTexture as a class's member?
« on: November 10, 2014, 11:33:36 am »
I have a resource class that holds textures and fonts etc. and I access those for example with

sf::Texture &getTexture(const std::string &nameOfTexture);

This works.

Now I need an sf::RenderTexture as a class member too, but it won't let me do it. The compilation error is

1>C:\Users\admin\Documents\SFML\SFML-2.1-vc11\include\SFML/Graphics/RenderTarget.hpp(419): error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'
1>          C:\Users\admin\Documents\SFML\SFML-2.1-vc11\include\SFML/System/NonCopyable.hpp(67) : see declaration of 'sf::NonCopyable::NonCopyable'
1>          C:\Users\admin\Documents\SFML\SFML-2.1-vc11\include\SFML/System/NonCopyable.hpp(42) : see declaration of 'sf::NonCopyable'
1>          This diagnostic occurred in the compiler generated function 'sf::RenderTarget::RenderTarget(const sf::RenderTarget &)'

I Googled but couldn't find a solution. How am I supposed to do it?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10827
    • View Profile
    • development blog
    • Email
AW: Why can't I use sf::RenderTexture as a class's member?
« Reply #1 on: November 10, 2014, 11:50:12 am »
RenderTextures (or rather RenderTarget) can't be copied, as such you need to make sure, that you don't copy your class or handle the RT on the heap with a correct implementation of the copy constructor.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything