Advertisement
Guest User

main.cpp

a guest
Jan 23rd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.54 KB | None | 0 0
  1. #include "platform/platform.h"
  2. #include "app/mainLoop.h"
  3. #include "T3D/gameFunctions.h"
  4.  
  5. #include "include/cef_sandbox_win.h"
  6. #include "web/cef_handler.h"
  7. #include "include/cef_app.h"
  8. #include "include/cef_client.h"
  9.  
  10. #include "platformWin32/platformWin32.h"
  11. extern Win32PlatState winState;
  12.  
  13. // Entry point for your game.
  14. //
  15. // This is build by default using the "StandardMainLoop" toolkit. Feel free
  16. // to bring code over directly as you need to modify or extend things. You
  17. // will need to merge against future changes to the SML code if you do this.
  18. S32 TorqueMain(S32 argc, const char **argv)
  19. {
  20.    // Some handy debugging code:
  21.    //   if (argc == 1) {
  22.    //      static const char* argvFake[] = { "dtest.exe", "-jload", "test.jrn" };
  23.    //      argc = 3;
  24.    //      argv = argvFake;
  25.    //   }
  26.  
  27.    //   Memory::enableLogging("testMem.log");
  28.    //   Memory::setBreakAlloc(104717);
  29.  
  30.    // CEF
  31.    // Enable High-DPI support on Windows 7 or newer.
  32.   CefEnableHighDPISupport();
  33.  
  34.   // Provide CEF with command-line arguments.
  35.   CefMainArgs main_args(winState.appInstance);
  36.  
  37.   // CEF applications have multiple sub-processes (render, plugin, GPU, etc)
  38.   // that share the same executable. This function checks the command-line and,
  39.   // if this is a sub-process, executes the appropriate logic.
  40.   int exit_code = CefExecuteProcess(main_args, NULL, NULL);
  41.   if (exit_code >= 0) {
  42.     // The sub-process has completed so return here.
  43.     return exit_code;
  44.   }
  45.  
  46.   // Specify CEF global settings here.
  47.   CefSettings settings;
  48.   settings.no_sandbox = true;
  49.  
  50.   // Initialize CEF.
  51.   // CefInitialize creates a sub-proccess and executes the same executeable, as calling CefInitialize, if not set different in settings.browser_subprocess_path
  52.   // if you create an extra program just for the childproccess you only have to call CefExecuteProcess(...) in it.
  53.   CefInitialize(main_args, settings, NULL, NULL);
  54.  
  55.    // Initialize the subsystems.
  56.    StandardMainLoop::init();
  57.  
  58.    // Handle any command line args.
  59.    if(!StandardMainLoop::handleCommandLine(argc, argv))
  60.    {
  61.       Platform::AlertOK("Error", "Failed to initialize game, shutting down.");
  62.  
  63.       return 1;
  64.    }
  65.  
  66.    // create browser-window
  67.    // Specify CEF browser settings here.
  68.    CefBrowserSettings browser_settings;
  69.  
  70.    std::string url = "http://www.google.com";
  71.  
  72.    // Information used when creating the native window.
  73.    CefWindowInfo window_info;
  74.  
  75.    // SimpleHandler implements browser-level callbacks.
  76.    CefRefPtr<CefHandler> cefHandler(new CefHandler());
  77. #if defined(OS_WIN)
  78.    // On Windows we need to specify certain flags that will be passed to
  79.    // CreateWindowEx().
  80.    window_info.SetAsWindowless(winState.appWindow);
  81.    //window_info.SetAsPopup(winState.appWindow,"CEF TEST");
  82. #endif
  83.  
  84.    // Create the first browser window.
  85.    // Con::printf(ConsoleLogEntry::General, "afxBillboardData(%s) incomplete blend factor specification.", getName());
  86.    CefBrowserHost::CreateBrowserSync(window_info, cefHandler, url, browser_settings, NULL);
  87.  
  88.    // Run the CEF message loop. This will block until CefQuitMessageLoop() is
  89.    // called.
  90.    //CefRunMessageLoop();
  91.    
  92.    // Main loop
  93.    while(StandardMainLoop::doMainLoop());
  94.  
  95.    // Clean everything up.
  96.    StandardMainLoop::shutdown();
  97.  
  98.    // Do we need to restart?
  99.    if( StandardMainLoop::requiresRestart() )
  100.       Platform::restartInstance();
  101.  
  102.    // Shut down CEF.
  103.    CefShutdown();
  104.    delete CefHandler::GetInstance();
  105.  
  106.    // Return.
  107.    return StandardMainLoop::getReturnStatus();
  108. }
  109.  
  110. #endif //TORQUE_SHARED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement