Home - nicobabot/Multi-cameraculling GitHub Wiki
Multi-camera culling Research
Introduction to camera culling:
- The camera culling is a code optimization, that in the moment we render on the screen, all the elements that are out of the camera aren't printed.
- In our case, multi-camera culling, our objective will be achieving that optimization for when we have more than one camera.
Things to take in account before going into coding:
-
Cámara: (iPoint/SDL_Rect) it tell us the point/proportion of the map that we want to show (coordinates are respect the MAP).
-
Viewport: (SDL_Rect) it tell us wich portion of the screen we want to show when we render. (coordinates are respect the SCREEN).
-
The viewport doesn't prevent the things to be out if his rect to be rendered, only doesn't show it to you (Bliting still consuming resources).
-
In our code the axis of positioning is:
-In the case of the cameras is:
Steps to follow for testing the camera culling.
- Create 2 or more cameras.
- Create a viewport for each one.
- Adapt your Blit function a way that discards all the elements that are out of the camera when printing.
- In the case you are using a map created with tiles, adapt aswell the function that draws all the tiles (exclude all the calculations for the tiles outside the camera).
- With a timer or simply observing the dt, compare the final result with the initial one.