CGE 2D game development road

1、Choose a development engine

I found that CGE had 2D rendering performance problems a long time ago,I did not report this problem at the time, and transferred to the test of other engines. I tried almost all pascal engines

As we all know, there is not much choice for pascal game. I think there are only two options at present - SDL2 and CGE, other choices are not reliable.

If you choose SDL2 , it means to make all wheels yourself.

2、Use CGE’s distress

First ,I develop it in accordance with the official recommendation. Soon, I found that there is still a problem of rendering performance.

But, This time I took the initiative to report the problem. Get officially active feedback

I generally understand the problem now.

If you develop a simple 2D game, you can use the official recommendation method. The problem of poor rendering performance is not fully exposed.

If a complex 2D 'game is developed, Only the second way to use the official recommendation for the time being - Render using TDrawableImage by yourself

The 2D game I want to develop has three layers of Tile maps, there are a large number of small tiles need real -time rendering(Map similar to Diablo)

After simple testing, using TDrawableImage should be roughly satisfied.

But I found that almost all official cases did not use this method, There are very few descriptions in this way of official document.

Use TDrawableImage can meet the performance requirements, but how to combine other other UI, fonts(International text), etc. No example, no document(Disclaimer the way to give up).I want to use Label and other designed modules in the case of using TDrawableImage’s own rendering

Note that I just made another batch of optimizations to our Tiled rendering, Big improvements and optimizations for Tiled maps handling in TCastleScene – Castle Game Engine . I encourage to try it out. And please report more exactly – testcases you make, plans you have, lacks in current API. Then I can address it better :slight_smile: We’re not perfect, but I need a better description of the issues you have with current solution (ideally, a reproducible test program) to fix them :slight_smile:

As for drawing yourself: See:

Drawing using TDrawableImage is relatively trivial, it is really just loading and drawing a simple 2D image. You draw by overriding TCastleUserInterface.Render or TCastleUserInterface.RenderOverChildren methods and placing there various calls to draw things. This means:

That aren’t that many examples of using TDrawableImage because, as CGE high-level API gets more capable, the valid use-cases for TDrawableImage are more and more seldom :slight_smile: Whether you want to draw images in UI, or in viewport, 2D or 3D, or sprite sheets… all these cases are covered by better approaches now, and these new approaches also allow to design stuff in CGE editor. So TDrawableImage remains now mostly for “really special purposes when you have a valid reason to implement rendering using images yourself”.

Michalis’s work surprised me. In just two days, the performance improves huge.

Yesterday, examples/tiled/map_viewer/data/maps/desert_big.tmx tiled rendering incredibly faster (like 30x), Increase from 2.7FPS to 60FPS. Now, it had 600+FPS on my system(just downloaded version). Performance has increased by 220X (2.7FPS->600+FPS)

This makes me completely confidently developed in an officially recommended manner.

Congratulations on the improvement of CGE’s rapid advancement performance. Great work! I need more time to test, if there is a problem, I will bring test examples.

1 Like

Ha! Thank you for the good words!

“other choices are not reliable” - have you looked at ZenGL?

The engine I chose before is ZenGL,It is simple and efficient

I have a long time using Zengl.

Although ZenGL hasn’t been updated for ten years.

Although Delphi and FPC is constantly updating, ZenGL has always been able to run well

I used ZenGL :Camera、Keyboard and Mouse event management、Multi -threaded loading resources,Simple and efficient drawing API

The others are all to implement myself,Although tired, you can do whatever you want.

A few days ago, the Zengl official website couldn’t open it anymore

I encountered some incomplete places in ZenGL, for example UI part、unicode text conveniently etc,

It’s time to take a look at other choices. Write down these sadness.

More than ten years ago, I followed CGE, Compared with ZENGL, I prefer ZenGL. CGE is progressing huge on 3D, But I only focus on 2D Game development. CGE has too many convenience, and there are more restrictions. Many times I can only wait for the official update. I hope to do it myself.

some updates here GitHub - Seenkao/New-ZenGL: 2D OpenGL krossplatform - library (+ full OpenGL), it’s not from original author, but updating

To be clear, I hope in CGE to give you tools to deal with things in “lower level” when our “higher level” stuff is not enough.

For example, in How to render TCastleScene between two layers of Tiledmap? - #13 by michalis you found a problem with TCastleTiledMap, recorded as Tiled maps: Make it possible to render a character (any TCastleTransform) in a flexible way behind or in front of a layer with walls · Issue #440 · castle-engine/castle-engine · GitHub . I will fix it (though it is not trivial, so this one will not be done by tomorrow :slight_smile: )…

… but in the meantime you have the option to make drawing yourself.

As much as I wanted to encourage using ready rendering of TCastleTiledMap , I admit that Tiled maps: Make it possible to render a character (any TCastleTransform) in a flexible way behind or in front of a layer with walls · Issue #440 · castle-engine/castle-engine · GitHub shows it is unsuitable in some cases (when you want to have a layer with walls). I didn’t predict this problem.

But you still have the option to draw map yourself using TDrawableImage, using the information from TCastleTiledMapData. These structures don’t go anywhere, and TDrawableImage is optimal thanks to batching introduced last week. And you can take a look at src/scene/castletiledmap_control.inc ( castle-engine/src/scene/castletiledmap_control.inc at master · castle-engine/castle-engine · GitHub ), use this as a good starting point. If you insert character rendering in the middle of that code, than the walls will behave correctly.