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

Author Topic: App.Draw  (Read 4281 times)

0 Members and 1 Guest are viewing this topic.

Jarwulf

  • Newbie
  • *
  • Posts: 37
    • View Profile
App.Draw
« 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?

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
App.Draw
« Reply #1 on: January 21, 2010, 03:19:27 am »
Detail about your errors please.

Jarwulf

  • Newbie
  • *
  • Posts: 37
    • View Profile
App.Draw
« Reply #2 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
App.Draw
« Reply #3 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.
Laurent Gomila - SFML developer

Jarwulf

  • Newbie
  • *
  • Posts: 37
    • View Profile
App.Draw
« Reply #4 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.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
App.Draw
« Reply #5 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Jarwulf

  • Newbie
  • *
  • Posts: 37
    • View Profile
App.Draw
« Reply #6 on: January 22, 2010, 01:16:45 am »
nvrmind I think I figured it out