I am using the code from the
tutorial for my game's tilemap.
The tilemap of the test level of my game only has 17 * 20 tiles each 32x32 pixels (and I'm planning to add a whole lot more tiles) but the CPU usage goes to 25% when drawing the vertex array.
I call
drawTiles(*window); to draw it which is just a member function of the tilemap class. The function is
void TileMap::drawTiles(sf::RenderTarget &target) {
sf::RenderStates states = sf::RenderStates::Default;
states.transform *= getTransform();
states.texture = &tilesTexture_;
target.draw(tilesVertexArray_, states);
}
I used the Visual Studio Performance Wizard to see what's causing the heavy CPU usage, and it says it's the vertex array draw call.
Indeed, when I comment out the
drawTiles(*window); to no longer draw the tilemap, the CPU goes down to 0%, even with no framerate limit.
What am I doing wrong, please??