Home | History | Annotate | Download | only in smoke
      1 /*
      2  * Copyright (C) 2016 Google, Inc.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *     http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #include <string>
     18 #include <vector>
     19 
     20 #include "Smoke.h"
     21 
     22 namespace {
     23 
     24 #if defined(VK_USE_PLATFORM_ANDROID_KHR)
     25 Game *create_game(const std::vector<std::string> &args) { return new Smoke(args); }
     26 #endif
     27 
     28 Game *create_game(int argc, char **argv) {
     29     std::vector<std::string> args(argv, argv + argc);
     30     return new Smoke(args);
     31 }
     32 
     33 }  // namespace
     34 
     35 #if defined(VK_USE_PLATFORM_XCB_KHR)
     36 
     37 #include "ShellXcb.h"
     38 
     39 int main(int argc, char **argv) {
     40     Game *game = create_game(argc, argv);
     41     {
     42         ShellXcb shell(*game);
     43         shell.run();
     44     }
     45     delete game;
     46 
     47     return 0;
     48 }
     49 
     50 #elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
     51 
     52 #include "ShellWayland.h"
     53 
     54 int main(int argc, char **argv) {
     55     Game *game = create_game(argc, argv);
     56     {
     57         ShellWayland shell(*game);
     58         shell.run();
     59     }
     60     delete game;
     61 
     62     return 0;
     63 }
     64 
     65 #elif defined(VK_USE_PLATFORM_ANDROID_KHR)
     66 
     67 #include <android/log.h>
     68 #include "ShellAndroid.h"
     69 
     70 void android_main(android_app *app) {
     71     Game *game = create_game(ShellAndroid::get_args(*app));
     72 
     73     try {
     74         ShellAndroid shell(*app, *game);
     75         shell.run();
     76     } catch (const std::runtime_error &e) {
     77         __android_log_print(ANDROID_LOG_ERROR, game->settings().name.c_str(), "%s", e.what());
     78     }
     79 
     80     delete game;
     81 }
     82 
     83 #elif defined(VK_USE_PLATFORM_WIN32_KHR)
     84 
     85 #include "ShellWin32.h"
     86 
     87 int main(int argc, char **argv) {
     88     Game *game = create_game(argc, argv);
     89     {
     90         ShellWin32 shell(*game);
     91         shell.run();
     92     }
     93     delete game;
     94 
     95     return 0;
     96 }
     97 
     98 #endif  // VK_USE_PLATFORM_XCB_KHR
     99