|
|
@@ -7,7 +7,6 @@
|
|
|
#include "core/oxygine.h"
|
|
|
#include "Stage.h"
|
|
|
#include "DebugActor.h"
|
|
|
-
|
|
|
#include "example.h"
|
|
|
|
|
|
|
|
|
@@ -17,6 +16,11 @@ using namespace oxygine;
|
|
|
// This function is called each frame
|
|
|
int mainloop()
|
|
|
{
|
|
|
+ // Update engine-internal components
|
|
|
+ // If input events are available, they are passed to Stage::instance.handleEvent
|
|
|
+ // If the function returns true, it means that the user requested the application to terminate
|
|
|
+ bool done = core::update();
|
|
|
+
|
|
|
// It gets passed to our example game implementation
|
|
|
example_update();
|
|
|
|
|
|
@@ -34,11 +38,6 @@ int mainloop()
|
|
|
core::swapDisplayBuffers();
|
|
|
}
|
|
|
|
|
|
- // Update engine-internal components
|
|
|
- // If input events are available, they are passed to Stage::instance.handleEvent
|
|
|
- // If the function returns true, it means that the user requested the application to terminate
|
|
|
- bool done = core::update();
|
|
|
-
|
|
|
return done ? 1 : 0;
|
|
|
}
|
|
|
|
|
|
@@ -83,6 +82,12 @@ void run()
|
|
|
#endif
|
|
|
|
|
|
|
|
|
+
|
|
|
+#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
|
|
|
+ // On iPhone mainloop is called automatically by CADisplayLink, see int main() below
|
|
|
+ return;
|
|
|
+#endif
|
|
|
+
|
|
|
// This is the main game loop.
|
|
|
while (1)
|
|
|
{
|
|
|
@@ -132,25 +137,28 @@ int main(int argc, char* argv[])
|
|
|
#ifdef OXYGINE_SDL
|
|
|
|
|
|
#include "SDL_main.h"
|
|
|
+#include "SDL.h"
|
|
|
+
|
|
|
extern "C"
|
|
|
{
|
|
|
+ void one(void* param) { mainloop(); }
|
|
|
+ void oneEmsc() { mainloop(); }
|
|
|
+
|
|
|
int main(int argc, char* argv[])
|
|
|
{
|
|
|
- run();
|
|
|
- return 0;
|
|
|
- }
|
|
|
-};
|
|
|
-#endif
|
|
|
|
|
|
-#ifdef EMSCRIPTEN
|
|
|
-#include <emscripten.h>
|
|
|
+ run();
|
|
|
|
|
|
-void one() { mainloop(); }
|
|
|
+#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
|
|
|
+ // If parameter 2 is set to 1, refresh rate will be 60 fps, 2 - 30 fps, 3 - 15 fps.
|
|
|
+ SDL_iPhoneSetAnimationCallback(core::getWindow(), 1, one, nullptr);
|
|
|
+#endif
|
|
|
|
|
|
-int main(int argc, char* argv[])
|
|
|
-{
|
|
|
- run();
|
|
|
- emscripten_set_main_loop(one, 0, 0);
|
|
|
- return 0;
|
|
|
-}
|
|
|
+#if EMSCRIPTEN
|
|
|
+ emscripten_set_main_loop(oneEmsc, 0, 0);
|
|
|
#endif
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+};
|
|
|
+#endif
|