SFML community forums

Help => Graphics => Topic started by: Jarwulf on January 21, 2010, 01:20:28 am

Title: App.Draw
Post by: Jarwulf on January 21, 2010, 01:20:28 am
Hi I have

sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");



I have several objects on screen. I currently have all the objects displayed by
using App.Draw from main().


I want to make it so that the objects display under certain circumstances ie a collision between two causes them to disappear. So I figure I should transfer whether an object uses App.Draw from main to the object itself,controlled by an (if) statement. When I try to do something like

Object.objectwork(App);

I get errors. How would I accomplish what I want?
Title: App.Draw
Post by: panithadrum on January 21, 2010, 03:19:27 am
Detail about your errors please.
Title: App.Draw
Post by: Jarwulf on January 21, 2010, 03:31:33 am
Quote from: "panithadrum"
Detail about your errors please.



Something about can't access private member  noncopyable. I guess that means a part of App is private and I can't use the whole thing as an argument so I wonder what part of App I can use. What sort of type is Draw?
Title: App.Draw
Post by: Laurent on January 21, 2010, 07:10:41 am
sf::RenderWindow cannot be copied (for obvious reasons), you must pass it by reference to your function.
Title: App.Draw
Post by: Jarwulf on January 22, 2010, 01:10:43 am
Quote from: "Laurent"
sf::RenderWindow cannot be copied (for obvious reasons), you must pass it by reference to your function.



Alright, I do that and I transfer responsibility for App.Draw to the objects themselves. so for


class obj
{


objaction(sf::RenderWindow& App)
{

App.Draw(Image);
App.Display

}


};


I get a flashing image. If I include App.Clear it gets even worse.
Title: App.Draw
Post by: Nexus on January 22, 2010, 01:13:59 am
Don't call Display() after each element drawn, but call it once per frame (after drawing everything). The same applies to Clear() which should be called before anything is drawn on the screen.
Title: App.Draw
Post by: Jarwulf on January 22, 2010, 01:16:45 am
nvrmind I think I figured it out