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

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

0 Members and 3 Guests are viewing this topic.

nero81af

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Re: Android and iOS ports available for testing
« Reply #165 on: April 22, 2014, 05:05:58 pm »
I'd like to submit here some patches I had to put in sfml in order to build ogre with sfml on android ios macos linux and windows with gl3plus renderer and gles2 renderer and mingw64 compiler. Some patches allow the creation of a es2.0 / 3.0 context.. not sure those are useful tho since sfml is working with gles 1.0 only.. anyway here they are (those patches should not broke actual build)

SFML/Window/EglContext.cpp: line 197.

    //const EGLint contextVersion[] = {
    //    EGL_CONTEXT_CLIENT_VERSION, 1,
    //    EGL_NONE
    //};
    //
    //EGLContext toShared;
    //
    //if (shared)
    //    toShared = shared->m_context;
    //else
    //    toShared = EGL_NO_CONTEXT;
    EGLint renderable;
    EGLint client_version;

    eglGetConfigAttrib(m_display,m_config,EGL_RENDERABLE_TYPE,&renderable);

    if(renderable == EGL_OPENGL_ES_BIT)
    {
        client_version = 1;
    }
    else if(renderable == EGL_OPENGL_ES2_BIT)
    {
        client_version = 2;
    }

    const EGLint contextVersion[] = {
        EGL_CONTEXT_CLIENT_VERSION, client_version,
        EGL_NONE
    };

    EGLContext toShared;

    if (shared && (client_version != 2))
        toShared = shared->m_context;
    else
        toShared = EGL_NO_CONTEXT;

SFML/Window/EglContext.cpp: line 260.

    // Set our video settings constraint
    //const EGLint attributes[] = {
    //    EGL_BUFFER_SIZE, bitsPerPixel,
    //    EGL_DEPTH_SIZE, settings.depthBits,
    //    EGL_STENCIL_SIZE, settings.stencilBits,
    //    EGL_SAMPLE_BUFFERS, settings.antialiasingLevel,
    //    EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
    //    EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
    //    EGL_NONE
    //};
    EGLint renderable;

    if(settings.majorVersion == 1)
    {
        renderable = EGL_OPENGL_ES_BIT;
    }
    else if(settings.majorVersion == 2)
    {
        renderable = EGL_OPENGL_ES2_BIT;
    }

    const EGLint attributes[] = {
        EGL_BUFFER_SIZE, bitsPerPixel,
        EGL_DEPTH_SIZE, settings.depthBits,
        EGL_STENCIL_SIZE, settings.stencilBits,
        EGL_SAMPLE_BUFFERS, ((settings.antialiasingLevel > 0) ? 1 : 0),
        EGL_SAMPLES, settings.antialiasingLevel,
        EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
        EGL_RENDERABLE_TYPE, renderable,
        EGL_NONE
    };

SFML/Window/Android/WindowImplAndroid.cpp: line 520.

    //case AKEYCODE_DEL                : return Keyboard::Delete;
    case AKEYCODE_DEL                : return Keyboard::BackSpace;
 
SFML/Window/Android/WindowImplAndroid.cpp: line 614.

    if(action == AKEY_EVENT_ACTION_UP)
    {
       unicode = 0;
    }

SFML/Window/iOS/SFAppDelegate.mm: line 269.

    if(character == '\b')
    {
        sf::Event event;
        event.type = sf::Event::KeyPressed;
        event.key.code = sf::Keyboard::BackSpace;
        event.key.alt = false;
        event.key.control = false;
        event.key.shift = false;
        sfWindow->pushEvent(event);
    }
    else if(character == '\n')
    {
        sf::Event event;
        event.type = sf::Event::KeyPressed;
        event.key.code = sf::Keyboard::Return;
        event.key.alt = false;
        event.key.control = false;
        event.key.shift = false;
        sfWindow->pushEvent(event);
    }

SFML/Window/iOS/SFView.mm: line 104.

    //sf::Vector2i position(static_cast<int>(point.x), static_cast<int>(point.y));
    sf::Vector2i position(static_cast<int>(point.x * self.contentScaleFactor), static_cast<int>(point.y * self.contentScaleFactor));

SFML/Window/iOS/SFView.mm: line 124.

    //sf::Vector2i position(static_cast<int>(point.x), static_cast<int>(point.y));
    sf::Vector2i position(static_cast<int>(point.x * self.contentScaleFactor), static_cast<int>(point.y * self.contentScaleFactor));

