DefOS - Extra native OS functions

#7

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

#8

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?

0 Likes

#9

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

Really? Why?

0 Likes

#10

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

#11

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

#12

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

How to launch a game with maximized window
#13

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

#14

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

3 Likes

#15

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

0 Likes

#16

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

5 Likes

#17

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

2 Likes

#18

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

#19

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

#20

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

0 Likes

#21

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.

0 Likes

#22

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

#24

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?

0 Likes

#25

Yes, but you need to share the build error.

0 Likes

#26

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

#27

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.

0 Likes