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

Author Topic: Problem passing around an instance of sf::RenderWindow  (Read 2495 times)

0 Members and 1 Guest are viewing this topic.

Wibbs

  • Newbie
  • *
  • Posts: 40
    • View Profile
Problem passing around an instance of sf::RenderWindow
« on: October 26, 2009, 04:46:59 pm »
Hi,

I'm sorry if this is a silly question, but I can't get my head around how to pass a reference or pointer to my sf::RenderWindow instance.  

I have a VideoManager class which holds a sf::RenderWindow private member variable.  How do I write a get function that will give other classes access to this variable? I've tried passing by reference and pointeres in various combinations, but whatever I try brings up the error:

cannot access private member declared in class 'sf::NonCopyable

which I am guessing is something to do with a singleton implementaiton within SFML.  

I would be grateful for any pointers, as I feel I'm missing something obvious here...

Thanks,

Wibbs

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Problem passing around an instance of sf::RenderWindow
« Reply #1 on: October 26, 2009, 05:13:00 pm »
You get this error because you try to pass your window by value (i.e. a copy of it), which is for obvious reasons not allowed.

You must return a reference:
Code: [Select]
sf::RenderWindow& GetWindow() {return this->window;}
Laurent Gomila - SFML developer

Wibbs

  • Newbie
  • *
  • Posts: 40
    • View Profile
Problem passing around an instance of sf::RenderWindow
« Reply #2 on: October 26, 2009, 05:46:07 pm »
Thanks for the quick reply.  Turns out my mistake was actually because of confusion using boost smart pointers rather than directly with SFML, and it was trying to make a copy of an object without me realising it - all sorted now though.

Wibbs

 

anything