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

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

0 Members and 1 Guest are viewing this topic.

XeRaCKeR

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: Android and iOS ports available for testing
« Reply #240 on: July 09, 2014, 12:29:20 am »
https://github.com/SFML/SFML/wiki/Building-SFML-for-Android

To write some actual app, have a look at the Android example.

Yes, I followed this guide, but how to compile?

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Android and iOS ports available for testing
« Reply #241 on: July 09, 2014, 08:01:05 am »
That guide uses CMake, so you tell it what compiler you want and it will generate the appropriate makefile/project file/whatever which you then use to do the actual compilation in whatever way is normal for your compiler.  It even gives the example that on Linux the actual compilation would be make && sudo make install.  For something like Visual Studio obviously you would open the project file and then tell VS to build the project.  Reading the official CMake tutorial might help: http://www.sfml-dev.org/tutorials/2.1/compile-with-cmake.php

XeRaCKeR

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: Android and iOS ports available for testing
« Reply #242 on: July 09, 2014, 08:05:39 am »
That guide uses CMake, so you tell it what compiler you want and it will generate the appropriate makefile/project file/whatever which you then use to do the actual compilation in whatever way is normal for your compiler.  It even gives the example that on Linux the actual compilation would be make && sudo make install.  For something like Visual Studio obviously you would open the project file and then tell VS to build the project.  Reading the official CMake tutorial might help: http://www.sfml-dev.org/tutorials/2.1/compile-with-cmake.php

I already compiled/built SFML with CMAKE, I mean how to compile my code for android apps to .apk? how to create a project, in code::blocks, for example.

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #243 on: July 09, 2014, 09:46:12 am »
how to create a project, in code::blocks, for example.
Well, i'm working on it now. I have no results yet, but i have several thoughts. By the first i copied XML where ARM compiler declared. Then i'll adapt it for NDK toolchain - it's not problem for one single computer. After building source C::B will run afterbuild script which will create APK. So, it looks pretty simple and at least possible. But my main target is debugging code with C::B and i don't know how to do it yet, but think it possible too.

Sonkun

  • Full Member
  • ***
  • Posts: 241
    • View Profile
Re: Android and iOS ports available for testing
« Reply #244 on: July 09, 2014, 06:34:32 pm »
Quickly:
Compile SFML using CMake, it should look like this:
Quote
export ANDROID_NDK=/path/to/ndk
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/android.toolchain.cmake -DANDROID_ABI=armeabi ..
make
make install

The last command, make install, will install everything in your NDK (headers, libraries, bootstrap).

