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

Author Topic: Is it possible to copy a window ?  (Read 3640 times)

0 Members and 1 Guest are viewing this topic.

hanhau

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Is it possible to copy a window ?
« 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 ^^

SpeCter

  • Full Member
  • ***
  • Posts: 151
    • View Profile
Re: Is it possible to copy a window ?
« Reply #1 on: December 21, 2014, 05:09:02 pm »
sf::RenderWindow is derived from sf::NonCopyable so no, you can't copy it.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Is it possible to copy a window ?
« Reply #2 on: December 21, 2014, 06:26:51 pm »
I can't imagine any case where one would need to copy a window.
Laurent Gomila - SFML developer

hanhau

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Is it possible to copy a window ?
« Reply #3 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.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Is it possible to copy a window ?
« Reply #4 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.

SpeCter

  • Full Member
  • ***
  • Posts: 151
    • View Profile
Re: Is it possible to copy a window ?
« Reply #5 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 ;)

hanhau

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Is it possible to copy a window ?
« Reply #6 on: December 21, 2014, 07:09:17 pm »
SpeCter .....

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

Thank you for the help, nice Christmas everyone ^^

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Is it possible to copy a window ?
« Reply #7 on: December 21, 2014, 08:04:20 pm »
The emphasis should really be on Ixrec's post, for your own sake.
SFML / OS X developer