DefOS - Extra native OS functions

I’ll help make a practical use tutorial later if there is no tutorial later. We still need to wait until all targets get Native Extensions support. I was personally waiting on that to really use it. Sounds like it’s happening within next few weeks!

For majority of users, you will probably never develop your own Native Extensions and instead use the generic ones already made, because majority of a game can be accomplished without them, and there are only so many reasons most devs would want extra features such as implementing 3rd party 3dks for ads or using target os api /hardware features which are not already implemented in vanilla Defold engine.

4 Likes

Got sick Friday and kind of killed my productivity. I did still spend a few hours today reading X11 docs for Linux. I think after figuring out a few issues the rest should be easy. Main issue right now is how to get the application’s Window… I can think of some hacky ways of doing it but not what seems the right way. Linux doesn’t have Native Extensions support yet, right? Might be better to wait until it does because then I can use dmGraphics::GetNativeX11Window and it’s easy.

Edit: can’t use ffi on Linux anyway so have to wait for sure?

Yes, not long now. I’ll check with Sven and Mathias to confirm when.

Really? Why?

If I do

```local ffi = package.preload.ffi()`

on Linux it will give error

attempt to call field ffi (a nil value)

I think same error happens on macOS right now too?

1 Like

New methods was added to the library :smirk_cat: :

defos.set_window_title("I set this title using Defos")
defos.toggle_fullscreen()
defos.is_fullscreen()
3 Likes

Few more new methods:

	defos.toggle_maximize()
	defos.is_maximized()

And new example:

UPD: Thanks @britzl !!! defos.is_maximize() was replaced with defos.is_maximized(). Screenshot and readme was updated too.

5 Likes

Wow, this extension is really developing into something super useful for those devs creating desktop games using Defold! Well done!

I pushed a fix to a typo and also added an FFI check and defaulting to the native extension if it exists.

Should it perhaps be defos.is_maximized() with a ‘d’?

5 Likes

I think you right!
I’ll fix it right now. And thanks for your fixes!!!

3 Likes

Hey guys, what’s the status with DefOS, now that Native Extensions work on Windows?

It needs work but I’m giving attention to other projects first right now. Which features do you need?

5 Likes

Yeah, no rush, I’m mostly just curious at the moment. Toggling fullscreen and the mouse cursor would fill my needs.

2 Likes

Good to know that somebody want to use extension. Unfortunately I have no Windows PC to remake DefOS like an extension for Windows, but I’ll try to come up with something.

2 Likes

Yeah, I think it’s a great extension! It’s pretty necessary for a professional desktop game.

So the Lua FFI module works perfectly on windows (why I doubted I don’t know). Is that not available on Linux? I guess it will be nice when Linux Native Extensions are released and you can use the same approach for all three.

Again, I’m not trying to nag at all, just checking out possibilities for my next project.

1 Like

Tried to compile example project from github and got the build error:

PC, win10
what’s wrong?

UPD: Solved by renaming/removing ext.manifest/NE

Pretty sure FFI isn’t available on Linux. I think I tested a few months ago and it wasn’t supported. It doesn’t work on Mac either.

FFI and LuaJIT are available on all platforms except html 5 and arm64. But there’s some kind of problem when building (not bundling) from editor 2.

2 Likes

Hi all.

I try bundling DefOS with Native Extension(for use on macOS) and receieve build error. Anyone can help?

Or maybe I can make FFI variant for macOS?

Yes, but you need to share the build error.

I can probably do this during next week. It would be great to get rid of the FFI stuff and only ship it as a native extension.

3 Likes

Ok. I show error later.

And thank you for make Native Extension for Windows. Or say what need to do for Windows. I try make it.