SFML community forums

Help => Window => Topic started by: hanhau on December 21, 2014, 04:06:39 pm

Title: Is it possible to copy a window ?
Post by: hanhau on December 21, 2014, 04:06:39 pm
Hey Guys there, I am pretty new here at SFML :) Here“s my question:

Can I copy a RenderWindow ?
Like .....

sf::RenderWindow app1(sf::VideoMode(100,100),"app1",sf::Style::Default);
sf::RenderWindow app2 = app1;
 

I could need it in some ways, but I am actually search for other solutions for the problem.
That was it.

Thanks for answers :)
Have a nice day, Hannes ^^
Title: Re: Is it possible to copy a window ?
Post by: SpeCter on December 21, 2014, 05:09:02 pm
sf::RenderWindow is derived from sf::NonCopyable so no, you can't copy it.
Title: Re: Is it possible to copy a window ?
Post by: Laurent on December 21, 2014, 06:26:51 pm
I can't imagine any case where one would need to copy a window.
Title: Re: Is it possible to copy a window ?
Post by: hanhau on December 21, 2014, 06:56:40 pm
Actually, I wrote a headerfile, wich contains a class with a function, that should draw in the mainwindow, wich gets initialized in the main.cpp. How can I do that ? Okay, copying Is not the right word, I just want to handle that in a other .hpp file, because of the handling with easier coding with more view about it.
Title: Re: Is it possible to copy a window ?
Post by: Ixrec on December 21, 2014, 06:58:49 pm
I think you're asking how to pass a function argument by reference instead of by value.  This is basic C++ stuff; you should go read a good book about the language first (https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list).
Title: Re: Is it possible to copy a window ?
Post by: SpeCter on December 21, 2014, 06:59:50 pm
Just call by reference or by pointer:

void foo(sf::Window& window)
{
    //do whatever you want with window like:
    window.draw(whatever);
}

Edit:
Do what Ixrec said ;)
Title: Re: Is it possible to copy a window ?
Post by: hanhau on December 21, 2014, 07:09:17 pm
SpeCter .....

oh yeah, pointer .... I totally forgot, damnit.

Thank you for the help, nice Christmas everyone ^^
Title: Re: Is it possible to copy a window ?
Post by: Hiura on December 21, 2014, 08:04:20 pm
The emphasis should really be on Ixrec's post, for your own sake.