Skip to content

Commit f541abf

Browse files
committed
Remove odd engine_draw_frame call patterns.
It looks like whoever wrote this just kept adding draw calls until it worked. For some reason if I removed the call from `APP_CMD_INIT_WINDOW` (which really shouldn't have needed to render), or added an `if (!animating)` early exist to engine_draw_frame, it would prevent the app from *ever* rendering. I never figured out why, but in any case the most important call is the one that was missing: the one in `APP_CMD_GAINED_FOCUS`. That's why the rendering wouldn't start until you tapped the screen. I added that and now all the calls that appear superfluous in fact are.
1 parent 0f23ecb commit f541abf

File tree

1 file changed

+1
-3
lines changed
  • native-activity/app/src/main/cpp

1 file changed

+1
-3
lines changed

native-activity/app/src/main/cpp/main.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ static int32_t engine_handle_input(android_app* app,
263263
AInputEvent* event) {
264264
auto* engine = (Engine*)app->userData;
265265
if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) {
266-
engine->StartRendering();
267266
engine->state.x = AMotionEvent_getX(event, 0);
268267
engine->state.y = AMotionEvent_getY(event, 0);
269268
return 1;
@@ -287,7 +286,6 @@ static void engine_handle_cmd(android_app* app, int32_t cmd) {
287286
// The window is being shown, get it ready.
288287
if (engine->app->window != nullptr) {
289288
engine_init_display(engine);
290-
engine_draw_frame(engine);
291289
}
292290
break;
293291
case APP_CMD_TERM_WINDOW:
@@ -304,6 +302,7 @@ static void engine_handle_cmd(android_app* app, int32_t cmd) {
304302
engine->accelerometerSensor,
305303
(1000L / 60) * 1000);
306304
}
305+
engine->StartRendering();
307306
break;
308307
case APP_CMD_LOST_FOCUS:
309308
// When our app loses focus, we stop monitoring the accelerometer.
@@ -313,7 +312,6 @@ static void engine_handle_cmd(android_app* app, int32_t cmd) {
313312
engine->accelerometerSensor);
314313
}
315314
engine->StopRendering();
316-
engine_draw_frame(engine);
317315
break;
318316
default:
319317
break;

0 commit comments

Comments
 (0)