创建窗口

    #include 

    LRESULT CALLBACK RenderWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
      switch (msg) {
        case WM_CLOSE:
            PostQuitMessage(0);
            break;
      }
        return DefWindowProc(hwnd, msg, wParam, lParam);
    }

    INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd) {
        WNDCLASSEX wndClass;
        wndClass.cbClsExtra = 0;
        wndClass.cbSize = sizeof(WNDCLASSEX);
        wndClass.cbWndExtra = 0;
        wndClass.hbrBackground = NULL;
        wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
        wndClass.hIcon = NULL;
        wndClass.hIconSm = NULL;
        wndClass.hInstance = hInstance;
        wndClass.lpfnWndProc = (WNDPROC)RenderWindowProc;
        wndClass.lpszClassName = L"OpenGLWindow";
        wndClass.lpszMenuName = NULL;
        wndClass.style = CS_HREDRAW | CS_VREDRAW;

        ATOM atom = RegisterClassEx(&wndClass);

        HWND hwnd = CreateWindowEx(NULL, L"OpenGLWindow", L"OpenGL Render Window", WS_OVERLAPPEDWINDOW, 100, 100, 800, 600, NULL, NULL, hInstance, NULL);

        ShowWindow(hwnd, SW_SHOW);
        UpdateWindow(hwnd);

        MSG msg;

        while (true) {
            if (PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE)) {
                if (msg.message == WM_QUIT) {
                    break;
                }
                TranslateMessage(&msg);
                DispatchMessage(&msg);
            }
        }

        return 0;
    }

你可能感兴趣的:(创建窗口)