MCPcopy Create free account
hub / github.com/axmolengine/axmol / run

Method run

core/platform/linux/Application-linux.cpp:53–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53int Application::run()
54{
55 initGfxContextAttrs();
56 // Initialize instance and cocos2d.
57 if (!applicationDidFinishLaunching())
58 {
59 return 0;
60 }
61
62 std::chrono::steady_clock::time_point lastTime{};
63
64 auto director = Director::getInstance();
65 auto renderView = director->getRenderView();
66
67 // Retain renderView to avoid renderView being released in the while loop
68 renderView->retain();
69
70 while (!renderView->windowShouldClose())
71 {
72 lastTime = std::chrono::steady_clock::now();
73
74 director->mainLoop();
75 renderView->pollEvents();
76
77 auto interval = std::chrono::steady_clock::now() - lastTime;
78 if (interval < _animationInterval)
79 {
80 auto waitDuration = _animationInterval - interval;
81 std::this_thread::sleep_for(waitDuration);
82 }
83 else
84 {
85 std::this_thread::yield();
86 }
87 }
88 /* Only work on Desktop
89 * Director::mainLoop is really one frame logic
90 * when we want to close the window, we should call Director::end();
91 * then call Director::mainLoop to do release of internal resources
92 */
93 if (renderView->isGfxContextReady())
94 {
95 director->end();
96 director->mainLoop();
97 director = nullptr;
98 }
99 renderView->release();
100 return EXIT_SUCCESS;
101}
102
103void Application::setAnimationInterval(float interval)
104{

Callers

nothing calls this directly

Calls 9

initGfxContextAttrsFunction · 0.85
getInstanceFunction · 0.85
windowShouldCloseMethod · 0.80
retainMethod · 0.45
mainLoopMethod · 0.45
pollEventsMethod · 0.45
isGfxContextReadyMethod · 0.45
endMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected