2016-07-19 21:17:20 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SkTypes.h"
|
|
|
|
#include "SkTHash.h"
|
2016-08-04 19:30:31 +00:00
|
|
|
#include "SDL.h"
|
2016-07-19 21:17:20 +00:00
|
|
|
#include "Timer.h"
|
|
|
|
#include "Window_mac.h"
|
|
|
|
#include "../Application.h"
|
|
|
|
|
|
|
|
using sk_app::Application;
|
|
|
|
|
2016-08-04 19:30:31 +00:00
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) != 0) {
|
|
|
|
SkDebugf("Could not initialize SDL!\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2016-07-19 21:17:20 +00:00
|
|
|
|
2016-08-04 19:30:31 +00:00
|
|
|
Application* app = Application::Create(argc, argv, nullptr);
|
2016-07-19 21:17:20 +00:00
|
|
|
|
2016-08-04 19:30:31 +00:00
|
|
|
SDL_Event event;
|
2016-07-19 21:17:20 +00:00
|
|
|
bool done = false;
|
|
|
|
while (!done) {
|
2016-08-04 19:30:31 +00:00
|
|
|
while (SDL_PollEvent(&event)) {
|
2016-07-19 21:17:20 +00:00
|
|
|
switch (event.type) {
|
2016-08-04 19:30:31 +00:00
|
|
|
// events handled by the windows
|
|
|
|
case SDL_WINDOWEVENT:
|
|
|
|
case SDL_MOUSEMOTION:
|
|
|
|
case SDL_MOUSEBUTTONDOWN:
|
|
|
|
case SDL_MOUSEBUTTONUP:
|
|
|
|
case SDL_KEYDOWN:
|
|
|
|
case SDL_KEYUP:
|
|
|
|
done = sk_app::Window_mac::HandleWindowEvent(event);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_QUIT:
|
2016-07-19 21:17:20 +00:00
|
|
|
done = true;
|
2016-08-04 19:30:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2016-07-19 21:17:20 +00:00
|
|
|
}
|
|
|
|
|
2016-08-04 19:30:31 +00:00
|
|
|
app->onIdle();
|
|
|
|
}
|
2016-07-19 21:17:20 +00:00
|
|
|
delete app;
|
|
|
|
|
2016-08-04 19:30:31 +00:00
|
|
|
SDL_Quit();
|
|
|
|
|
2016-07-19 21:17:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|