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:theme="@style/AppTheme"
|
||||||
android:hardwareAccelerated="true" >
|
android:hardwareAccelerated="true" >
|
||||||
|
|
||||||
<!-- Example of setting SDL hints from AndroidManifest.xml:
|
<!-- setting sdl hints. uses the string value -->
|
||||||
<meta-data android:name="SDL_ENV.SDL_ANDROID_TRAP_BACK_BUTTON" android:value="0"/>
|
<meta-data android:name="SDL_ENV.SDL_ANDROID_BLOCK_ON_PAUSE" android:value="0"/>
|
||||||
-->
|
|
||||||
|
|
||||||
<activity android:name="TomatoActivity"
|
<activity android:name="TomatoActivity"
|
||||||
android:label="@string/app_name"
|
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);
|
std::unique_ptr<Screen> screen = std::make_unique<StartScreen>(args, renderer.get(), theme);
|
||||||
|
|
||||||
|
bool is_background = false;
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
while (!quit) {
|
while (!quit) {
|
||||||
auto new_time = std::chrono::steady_clock::now();
|
auto new_time = std::chrono::steady_clock::now();
|
||||||
@ -131,6 +131,10 @@ int main(int argc, char** argv) {
|
|||||||
if (event.type == SDL_EVENT_QUIT) {
|
if (event.type == SDL_EVENT_QUIT) {
|
||||||
quit = true;
|
quit = true;
|
||||||
break;
|
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)) {
|
if (screen->handleEvent(event)) {
|
||||||
@ -143,6 +147,10 @@ int main(int argc, char** argv) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_background) {
|
||||||
|
render = false;
|
||||||
|
}
|
||||||
|
|
||||||
// can do both in the same loop
|
// can do both in the same loop
|
||||||
if (render) {
|
if (render) {
|
||||||
ImGui_ImplSDLRenderer3_NewFrame();
|
ImGui_ImplSDLRenderer3_NewFrame();
|
||||||
|
Loading…
Reference in New Issue
Block a user