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

Author Topic: Strange error when passing a reference to sf::RenderTarget  (Read 1491 times)

0 Members and 1 Guest are viewing this topic.

pabloist

  • Newbie
  • *
  • Posts: 26
    • View Profile
Strange error when passing a reference to sf::RenderTarget
« on: March 23, 2011, 01:39:28 am »
I'm not really sure why I'm getting this error, since I've done this before in other programs. It happens when I attempt to call sf::RenderTarget.Draw(sf::Sprite) - it tells me that I'm attempting to call a pure virtual method.

Code: [Select]
void Draw(sf::RenderTarget& target)
{ target.Draw(sprite_); }


and then in a drawing loop, I'd have
Code: [Select]
// Window declaration
sf::RenderWindow App(/* construction */);

// Drawing loop
for (/* all objects */)
{ iter->Draw(App); }


Is there something wrong with what I'm doing? Or should I try posting more code? Will I be forced to use pointers to make sure the polymorphism kicks in? It's weird, since this has worked before...

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Strange error when passing a reference to sf::RenderTarget
« Reply #1 on: March 23, 2011, 08:56:14 am »
No, you don't need pointers since you use references.

Is the posted code the original one? What's the declaration of your container that iter is refering to? Seems like you're somewhat calling sf::Drawable::Draw() (indirectly) which calls sf::Drawable::Render(), and that's pure virtual.

I guess more (original?) code would be useful. Or even a minimal example to reproduce the problem.

pabloist

  • Newbie
  • *
  • Posts: 26
    • View Profile
Strange error when passing a reference to sf::RenderTarget
« Reply #2 on: March 24, 2011, 12:19:34 am »
EDIT: Nevermind! I realized that the objects that I was attempting to call Draw() from (that were stored in a container) were destructed before I managed to draw them. [/b]