Jump to content
  • Advertisement
Sign in to follow this  
d4rkmage

Can someone explain how bindings work exactly?

This topic is 1933 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm mainly interested in Lua so for this thread I'll explain in Lua. If SDL, C++ and such have Lua bindings, What's the difference between using a Lua game engine compared to using a Lua binding? What is a binding even I don't quite understand. Are game engines that use Lua, in a way, just Lua bindings that have extra features developed on top of the, like IDE's and Deployment tools etc? Am I getting this all wrong? Can someone please explain in retard mode because I think I've been reading the wrong stuff or I'm mentally ill because I'm really confused atm. Thanks a lot for any help

Share this post


Link to post
Share on other sites
Advertisement

When people say "binding" in this way they mean that the library has a wrapper that exposes library functionality in the bound language. For example, SFML is written entirely in C++, which means that users would need to be able to read and code in C++ to use it. However, it also has bindings that let users access SFML's features through language-specific interfaces. I code in C#, so I use the C# binding and use SFML just like it was written in C# instead. If you like Lua, you can use the Lua binding.

 

Does that help?

Share this post


Link to post
Share on other sites

Not exactly tongue.png

 

What I mean is, so I don't even know any type of C but as far as I've heard, you can go in visual studio, code in C# and then build? So if you add a Lua binding to it, can I go in visual studio, go to lua.org and use the api to start coding in Lua? If that's true, and I feel like it's not that easy, then that's why I was asking about what's different between binding and game engine, besides IDE's and building tools or whatever they have bonus. I dont know if I'm getting my question across properly, sorry =(

Share this post


Link to post
Share on other sites

Lua's internal working is different than C or C++'s internal working, so for you to call a C++ function from Lua, you have to "bind" the function. Binding means to create a Lua function that wraps around the C++ function, so the C++ function can be called from Lua.

 

Game Engines that use Lua mean they are engines that bind certain of the game functions to Lua, so you can access then engine's features from within Lua.

Game Engines don't have to have IDEs. Some game engines do, but not all of them.

 

The game engines are usually written in C++ or C# or C, or some other language. They either expose some engine functions so Lua can be used as script files, and it mostly goes:

[engine does most of the logic] [engine needs to call user script to customize the logic] [engine -> lua -> user script]

 

...or they provide a complete interface of the engine, so the game logic is written in the scripting language.

[script does most the logic] [script needs to call engine function to do some heavy lifting] [userscript -> lua -> engine function]

 

Binding, in this context, means making one language (like Lua) talk to another language (like C++).

Share this post


Link to post
Share on other sites

I was typing a new attempt, but Servant's is much better than what I was writing.

Share this post


Link to post
Share on other sites

The game engines are usually written in C++ or C# or C, or some other language.

Whilst I don't really know of any games engines written entirely in C#, it is a classic example of a language that has bindings created so it can interact with other (usually native) languages.

For example, monogame can use OpenGL via the C# bindings (OpenTk) and then MonoGame is an XNA replica wrapping the OpenTk framework.

 

Then again, an engine made in C++ (such as Unreal) is effectively just (admittedly very fat) bindings to C and OpenGL / DirectX ;) (Though DirectX does have C++ elements in it natively)

 

I personally find writing bindings very time consuming and fiddly and for the last project we developed a way to simply inline Android Java into C++ so we could use functionality only exposed by Java without spending time on writing actual bindings.

(Very similar to this one to inline Javascript into C++ -> http://www.mutiny3d.org/doku.php?id=iffe)

Edited by Karsten_

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!