forked from Green-Sky/tomato
background processing
This commit is contained in:
parent
b0e25627b3
commit
56f1bf559c
@ -76,9 +76,8 @@
|
||||
android:theme="@style/AppTheme"
|
||||
android:hardwareAccelerated="true" >
|
||||
|
||||
<!-- Example of setting SDL hints from AndroidManifest.xml:
|
||||
<meta-data android:name="SDL_ENV.SDL_ANDROID_TRAP_BACK_BUTTON" android:value="0"/>
|
||||
-->
|
||||
<!-- setting sdl hints. uses the string value -->
|
||||
<meta-data android:name="SDL_ENV.SDL_ANDROID_BLOCK_ON_PAUSE" android:value="0"/>
|
||||
|
||||
<activity android:name="TomatoActivity"
|
||||
android:label="@string/app_name"
|
||||
|
10
src/main.cpp
10
src/main.cpp
@ -106,7 +106,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
std::unique_ptr<Screen> screen = std::make_unique<StartScreen>(args, renderer.get(), theme);
|
||||
|
||||
|
||||
bool is_background = false;
|
||||
bool quit = false;
|
||||
while (!quit) {
|
||||
auto new_time = std::chrono::steady_clock::now();
|
||||
@ -131,6 +131,10 @@ int main(int argc, char** argv) {
|
||||
if (event.type == SDL_EVENT_QUIT) {
|
||||
quit = true;
|
||||
break;
|
||||
} else if (event.type == SDL_EVENT_WILL_ENTER_BACKGROUND) {
|
||||
is_background = true;
|
||||
} else if (event.type == SDL_EVENT_DID_ENTER_FOREGROUND) {
|
||||
is_background = false;
|
||||
}
|
||||
|
||||
if (screen->handleEvent(event)) {
|
||||
@ -143,6 +147,10 @@ int main(int argc, char** argv) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_background) {
|
||||
render = false;
|
||||
}
|
||||
|
||||
// can do both in the same loop
|
||||
if (render) {
|
||||
ImGui_ImplSDLRenderer3_NewFrame();
|
||||
|
Loading…
Reference in New Issue
Block a user