CGE 2D render too slow

  1. See Optimization and profiling | Manual | Castle Game Engine for notes how to compare FPS.

  2. If you really want to compare full FPS, disregaring the fact that some frames drawn were never actually displayed, be sure to set ApplicationProperties.LimitFPS to 0, otherwise CGE limits them to 0.

  3. That being said, our Tiled drawing performance indeed can suck for larger maps. This is a larger TODO. The plan is to:

    • Advise loading Tiled maps to TCastleScene

    • Make DynamicBatching include more cases, such that Tiled maps in TCastleScene get more optimized.

    But that’s a larger work inside CGE.

    There is no perfect solution right now that is easy. Some solutions:

    A. You can “bake” a static map layers into big images, and rendering them as big images underneath TCastleTiledMapControl.

    B. Or you can implement your own map rendering using TDrawableImage.Draw with batching.

    Both A and B of course are far from optimal, as they mean you’re not really “just loading Tiled map into TCastleTiledMapControl and that’s it”.

    I’m sure that with B, you can achieve the same speed as with ZenGL, as underneath these are really just simple OpenGL calls. As Eugene notes, ZenGL likely does batching as lower level, while our TDrawableImage.Draw does not do automatic batching, you need to pass yourself an array of images to draw to one TDrawableImage.Draw. In CGE, batching is done for TCastleScene shapes.