SDLを初期化する方法は次のとおりです。
//initialize engine and set main loop callback... kind of awkward is there a better way to do this?
extern "C"{
CBCore::Engine *engine;
void UpdateLoop(void *f)
{
engine->updateLoop();
}
int main(int argc, char *argv[])
{
engine = new CBCore::Engine();
engine->init();
Assert(engine->window(), "Window not set for iOS animation callback");
SDL_iPhoneSetAnimationCallback(engine->window(), 1, UpdateLoop, NULL);
return 0;
}
}
//init function of engine, initializes required SDL subsystems and creates window
void Engine::init()
{
SDL_Log("Initializing engine!");
/* initialize SDL */
if(SDL_Init(0) != 0){
Assert(0, "Could not initialize SDL");
}
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
Assert(0, "Could not initialize SDL Video");
}
if(SDL_InitSubSystem(SDL_INIT_TIMER) != 0){
Assert(0, "Could not initialize SDL Timer");
}
_window = SDL_CreateWindow(NULL, 0, 0, 480, 320, SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL);
Assert(_window, "Could not create window");
_context = SDL_GL_CreateContext(pimpl->window);
Assert(_context, "Could not create context");
SDL_Log("Engine successfully initialized!");
}
//loop
void Engine::updateLoop()
{
SDL_Event event;
SDL_Log("Polling events");
while(SDL_PollEvent(&event)) {
SDL_Log("Polled event %d", event.type);
}
}
ループが呼び出され、起動時に 4 つのイベントが発生します: SDL_APP_DIDENTERFOREGROUND、SDL_WINDOWEVENT_SIZE_CHANGED、SDL_WINDOWEVENT_SHOWN、SDL_WINDOWEVENT_ENTER; バックグラウンドメッセージなども入力しました。しかし、牛が家に帰るまでシミュレーター/デバイスをクリック/タッチできますが、イベントは受信されません...何か不足していますか?