GMS 2.3+ Does GMS2 only "draw" sprites, tiles, backgrounds, etc. when they are in the player's view?

Are sprites, tiles, background images, etc. only "drawn" by GMS2 when they are on screen and visible to the player? Or are there, in theory, performance efficiencies to be gained by, for example, manually telling GMS2 to draw only those tiles or portion of a background image surrounding/visible to the player?

Just curious how it works generally/in theory, not asking about any specific application.
 

FoxyOfJungle

Kazan Games
All tiles, sprites, etc. are drawn all at the same time. You must program something that does the opposite of that. (But personally I don’t think it is necessary in most cases, only for objects).
Evidences, using a special camera:



The only thing that undergoes optimization: backgrounds, if defined in the room itself, it draws a total of 2 images, so that they repeat themselves, if you add movement to them. They disappear as they are visible by the camera in the current view.
But in general, sprites, tiles, and other images are not as heavy (they are very light!). Worry about the amount of objects, collision checks and other things, like shaders present in the room, not sprites.
 
Last edited:
All tiles, sprites, etc. are drawn all at the same time. You must program something that does the opposite of that.
Evidences, using a special camera:



The only thing that undergoes optimization: backgrounds, if defined in the room itself, it draws a total of 2 images, so that they repeat themselves, if you add movement to them. They disappear as they are visible by the camera in the current view.
But in general, sprites, tiles, and other images are not as heavy (they are very light!). Worry about the amount of objects and collision checks present in the room, not sprites.
Perfect, thank you! (That's a sweet camera view you've got there.)
 

rytan451

Member
GPU dependent, but it should be slower to manually check position before drawing. Here's why:

The CPU submits a bunch of triangles to the GPU. These triangle make up the tiles, sprites, etc. that are being drawn to the screen. This is done sequentially; the vertex buffer is built up one vertex at a time. If you remove these triangles manually (culling them), then you're going to have to do O(n) more operations sequentially (where n is the number of vertices).

Then, the vertex buffer is passed to the GPU. The GPU works with the triangles. One of the most basic steps is view frustum culling: it just skips drawing all triangles that are completely outside of what would be visible. This also takes O(n) operations, but it's done in parallel, the amount of time taken is much less (O(n/s) where s is the number of simultaneous instructions that can be done; usually on the order of 1,000). Of course, not all GPUs do frustum culling, but most modern ones do.
 
Top