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

Author Topic: Drawing to render window freezes  (Read 1195 times)

0 Members and 1 Guest are viewing this topic.

Gleade

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Drawing to render window freezes
« on: February 20, 2015, 09:50:22 am »
Hello, I have two classes:
Object
ObjectManager

I store all of my objects inside the ObjectManager class with a vector. I update all objects in one function which works perfectly. But when it comes to drawing them all in another function the game freezes. I even tried getting the object to just draw a RectangleShape & it still freezes. But when I comment out the draw function inside the object itself it is fine. So I think it might have to do with drawing to the window?

Here is my draw code for the object manager:

mWindow:
sf::RenderWindow                *mWindow;

void ObjectManager::draw()
{
        // Draw all of our drawable objects
        for (std::vector<Object*>::iterator it = objectList.begin(); it != objectList.end(); ++it)
        {
                (*it)->draw(mWindow);

        }
}
 

Here is the function above it that updates the objects (and it works):

void ObjectManager::draw()
{
void ObjectManager::update(sf::Time &delta)
{
        // Update all of our objects on the list
        for (std::vector<Object*>::iterator it = objectList.begin(); it != objectList.end(); ++it)
        {
                (*it)->update(delta);
                std::cout << "draw" << std::endl;
        }

        // Set there draw priority by depth
        std::sort(objectList.begin(), objectList.end(), sortByDepth);
}
 

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Drawing to render window freezes
« Reply #1 on: February 20, 2015, 09:53:41 am »
What you're showing is that you're iterating on your objects and calling some function on them. Nobody can help you with that. You must provide a complete and minimal code that reproduces the problem.
Laurent Gomila - SFML developer

 

anything