1
Graphics / Hundreds of tiles on a grid, slow draw.
« on: April 20, 2012, 02:37:06 am »
Hello everyone.
I have been having issues getting a game to run fast enough using this library. It's a simple issue with displaying many objects on the screen.
A tile-based game grid is used, and the screen contains roughly 20x30 of these tiles, possibly with several layers. The total number of tiles being drawn eventually is roughly 600 or so.
For this test, however, I used a 15x20 window and only one layer (300 tiles).
There are a few other sprites present that are not tiles.
Frame rendering time, according to RenderWindow's myLastFrameTime, is about 0.04 seconds.
A part of the code can be seen here:
When the draw code (and only the draw code) is commented out, myLastFrameTime is decreased to 0.004 seconds.
I am using SFML 1.6 with dlls. OS is Windows 7. Graphics card is ATI Mobility Radeon HD 4200 Series. I used debug mode, but got about the same speeds when starting without debugging too.
I have heard that upgrading to 2.0 will help, but I am wondering if there are any ways that I can make this more efficient outside of that, if I am doing anything wrong, or if something is not functioning properly. Its just odd to me that display slows down under 60 FPS at 300 tiles, as that seems like a tame number of objects to render.
I have been having issues getting a game to run fast enough using this library. It's a simple issue with displaying many objects on the screen.
A tile-based game grid is used, and the screen contains roughly 20x30 of these tiles, possibly with several layers. The total number of tiles being drawn eventually is roughly 600 or so.
For this test, however, I used a 15x20 window and only one layer (300 tiles).
There are a few other sprites present that are not tiles.
Frame rendering time, according to RenderWindow's myLastFrameTime, is about 0.04 seconds.
A part of the code can be seen here:
//draw tiles
for (int j = 0; j < arrayY; j++) {
for (int i = 0; i < arrayX; i++) {
//draw tile
window->Draw(groundTileArray[i][j]);
}
}
for (int j = 0; j < arrayY; j++) {
for (int i = 0; i < arrayX; i++) {
//draw tile
window->Draw(groundTileArray[i][j]);
}
}
When the draw code (and only the draw code) is commented out, myLastFrameTime is decreased to 0.004 seconds.
I am using SFML 1.6 with dlls. OS is Windows 7. Graphics card is ATI Mobility Radeon HD 4200 Series. I used debug mode, but got about the same speeds when starting without debugging too.
I have heard that upgrading to 2.0 will help, but I am wondering if there are any ways that I can make this more efficient outside of that, if I am doing anything wrong, or if something is not functioning properly. Its just odd to me that display slows down under 60 FPS at 300 tiles, as that seems like a tame number of objects to render.