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

Author Topic: How to draw multiple objects at once  (Read 2769 times)

0 Members and 1 Guest are viewing this topic.

Republican31

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
How to draw multiple objects at once
« on: September 07, 2015, 08:00:52 am »
Hi! I am not sure if this is the right package or not, but I am just wondering how to draw multiple objects at once. For example:

Starting with:
mainWindow.draw(thing1);

Is there a way to do something like this:
mainWindow.draw(thing1, thing2);
So that I don't have to make a .draw for every object?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: How to draw multiple objects at once
« Reply #1 on: September 07, 2015, 08:26:11 am »
Use a loop.

Say you have all your 'thing's in a vector:
std::vector<thing> myThings;
Then you'd iterate over the container and draw them all like so:
for (const auto& thing : myThings) {
    mainWindow.draw(thing);
}