Skip to content

SDL2: implement support for loadingscreen#605

Merged
inclement merged 1 commit into
kivy:masterfrom
tito:sdl2-loadingscreen
Jan 15, 2016
Merged

SDL2: implement support for loadingscreen#605
inclement merged 1 commit into
kivy:masterfrom
tito:sdl2-loadingscreen

Conversation

@tito

@tito tito commented Jan 15, 2016

Copy link
Copy Markdown
Member

As explained on #465, the previous approach (pure GL, or using window background) doesn't fully work.
This approach have a tiny delay until PythonActivity.onCreate is called.
It first display an ImageView fitted on the screen.
Once SDL is loaded (and that SDL put its own layout), we put again our ImageView.

The tricky part is when to remove.
On the previous python-for-android+kivy, kivy was explicitely saying that he's ready to receive event. And that's where we knew the loading screen could be removed.
Here, there is no absolute way to do it, as SDL itself on the java part doesn't provide any callback... except pollInputDevices()

This method is called each X seconds, to check if any joystick has been plugged or not.
The PR add a keepActive() method that is overrided in PythonActivity to remove the screen.
It wait for the second call of it before removing the loading screen:

  1. the first call is done right after the creation of the SDL window in C code. (In kivy, it's just the start, after that we load the app, widgets etc... it can take a long time)
  2. the second call is done (at least on kivy) after the first frame rendered.

The loading screen might be displayed more than needed (pure SDL2 game // very fast loading). In any case,
we can always force to remove the loading screen with:

PythonActivity.mActivity.removeLoadingScreen()

If anybody have another good approach, feel free :)

Closes #465

As explained on kivy#465, the previous approach (pure GL, or using window background) doesn't fully work.
This approach have a tiny delay until PythonActivity.onCreate is called.
It first display an ImageView fitted on the screen.
Once SDL is loaded (and that SDL put its own layout), we put again our ImageView.

The tricky part is when to remove.
On the previous python-for-android+kivy, kivy was explicitely saying that he's ready to receive event. And that's where we knew the loading screen could be removed.
Here, there is no absolute way to do it, as SDL itself on the java part doesn't provide any callback... except pollInputDevices()

This method is called each X seconds, to check if any joystick has been plugged or not.
The PR add a keepActive() method that is overrided in PythonActivity to remove the screen.
It wait for the second call of it before removing the loading screen:
1. the first call is done right after the creation of the SDL window in C code. (In kivy, it's just the start, after that we load the app, widgets etc... it can take a long time)
2. the second call is done (at least on kivy) after the first frame rendered.

The loading screen might be displayed more than needed (pure SDL2 game // very fast loading). In any case,
we can always force to remove the loading screen with:

    PythonActivity.mActivity.removeLoadingScreen()

If anybody have another good approach, feel free :)

Closes kivy#465
inclement added a commit that referenced this pull request Jan 15, 2016
SDL2: implement support for loadingscreen
@inclement inclement merged commit 5e5eb66 into kivy:master Jan 15, 2016
@tito tito deleted the sdl2-loadingscreen branch January 15, 2016 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants