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

Author Topic: Android and iOS ports available for testing  (Read 300158 times)

0 Members and 3 Guests are viewing this topic.

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android and iOS ports available for testing
« Reply #420 on: November 30, 2015, 02:37:10 pm »
At least not yet. You'll have to use the Asset Manager. However I don't have any snippet ready and I'm not sure whether there's NDK level access or whether you'd have to use the JNI to call Java stuff.

BlueCobold

  • Full Member
  • ***
  • Posts: 105
    • View Profile
Re: Android and iOS ports available for testing
« Reply #421 on: November 30, 2015, 02:51:20 pm »
Afaik there's no "native" way of getting the apk structure. The NDK doesn't offer any class or method for that. You could use a zip-lib (also provided by the NDK) to explore the archieve. Or use a Java-call.
The Asset-Manager and Asset-Dir classes in the NDK only provide access to a file you already know the path of.
I just did exactly that recently (unpack a multi-layer deep asset-folder from the APK), so I'm pretty sure that's the only way (Java or zip-lib). It's easy to find a native snippet of using the Asset Manager to unpack a known directory or file though. There's various samples.
« Last Edit: November 30, 2015, 02:56:25 pm by BlueCobold »

Zax37

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Android and iOS ports available for testing
« Reply #422 on: November 30, 2015, 07:43:35 pm »
Thank You both for Your answers :) I was looking at AssetManager examples before, but does even SFML give access to the required handles(JNIEnv* env, jobject clazz --- if that's even required or I did not understand the examples)?

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android and iOS ports available for testing
« Reply #423 on: November 30, 2015, 07:55:20 pm »
Check the test branch I've mentioned on last page. It has a new function that will expose the native handle. Check the included Android example for JNI interaction (that function is still WIP though).

BlueCobold

  • Full Member
  • ***
  • Posts: 105
    • View Profile
Re: Android and iOS ports available for testing
« Reply #424 on: November 30, 2015, 08:35:56 pm »
Jup, I'm using the branch Mario mentioned to grab the AssetManager and extract my files.

Zax37

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Android and iOS ports available for testing
« Reply #425 on: December 04, 2015, 05:27:48 pm »
Another thing - sf::Vertex seems to be not rendering on Android. Is that a known bug?

BlueCobold

  • Full Member
  • ***
  • Posts: 105
    • View Profile
Re: Android and iOS ports available for testing
« Reply #426 on: December 04, 2015, 05:30:56 pm »
Does this work on other platforms? Because I'd say a Vertex itself isn't actually drawable.

Zax37

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Android and iOS ports available for testing
« Reply #427 on: December 04, 2015, 05:39:56 pm »
Sure,

Quote
window.draw(rectangle, 4, sf::Quads);

this works on windows but does not on android.

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android and iOS ports available for testing
« Reply #428 on: December 04, 2015, 06:04:43 pm »
Android uses OpenGL ES and OpenGL ES doesn't understand quads (which will silently fail at the moment). As a workaround, use some other primitive type.

Zax37

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Android and iOS ports available for testing
« Reply #429 on: December 05, 2015, 01:04:18 pm »
Thanks, that solved it :) Getting string from resources is also not possible directly through SFML right now?

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android and iOS ports available for testing
« Reply #430 on: December 05, 2015, 01:12:31 pm »
You should be able to use SFML's InputStream for that, which I think is wrapped to the asset manager.

Zax37

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Android and iOS ports available for testing
« Reply #431 on: December 05, 2015, 10:27:25 pm »
Well, no, I think You're mistaking assets with resources now :) I'm not too familiar with whole android apk structure, but as far as I understood, strings get compiled with other resources description to resources.arsc and when You're creating a "standard" android apk You simply use @string/app_name to get app_name string, depending on user's language. It could be a neat feature for SFML(if that's even possible through native functions).

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android and iOS ports available for testing
« Reply #432 on: December 05, 2015, 10:58:05 pm »
Ah ok, I thought you'd like to read strings from a text file. Reading string resources isn't exposed and you'd have to write the code for that yourself.

Kori

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Android and iOS ports available for testing
« Reply #433 on: December 27, 2015, 12:07:00 am »
img.saveToFile("file.png");

not working for me. In LogCat is wrote "failed to save image". I am testing it on android.
If someone have time, pleas check it, because i don't know that this is my mistake or sfml bug.

Zax37

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Android and iOS ports available for testing
« Reply #434 on: December 29, 2015, 05:03:01 pm »
Maybe You don't have permissions to write to that file? Try that:

<manifest ...>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    ...
</manifest>