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

Function demo_create_window

cube/cube.c:2781–2828  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2779}
2780
2781static void demo_create_window(struct demo *demo) {
2782 WNDCLASSEX win_class;
2783
2784 // Initialize the window class structure:
2785 win_class.cbSize = sizeof(WNDCLASSEX);
2786 win_class.style = CS_HREDRAW | CS_VREDRAW;
2787 win_class.lpfnWndProc = WndProc;
2788 win_class.cbClsExtra = 0;
2789 win_class.cbWndExtra = 0;
2790 win_class.hInstance = demo->connection; // hInstance
2791 win_class.hIcon = LoadIcon(NULL, IDI_APPLICATION);
2792 win_class.hCursor = LoadCursor(NULL, IDC_ARROW);
2793 win_class.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
2794 win_class.lpszMenuName = NULL;
2795 win_class.lpszClassName = demo->name;
2796 win_class.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
2797 // Register window class:
2798 if (!RegisterClassEx(&win_class)) {
2799 // It didn't work, so try to give a useful error:
2800 printf("Unexpected error trying to start the application!\n");
2801 fflush(stdout);
2802 exit(1);
2803 }
2804 // Create window with the registered class:
2805 RECT wr = {0, 0, demo->width, demo->height};
2806 AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE);
2807 demo->window = CreateWindowEx(0,
2808 demo->name, // class name
2809 demo->name, // app name
2810 WS_OVERLAPPEDWINDOW | // window style
2811 WS_VISIBLE | WS_SYSMENU,
2812 100, 100, // x/y coords
2813 wr.right - wr.left, // width
2814 wr.bottom - wr.top, // height
2815 NULL, // handle to parent
2816 NULL, // handle to menu
2817 demo->connection, // hInstance
2818 NULL); // no extra parameters
2819 if (!demo->window) {
2820 // It didn't work, so try to give a useful error:
2821 printf("Cannot create a window in which to draw!\n");
2822 fflush(stdout);
2823 exit(1);
2824 }
2825 // Window client area size must be at least 1 pixel high, to prevent crash.
2826 demo->minsize.x = GetSystemMetrics(SM_CXMINTRACK);
2827 demo->minsize.y = GetSystemMetrics(SM_CYMINTRACK) + 1;
2828}
2829#endif
2830#if defined(VK_USE_PLATFORM_XLIB_KHR)
2831static void demo_create_xlib_window(struct demo *demo) {

Callers 1

WinMainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected