Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sfml for android(already started on)  (Read 4073 times)

0 Members and 1 Guest are viewing this topic.

greeniekin

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
sfml for android(already started on)
« on: August 04, 2012, 12:24:48 pm »
I have started working towards getting sfml on android by using the ndk.

I have built a cmake tool-chain that compiles for android and tested it with android.(only tested this through windows)

I have also made something similar to SFML_Main for android. As there is no main function in android to try and replicate it. While ndk works by java making natives calls which would mean the calls could be whatever you want and not having a standard way to make a native activity. Fortunately android has an existing activity called nativeActivity(http://developer.android.com/reference/android/app/NativeActivity.html) which exposes the core functions called during the life cycle of an android activity. Which is what SFML_Main uses.

This is kind of where it goes all to hell. An activity is already a window that calls native code. Which makes the structure of sfml with creating a window after code has started a bit useless. Including all the events and things related to that.



A way around  to have code that  does net need any modifications when using pure sfml between platforms would be to have my sfml_main  store away information about the activity that is needed by the window. Then whenever sfml window is created it could grab all this information. You could then send the activities events through the windows including onPause and all that.

Down side is you would be required to use sfml with sfml main and will not be able to use it with your own custom java front and not using NativeActivity. Which realistically probably isn't that likely.

So I have no idea what the goal should be. And my head is hurting from fighting with cmake ><.

Any suggestions or help would be appreciated. Especially a word from Laurent.


« Last Edit: August 04, 2012, 12:26:20 pm by greeniekin »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sfml for android(already started on)
« Reply #1 on: August 04, 2012, 02:18:57 pm »
Porting SFML to mobile platforms is a complex task. It requires more than just making the current API work on these platforms. That's why I always answer the same thing: don't bother trying to port SFML, it first requires major design modifications.

Windows and events are the most critical parts in my opinion. I have no solution yet because I haven't thought about it.

Sorry I cannot help more :-\
Laurent Gomila - SFML developer

greeniekin

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: sfml for android(already started on)
« Reply #2 on: August 04, 2012, 03:34:53 pm »
Your very right. I didn't expect to come up with a perfect design and have it integrated into sfml 2(I know all public api is in lock down until it's release and that is the least of the issues). This was going to be me plodding a long by myself. With the potential best scenario that the tool-chain and adding support for gles might be a little helpful.

The worst that will happen is it will be a great example of what you should not do.

Considering it is for just for me and I do not plan to use sfml on top of anything else. I may just go with a nativeActivity  handler that gets the activities information and holds it for you until you construct your window.

It's a bit messy. but it allows me to use it for all my uses.

It would be an easier issue to solve if this were just a gaming engine. As you could assume there will always be an window available before hand.

Though I prefer SFML as it is. It means I can create a server app if needed with no gui just to help with NAT punch through(not for android of course).

Also I'm not planning to get it all converted in a month. If i can just get system,window and graphics working in some form by new year I would be pretty happy.
« Last Edit: August 04, 2012, 03:45:27 pm by greeniekin »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: sfml for android(already started on)
« Reply #3 on: August 04, 2012, 03:45:49 pm »
If you need some more insight on the development for Android, maybe you could take a look at DevilWithin's Parabola Engine. Afaik it's not a port of SFML, but was inspired by SFML. ;)
Also I'm sure DevilWithin is willing to give you some hints if you ask nicely. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

greeniekin

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: sfml for android(already started on)
« Reply #4 on: August 05, 2012, 07:13:58 am »

Thanks eXpl0it3r. I will look at it more closely the most interesting thing about his tree is it looks like he can generate an apk in there.
So far I have been generating a shared library and manually copy pasting it into an existing android project before generating the apk.

 

anything