Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CsTilengine for version 2.9.5
#1
Hello all, my name is Simon. I'm a 23 year old aspiring software engineer. I'm mostly proficient in object oriented languages where I prefer to develop my applications in C#. Furthermore, I have a great passion for game development but I'm not a game designer or artist. So I mainly deal with the programming aspect of it.

With my background as a .NET developer, I wanted to use Tilengine's C# binding. However, I noticed that the binding was not up to date with version 2.9.5, so I thought it would be a fun challenge to write a binding that is an up to date 1:1 API translation of the original C version, with every piece of documentation I could find included as XML documentation tags.

Using the current version of CsTilengine as a base and the C# wrapper of SDL2 as inspiration, I finished the binding in almost four days of work. I also added most of the samples from the original version. However, I only had some problems getting the TLN_GetListObject() method to work correctly. So I excluded the port of the QueryLayer.c sample from this version of the binding.
 
You can find the source code of my binding here: https://github.com/vonhoff/CsTilengine
Any form of feedback is greatly appreciated  Smile
Reply
#2
Oh this is so nice! I didn't want to use the C# bindings because it used an old version of Tilengine. But now, this problem is fixed. By the way I suggest you to make a pull request to the official repos.
Reply
#3
(04-01-2022, 09:00 PM)System64 Wrote: Oh this is so nice! I didn't want to use the C# bindings because it used an old version of Tilengine. But now, this problem is fixed. By the way I suggest you to make a pull request to the official repos.

Thanks for your reply! I updated the binding from version 2.9.4 to 2.9.5 and added a few more samples before creating a pull request. It should be there now.
Reply
#4
(04-04-2022, 05:39 AM)vonhoff Wrote:
(04-01-2022, 09:00 PM)System64 Wrote: Oh this is so nice! I didn't want to use the C# bindings because it used an old version of Tilengine. But now, this problem is fixed. By the way I suggest you to make a pull request to the official repos.

Thanks for your reply! I updated the binding from version 2.9.4 to 2.9.5 and added a few more samples before creating a pull request. It should be there now.

Thank you. I'll have a look at this. I just have two questions.

Isn't it better to statically link the Tilengine Binding dll for performances?
Why not also using the familiar C# construction?
Reply
#5
It is not required to include the binding as a project dependency. However, it seemed inefficient to me to make a copy of the binding for each available sample project. So I decided to put the binding in its own project to avoid duplicate files. Moreover, there is no significant difference when it comes to performance. Class libraries are mainly used for separation and reuse of code and do not negatively affect performance in C#.

Before I discovered Tilengine to draw retro-style graphics, I experimented with the C# binding of SDL2. This library was written as a pure port of the C headers, I found it easy to implement existing method calls without first translating them into a separate model. However, when I switched to the C# binding of Tilengine, I missed this particular way of coding, since CsTilengine is class-based and not a pure port of the C headers. So I decided to make an alternative version of it, with a design strongly inspired by the design of the C# binding of SDL2.
Reply
#6
I agree. One main reason for using direct 1:1 bindings is reuse of documentation and existing knowledge of the orifinal API. With this model there is a single API for all languages, that makes it straightorward to reuse.

The other approach, using target language's own constructs as I did with the Python and C# bindings, feels more integrated and natural with the target language semantics. But it requires more work to maintain, a whole new documentation to write, and new knowledge that must be gained despite having experience with the original API.

So at the end, having a targeted binding is nice for the developers of the target language that don't know the original API but is a pain to maintain, whereas a 1:1 translation maybe is not so nice with the target language, but is straightforward to use and work with the existing resources.

Here i don't consider execution performance as both bidings use .NET P/Invoke facility to make calls to native library, where the main overhead is, so performance should be quite similar for both.
Reply
#7
Thank you! I was getting back into wanting to work on my engine built on Tilengine but I was dreading having to update the bindings to the newest version, you've saved my hours!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)