MCPcopy Create free account
hub / github.com/csyonghe/Spire / WinMain

Function WinMain

Examples/hello/hello.cpp:408–623  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

406//
407
408int WINAPI WinMain(
409 HINSTANCE instance,
410 HINSTANCE /* prevInstance */,
411 LPSTR /* commandLine */,
412 int showCommand)
413{
414 // First we register a window class.
415
416 WNDCLASSEXW windowClassDesc;
417 windowClassDesc.cbSize = sizeof(windowClassDesc);
418 windowClassDesc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
419 windowClassDesc.lpfnWndProc = &windowProc;
420 windowClassDesc.cbClsExtra = 0;
421 windowClassDesc.cbWndExtra = 0;
422 windowClassDesc.hInstance = instance;
423 windowClassDesc.hIcon = 0;
424 windowClassDesc.hCursor = 0;
425 windowClassDesc.hbrBackground = 0;
426 windowClassDesc.lpszMenuName = 0;
427 windowClassDesc.lpszClassName = L"HelloWorld";
428 windowClassDesc.hIconSm = 0;
429 ATOM windowClassAtom = RegisterClassExW(&windowClassDesc);
430 if(!windowClassAtom)
431 {
432 fprintf(stderr, "error: failed to register window class\n");
433 return 1;
434 }
435
436 // Next, we create a window using that window class.
437
438 DWORD windowExtendedStyle = 0;
439 DWORD windowStyle = 0;
440 LPWSTR windowName = L"Spire Hello World";
441 HWND windowHandle = CreateWindowExW(
442 windowExtendedStyle,
443 (LPWSTR)windowClassAtom,
444 windowName,
445 windowStyle,
446 0, 0, // x, y
447 gWindowWidth, gWindowHeight,
448 NULL, // parent
449 NULL, // menu
450 instance,
451 NULL);
452 if(!windowHandle)
453 {
454 fprintf(stderr, "error: failed to create window\n");
455 return 1;
456 }
457
458
459 // Rather than statically link against D3D, we load it dynamically.
460
461 HMODULE d3d11 = LoadLibraryA("d3d11.dll");
462 if(!d3d11)
463 {
464 fprintf(stderr, "error: failed load 'd3d11.dll'\n");
465 return 1;

Callers

nothing calls this directly

Calls 3

initializeFunction · 0.85
renderFrameFunction · 0.85
GetBufferMethod · 0.80

Tested by

no test coverage detected