1
Window / [SOLVED] Accessing the window in other functions
« on: July 14, 2010, 03:06:04 am »
Sounds like you're passing by value and not by reference.
For the function inside your tile class, if you want to modify the RenderWindow, it should look something like
Note the ampersand(&) next to sf::RenderWindow. If you
If your code looks more like this:
then it'll try to pass by value (note the lack of the ampersand), which means its trying to copy the RenderWindow instead of sharing the same instance. Atleast, I'm assuming this is what is causing your problem, since you're getting an issue with sf::NonCopyable.
Although, if all you want to do is render your tile class to the RenderWindow each frame, make sure your Tile Class inherits from sf::Drawable, and define the Render function
That way, you just put your rendering stuff within Render(..) and call
and it'll draw your tile class. Assuming App is your RenderWindow.
For the function inside your tile class, if you want to modify the RenderWindow, it should look something like
Code: [Select]
void function(sf::RenderWindow& myRenderWindow)
{
...
}
Note the ampersand(&) next to sf::RenderWindow. If you
If your code looks more like this:
Code: [Select]
void function(sf::RenderWindow myRenderWindow)
{
...
}
then it'll try to pass by value (note the lack of the ampersand), which means its trying to copy the RenderWindow instead of sharing the same instance. Atleast, I'm assuming this is what is causing your problem, since you're getting an issue with sf::NonCopyable.
Although, if all you want to do is render your tile class to the RenderWindow each frame, make sure your Tile Class inherits from sf::Drawable, and define the Render function
Code: [Select]
virtual void Render(sf::RenderTarget& Target) const;
That way, you just put your rendering stuff within Render(..) and call
Code: [Select]
App.Draw(myTileClass)
and it'll draw your tile class. Assuming App is your RenderWindow.