1
Graphics / How does draw work?
« on: July 08, 2015, 05:55:06 pm »
I'm new to programming in general and so I don't really understand a lot of things but I've been working on a general star background generator and came up with a method that works nicely. The problem I have is that a lot of stars seems to slow it down greatly. A lot of stars being around 30,000 or more. Seeing as there are much more complex and numbered textures in video games I feel like this should be easy for a modern computer. I tried commenting out various parts of the code and narrowed it down specifically to the draw call. At first I thought maybe my stars vector was copying instead of passing by references, but I tried to change it specifically to references and got it working but that didn't make it any faster. I'm only using a small png with a few star shapes for a template and only load it once and just apply it to multiple sprites so I didn't think the resource itself should be slowing it down since it's just one reference used multiple times. Am I missing something important in how draw works? Thanks for any help, tips, etc!
The short: How does draw work and why is it slow when redrawing from a single resource reference of a small png? Is it just a limitation for the number of draws it can do efficiently or am I just probably doing something wrong?
void Stars::render(sf::RenderWindow *temp)
{
for(size_t i=0;i<starsVec.size();i++)
{
temp->draw(starsVec);
}
}
The short: How does draw work and why is it slow when redrawing from a single resource reference of a small png? Is it just a limitation for the number of draws it can do efficiently or am I just probably doing something wrong?
void Stars::render(sf::RenderWindow *temp)
{
for(size_t i=0;i<starsVec.size();i++)
{
temp->draw(starsVec);
}
}