MCPcopy Create free account
hub / github.com/SFML/SFML / ANativeActivity_onCreate

Function ANativeActivity_onCreate

src/SFML/Main/MainAndroid.cpp:491–566  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

489
490////////////////////////////////////////////////////////////
491JNIEXPORT void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, std::size_t savedStateSize)
492{
493 // Create an activity states (will keep us in the know, about events we care)
494 auto* states = new sf::priv::ActivityStates();
495
496 for (auto& isButtonPressed : states->isButtonPressed)
497 isButtonPressed = false;
498
499 if (savedState != nullptr)
500 {
501 const auto* begin = static_cast<const std::byte*>(savedState);
502 const auto* end = begin + savedStateSize;
503 states->savedState.assign(begin, end);
504 }
505
506 states->mainOver = false;
507
508 states->initialized = false;
509 states->terminated = false;
510
511 // Share it across the SFML modules
512 sf::priv::resetActivity(states);
513
514 // These functions will update the activity states and therefore, will allow
515 // SFML to be kept in the know
516 activity->callbacks->onStart = onStart;
517 activity->callbacks->onResume = onResume;
518 activity->callbacks->onPause = onPause;
519 activity->callbacks->onStop = onStop;
520 activity->callbacks->onDestroy = onDestroy;
521
522 activity->callbacks->onNativeWindowCreated = onNativeWindowCreated;
523 activity->callbacks->onNativeWindowDestroyed = onNativeWindowDestroyed;
524 activity->callbacks->onNativeWindowRedrawNeeded = onNativeWindowRedrawNeeded;
525 activity->callbacks->onNativeWindowResized = onNativeWindowResized;
526
527 activity->callbacks->onInputQueueCreated = onInputQueueCreated;
528 activity->callbacks->onInputQueueDestroyed = onInputQueueDestroyed;
529
530 activity->callbacks->onWindowFocusChanged = onWindowFocusChanged;
531 activity->callbacks->onContentRectChanged = onContentRectChanged;
532 activity->callbacks->onConfigurationChanged = onConfigurationChanged;
533
534 activity->callbacks->onSaveInstanceState = onSaveInstanceState;
535 activity->callbacks->onLowMemory = onLowMemory;
536
537 // Share this activity with the callback functions
538 states->activity = activity;
539
540 // Keep the screen turned on and bright
541 ANativeActivity_setWindowFlags(activity, AWINDOW_FLAG_KEEP_SCREEN_ON, AWINDOW_FLAG_KEEP_SCREEN_ON);
542
543 getScreenSizeInPixels(*activity, states->screenSize.x, states->screenSize.y);
544 getFullScreenSizeInPixels(*activity, states->fullScreenSize.x, states->fullScreenSize.y);
545
546 // Redirect error messages to logcat
547 sf::err().rdbuf(&states->logcat);
548

Callers

nothing calls this directly

Calls 5

resetActivityFunction · 0.85
getScreenSizeInPixelsFunction · 0.85
sleepFunction · 0.85
assignMethod · 0.80

Tested by

no test coverage detected