From now, just create a regular native Android project (actually, just copy and adjust the example provided in SFML source, it'll be easier), compile and run. Refer to the example to write your app Android.mk and Application.mk scripts. It should look like this:

cd path/to/your/android-project
$ANDROID_NDK/ndk-build  # this line compiles your project)

Then press the run button from your IDE.
Interested in using SFML with Python ? Try out its Python binding!

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: Android and iOS ports available for testing
« Reply #245 on: July 12, 2014, 08:53:13 am »
cd path/to/your/android-project
$ANDROID_NDK/ndk-build  # this line compiles your project)

Then press the run button from your IDE.


Why not just adding native support to your project (Right-click on project -> Android tools -> Add Native Support) and let eclipse compile your project?

Another advantage, you will have code completion and eclipse will report c++ errors too.


AlexAUT

nero81af

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Re: Android and iOS ports available for testing
« Reply #246 on: July 22, 2014, 10:00:58 am »
Just a quick question: is there a way to obtain the native activity outside sfml? I need access to obbpath and assetmanager to extract game data! :D Maybe it would be nice to obtain it from getSystemHandle instead of the native window!

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android and iOS ports available for testing
« Reply #247 on: July 22, 2014, 10:43:24 am »
Not yet.

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #248 on: August 08, 2014, 08:39:59 pm »
Anyone tried new NDK10? I wonder why $NDK/platforms is empty except "android-L". cmake can't configure make files without "android-9", i copied it, just for test, from previous NDK and cmake configured make files successfully. But, as expected, there were problems with linkage.

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android and iOS ports available for testing
« Reply #249 on: August 08, 2014, 09:15:20 pm »
Just updating and my Platforms folder has all the previous versions. Are you sure you downloaded the correct package? (Windows x64 here)

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #250 on: August 08, 2014, 09:22:51 pm »
I'm using Ubuntu for building for android.  :o Well, i think i can copy these files from Windows package.
upd: Yes, i'd downloaded wrong package. There are new target now - arm64.
« Last Edit: August 08, 2014, 09:25:55 pm by ChronicRat »

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #251 on: August 10, 2014, 05:09:01 pm »
I can share some hacks for my games. Currently it placed in System/Err.hpp and System/Err.cpp

#if defined(SFML_SYSTEM_ANDROID)

#include <string>

class AAsset;
class ANativeActivity;

namespace sf
{


SFML_SYSTEM_API AAsset* GetAsset(const std::string& filename); // for reading files from the Assets
SFML_SYSTEM_API ANativeActivity* GetActivity(); // not used yet
SFML_SYSTEM_API std::string GetLanguage(); // return something like "En_en"
SFML_SYSTEM_API std::string GetInternalDataPath();  // you know what is it =)
SFML_SYSTEM_API std::string GetExternalDataPath(); // and it


} // namespace sf

#endif

#if defined(SFML_SYSTEM_ANDROID)

namespace sf
{

AAsset* GetAsset(const std::string& filename)
{
        priv::ActivityStates* states = priv::getActivity(NULL);
        Lock(states->mutex);
        return AAssetManager_open(states->activity->assetManager, filename.c_str(), AASSET_MODE_UNKNOWN);
}



ANativeActivity* GetActivity()
{
        priv::ActivityStates* states = priv::getActivity(NULL);
        Lock(states->mutex);
        return states->activity;
}



std::string GetLanguage()
{
        priv::ActivityStates* states = priv::getActivity(NULL);
        Lock(states->mutex);
        char lng[3] = { 0 };
        AConfiguration_getLanguage(states->config, lng);
        return std::string(lng);
}



std::string GetInternalDataPath()
{
        priv::ActivityStates* states = priv::getActivity(NULL);
        Lock(states->mutex);
        const char* path = states->activity->internalDataPath;
        return path ? std::string(path) : "";
}



std::string GetExternalDataPath()
{
        priv::ActivityStates* states = priv::getActivity(NULL);
        Lock(states->mutex);
        const char* path = states->activity->externalDataPath;
        return path ? std::string(path) : "";
}

} // namespace sf
#endif

These things are necessary! I don't know how to say it in english... That functional MUST BE provided by SFML.

By the way, i'm using C::B to build  game, and now i'm trying to debug via C::B.
« Last Edit: August 10, 2014, 05:23:43 pm by ChronicRat »

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android and iOS ports available for testing
« Reply #252 on: August 10, 2014, 06:37:10 pm »
I've noticed the same limitation last week, but the whole asset loading is already there, just not exposed. I thought about adding something like sf::String::loadFromFile(). It should still be able to read binary files as well. And most important: The code should work cross-platform. :)

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #253 on: August 10, 2014, 06:44:19 pm »
I'm using my own ResourceManager, where 99% of files are loaded via sf::InputStream interface. It pretty good to universal reading of data from files or archives and my Lua's "require" is modified to use it, so i need full access to Assets. And I'm not using ::loadFromFile at all.  Now i'm using assets just once, when app runs first time it copies game's data files from Assets to app's data dir. To be honest, there are only one "data files" - resource.pak.
By the way, is "orientation" works now? I updated master branch to last state and Android's screen now is vertical only.
« Last Edit: August 10, 2014, 06:47:07 pm by ChronicRat »

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android and iOS ports available for testing
« Reply #254 on: August 10, 2014, 08:09:47 pm »
It should work just fine (triggers resize events). Just check the example app.

 

anything