main.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include <flutter/dart_project.h>
  2. #include <flutter/flutter_view_controller.h>
  3. #include <windows.h>
  4. #include "flutter_window.h"
  5. #include "run_loop.h"
  6. #include "utils.h"
  7. int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
  8. _In_ wchar_t *command_line, _In_ int show_command) {
  9. // Attach to console when present (e.g., 'flutter run') or create a
  10. // new console when running with a debugger.
  11. if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
  12. CreateAndAttachConsole();
  13. }
  14. // Initialize COM, so that it is available for use in the library and/or
  15. // plugins.
  16. ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
  17. RunLoop run_loop;
  18. flutter::DartProject project(L"data");
  19. std::vector<std::string> command_line_arguments =
  20. GetCommandLineArguments();
  21. project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
  22. FlutterWindow window(&run_loop, project);
  23. Win32Window::Point origin(10, 10);
  24. Win32Window::Size size(1280, 720);
  25. if (!window.CreateAndShow(L"eye_video", origin, size)) {
  26. return EXIT_FAILURE;
  27. }
  28. window.SetQuitOnClose(true);
  29. run_loop.Run();
  30. ::CoUninitialize();
  31. return EXIT_SUCCESS;
  32. }