MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Tools / WinMain

Function WinMain

cube/cube.cpp:4064–4153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4062}
4063
4064int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow) {
4065 // TODO: Gah.. refactor. This isn't 1989.
4066 MSG msg; // message
4067 bool done; // flag saying when app is complete
4068 int argc;
4069 char **argv;
4070
4071 // Ensure wParam is initialized.
4072 msg.wParam = 0;
4073
4074 // Use the CommandLine functions to get the command line arguments.
4075 // Unfortunately, Microsoft outputs
4076 // this information as wide characters for Unicode, and we simply want the
4077 // Ascii version to be compatible
4078 // with the non-Windows side. So, we have to convert the information to
4079 // Ascii character strings.
4080 LPWSTR *commandLineArgs = CommandLineToArgvW(GetCommandLineW(), &argc);
4081 if (nullptr == commandLineArgs) {
4082 argc = 0;
4083 }
4084
4085 if (argc > 0) {
4086 argv = (char **)malloc(sizeof(char *) * argc);
4087 if (argv == nullptr) {
4088 argc = 0;
4089 } else {
4090 for (int iii = 0; iii < argc; iii++) {
4091 size_t wideCharLen = wcslen(commandLineArgs[iii]);
4092 size_t numConverted = 0;
4093
4094 argv[iii] = (char *)malloc(sizeof(char) * (wideCharLen + 1));
4095 if (argv[iii] != nullptr) {
4096 wcstombs_s(&numConverted, argv[iii], wideCharLen + 1, commandLineArgs[iii], wideCharLen + 1);
4097 }
4098 }
4099 }
4100 } else {
4101 argv = nullptr;
4102 }
4103
4104 demo.init(argc, argv);
4105
4106 // Free up the items we had to allocate for the command line arguments.
4107 if (argc > 0 && argv != nullptr) {
4108 for (int iii = 0; iii < argc; iii++) {
4109 if (argv[iii] != nullptr) {
4110 free(argv[iii]);
4111 }
4112 }
4113 free(argv);
4114 }
4115
4116 demo.connection = hInstance;
4117 demo.name = "Vulkan Cube";
4118 demo.create_window<WsiPlatform::win32>();
4119 demo.create_surface();
4120 demo.select_physical_device();
4121 demo.init_vk_swapchain();

Callers

nothing calls this directly

Calls 6

initMethod · 0.80
create_surfaceMethod · 0.80
init_vk_swapchainMethod · 0.80
prepareMethod · 0.80
cleanupMethod · 0.80

Tested by

no test coverage detected