SFML/Window/iOS/SFView.mm: line 145.

    //sf::Vector2i position(static_cast<int>(point.x), static_cast<int>(point.y));
    sf::Vector2i position(static_cast<int>(point.x * self.contentScaleFactor), static_cast<int>(point.y * self.contentScaleFactor));

SFML/Window/Win32/JoystickImpl.cpp: line 235.

    //ss.str(_T(""));
    ss.str(sf::String(""));

SFML/Window/Win32/JoystickImpl.cpp: line 250.

    //ss.str(_T(""));
    ss.str(sf::String(""));
« Last Edit: April 23, 2014, 12:52:16 pm by nero81af »

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Android and iOS ports available for testing
« Reply #166 on: April 23, 2014, 12:02:10 am »
Regarding the OS X part of your patch, the current master revision should already address those issue. Can you confirm that?
SFML / OS X developer

nero81af

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Re: Android and iOS ports available for testing
« Reply #167 on: April 23, 2014, 10:25:38 am »
those patches have been applied on the master branch from yesterday so no! opengl 3.0 context does not work without those patches

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Android and iOS ports available for testing
« Reply #168 on: April 23, 2014, 10:46:18 am »
Then there's some duplicate code. https://github.com/SFML/SFML/blob/master/src/SFML/Window/OSX/SFContext.mm#L189-L202 and https://github.com/SFML/SFML/blob/master/src/SFML/Window/OSX/SFContext.mm#L215-L232

You can create a pull request on github if you want. It will be easier to integrate your work then.
SFML / OS X developer

nero81af

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Re: Android and iOS ports available for testing
« Reply #169 on: April 23, 2014, 12:38:34 pm »
I edited my previous post! master branch has fixed problems regarding opengl 3.0 context creation.

while testing I found out another bug

JoystickImpl.mm and JoystickImpl.hpp in Ios folder are missing getIdentification method!
« Last Edit: April 23, 2014, 12:53:34 pm by nero81af »

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #170 on: April 23, 2014, 12:59:06 pm »
Sonkun, did you solved rotation bug?

Sonkun

  • Full Member
  • ***
  • Posts: 241
    • View Profile
Re: Android and iOS ports available for testing
« Reply #171 on: April 23, 2014, 09:23:13 pm »
Sorry, actually I'm on vacation and I didn't have enough time to find out the bug or answer the forum. I'll have time to work on SFML Friday evening and whole Saturday. I hope it can wait.
Interested in using SFML with Python ? Try out its Python binding!

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #172 on: April 24, 2014, 04:44:18 pm »
Yes it can wait surely. =)

Sonkun

  • Full Member
  • ***
  • Posts: 241
    • View Profile
Re: Android and iOS ports available for testing
« Reply #173 on: April 26, 2014, 12:08:53 pm »
@nero81af: your patch sounds interesting. However it turns out I don't have enough time (because of the SFML team reorganization and the amount of discussion to read/reply) analyse and merge it. As for the rotation bug if you want to solve the bug, go ahead I would be glad to merge your changes. Otherwise, I'll be back on 28th of April thus I hope I can do it day after.
Interested in using SFML with Python ? Try out its Python binding!

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #174 on: April 26, 2014, 07:22:18 pm »
I've made a little hack:
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);
}
 
But i'm getting segfault on open. I cheked that states->activity is not null and assetManager is not null too. What it can be? My own bug, again.
« Last Edit: April 27, 2014, 10:34:06 am by ChronicRat »

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #175 on: April 27, 2014, 08:00:54 pm »
Here is log for rotation crash. I think it's OpenAL again.
04-27 21:37:07.432: E/AudioService(485): handleConfigurationChanged() createInstance IAudioServiceExt fail
04-27 21:37:07.432: E/AudioService(485): java.lang.RuntimeException
04-27 21:37:07.432: E/AudioService(485):        at com.mediatek.common.MediatekClassFactory.createInstance(MediatekClassFactory.java:550)
04-27 21:37:07.432: E/AudioService(485):        at android.media.AudioService.handleConfigurationChanged(AudioService.java:5916)
04-27 21:37:07.432: E/AudioService(485):        at android.media.AudioService.access$8500(AudioService.java:108)
04-27 21:37:07.432: E/AudioService(485):        at android.media.AudioService$AudioServiceBroadcastReceiver.onReceive(AudioService.java:4085)
04-27 21:37:07.432: E/AudioService(485):        at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:789)
04-27 21:37:07.432: E/AudioService(485):        at android.os.Handler.handleCallback(Handler.java:800)
04-27 21:37:07.432: E/AudioService(485):        at android.os.Handler.dispatchMessage(Handler.java:100)
04-27 21:37:07.432: E/AudioService(485):        at android.os.Looper.loop(Looper.java:194)
04-27 21:37:07.432: E/AudioService(485):        at com.android.server.ServerThread.run(SystemServer.java:1304)
04-27 21:37:07.494: E/WeatherApp(17889): ACTION_CONFIGURATION_CHANGED
04-27 21:37:07.536: E/WidgetUtils(17889): cityCode=cityId:292195

