Cameras, draw calls, and SFML View
In all our previous projects, all the entities in our games (with one exception) were graphically represented with a sprite. This is fine when there are only a few, a few dozen, or even a few hundred entities being drawn. It is important because the speed that SFML can draw each frame of our game has a direct relationship to the number of times we call window.draw
. This is not an SFML flaw but is directly connected to how OpenGL uses the graphics card.
The reason is that each time we call draw, quite a lot happens behind the scenes to set up OpenGL so that it is ready to draw. To quote the SFML website,
“…each call [to draw] involves setting a set of OpenGL states, resetting matrices, changing textures, etc. All of this is required even when simply drawing two triangles (a sprite).”
So, using a vertex array and rendering multiple images with one draw call to do our drawing, whenever possible, is a very...