Working on iOS

This commit is contained in:
Joshua Granick
2015-03-20 07:22:02 -07:00
parent 90ef6b39c3
commit 978dd06ee8
4 changed files with 36 additions and 33 deletions

View File

@@ -33,13 +33,6 @@
<ndll name="lime" if="included" />
<ndll name="curl_ssl" register="false" if="ios" />
<ndll name="png" register="false" if="ios" />
<ndll name="jpeg" register="false" if="ios" />
<ndll name="freetype" register="false" if="ios" />
<ndll name="ogg" register="false" if="ios" />
<ndll name="vorbis" register="false" if="ios" />
<dependency name="extension-api" path="dependencies/extension-api" if="android" />
<dependency path="dependencies/webgl-debug.js" if="html5 debug" />
<dependency path="dependencies/stats.min.js" if="html5 stats" />

View File

@@ -14,24 +14,18 @@ namespace lime {
AutoGCRoot* Application::callback = 0;
double Application::GetTicks () {
return SDL_GetTicks ();
}
SDLApplication* SDLApplication::currentApplication = 0;
SDLApplication::SDLApplication () {
SDL_Init (SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_TIMER);
#ifdef EMSCRIPTEN
currentApplication = this;
#ifdef EMSCRIPTEN
emscripten_cancel_main_loop ();
emscripten_set_main_loop (EmscriptenUpdate, 0, 0);
emscripten_set_main_loop (UpdateFrame, 0, 0);
emscripten_set_main_loop_timing (EM_TIMING_RAF, 1);
#endif
@@ -194,7 +188,7 @@ namespace lime {
}
void SDLApplication::Init() {
void SDLApplication::Init () {
framePeriod = 1000.0 / 60.0;
active = true;
@@ -380,6 +374,15 @@ namespace lime {
}
void SDLApplication::RegisterWindow (SDLWindow *window) {
#ifdef IPHONE
SDL_iPhoneSetAnimationCallback (window->sdlWindow, 1, UpdateFrame, NULL);
#endif
}
static SDL_TimerID timerID = 0;
bool timerActive = false;
bool firstTime = true;
@@ -410,7 +413,7 @@ namespace lime {
SDL_Event event;
event.type = -1;
#ifndef EMSCRIPTEN
#if (!defined (EMSCRIPTEN) && !defined (IPHONE))
if (active && (firstTime || SDL_WaitEvent (&event))) {
@@ -464,6 +467,20 @@ namespace lime {
}
void SDLApplication::UpdateFrame (void*) {
currentApplication->Update ();
}
double Application::GetTicks () {
return SDL_GetTicks ();
}
Application* CreateApplication () {
return new SDLApplication ();
@@ -471,17 +488,6 @@ namespace lime {
}
#ifdef EMSCRIPTEN
SDLApplication* SDLApplication::currentApplication = 0;
void SDLApplication::EmscriptenUpdate () {
currentApplication->Update ();
}
#endif
}

View File

@@ -11,6 +11,7 @@
#include <ui/MouseEvent.h>
#include <ui/TouchEvent.h>
#include <ui/WindowEvent.h>
#include "SDLWindow.h"
namespace lime {
@@ -28,10 +29,7 @@ namespace lime {
virtual int Quit ();
virtual bool Update ();
#ifdef EMSCRIPTEN
static SDLApplication *currentApplication;
static void EmscriptenUpdate ();
#endif
void RegisterWindow (SDLWindow *window);
private:
@@ -42,6 +40,9 @@ namespace lime {
void ProcessTouchEvent (SDL_Event* event);
void ProcessWindowEvent (SDL_Event* event);
static void UpdateFrame (void*);
static SDLApplication* currentApplication;
bool active;
Uint32 currentUpdate;
double framePeriod;

View File

@@ -1,4 +1,5 @@
#include "SDLWindow.h"
#include "SDLApplication.h"
#ifdef HX_WINDOWS
#include <SDL_syswm.h>
@@ -35,6 +36,8 @@ namespace lime {
sdlWindow = SDL_CreateWindow (title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, sdlFlags);
((SDLApplication*)currentApplication)->RegisterWindow (this);
#ifdef HX_WINDOWS
HINSTANCE handle = ::GetModuleHandle (nullptr);