04-27 21:37:08.149: A/libc(19415): Fatal signal 11 (SIGSEGV) at 0x006f0072 (code=1), thread 19459 (om.example.sfml)
04-27 21:37:08.393: E/InputDispatcher(485): channel '41f9b640 com.example.sfml/android.app.NativeActivity (server)' ~ Channel is unrecoverably broken and will be disposed!

04-27 21:37:08.984: E/AudioService(485): handleConfigurationChanged() createInstance IAudioServiceExt fail
04-27 21:37:08.984: E/AudioService(485): java.lang.RuntimeException
04-27 21:37:08.984: E/AudioService(485):        at com.mediatek.common.MediatekClassFactory.createInstance(MediatekClassFactory.java:550)
04-27 21:37:08.984: E/AudioService(485):        at android.media.AudioService.handleConfigurationChanged(AudioService.java:5916)
04-27 21:37:08.984: E/AudioService(485):        at android.media.AudioService.access$8500(AudioService.java:108)
04-27 21:37:08.984: E/AudioService(485):        at android.media.AudioService$AudioServiceBroadcastReceiver.onReceive(AudioService.java:4085)
04-27 21:37:08.984: E/AudioService(485):        at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:789)
04-27 21:37:08.984: E/AudioService(485):        at android.os.Handler.handleCallback(Handler.java:800)
04-27 21:37:08.984: E/AudioService(485):        at android.os.Handler.dispatchMessage(Handler.java:100)
04-27 21:37:08.984: E/AudioService(485):        at android.os.Looper.loop(Looper.java:194)
04-27 21:37:08.984: E/AudioService(485):        at com.android.server.ServerThread.run(SystemServer.java:1304)
04-27 21:37:09.103: E/WidgetUtils(17889): cityCode=cityId:292195
04-27 21:37:09.118: E/WeatherApp(17889): ACTION_CONFIGURATION_CHANGED
« Last Edit: April 29, 2014, 06:09:26 am by ChronicRat »

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #176 on: April 28, 2014, 11:59:36 am »
Adding "orientation" to manifest fixed crash. But view not changed in example project. My croger controls view itself, so it works on 4.2.x Android.
      android:configChanges="keyboardHidden|screenSize|orientation"
 
As i understand it won't work with Android 2.3.3.
« Last Edit: April 28, 2014, 12:31:19 pm by ChronicRat »

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #177 on: April 28, 2014, 04:26:16 pm »
Well, who is intrested, can download full android alpha - https://www.dropbox.com/s/409org6py72zkq7/croger.apk
I think it won't run on API < 13 and it crahes on stop/continue, i.e. you can't answer to call or read SMS and then return to game now. Fixed.
Now i see only one serious bug - NativeActivity not killed on exit. And when i'll run game again, there are just black screen, i need to kill app manually then start. Example has this bug too. Looks like onDestroy is not called on window close.
As i understand ANativeActivity_finish() does only  mark to wish finish, and app has to be alive while onDestroy is awaiting to be called.
« Last Edit: April 29, 2014, 08:07:01 am by ChronicRat »

Sonkun

  • Full Member
  • ***
  • Posts: 241
    • View Profile
Re: Android and iOS ports available for testing
« Reply #178 on: April 29, 2014, 07:19:36 pm »
Interesting! Actually, I noticed the activity not properly destroyed bug when working on the rotation bug (and that's why I needed more time :p). But I don't understand why we still see the application as running because the code is called as intended. onDestroy() takes care of sending the SFML close event, the main loop ends which ends the main() function, which  causes ANativeActivity_finish() to be called.
Interested in using SFML with Python ? Try out its Python binding!

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #179 on: April 29, 2014, 07:32:01 pm »
I inserted log messages in the onDestroy function, i haven't seen any message. In the same time messages in the terminateMain was displayed.

 

anything