You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.5 KiB

  1. #include <windows.h>
  2. /**
  3. *Ϣ
  4. */
  5. LRESULT CALLBACK GLWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  6. {
  7. switch (msg)
  8. {
  9. case WM_CLOSE:
  10. PostQuitMessage(0);
  11. return 0;
  12. }
  13. return DefWindowProc(hwnd, msg, wParam, lParam);
  14. }
  15. INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
  16. {
  17. /*ע�ᴰ��*/
  18. WNDCLASSEX wndclass;
  19. wndclass.cbClsExtra = 0;
  20. wndclass.cbSize = sizeof(WNDCLASSEX);
  21. wndclass.cbWndExtra = 0;
  22. wndclass.hbrBackground = NULL;
  23. wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  24. wndclass.hIcon = NULL;
  25. wndclass.hIconSm = NULL;
  26. wndclass.hInstance = hInstance;
  27. wndclass.lpfnWndProc = GLWindowProc;
  28. wndclass.lpszClassName = L"GLWindow";
  29. wndclass.lpszMenuName = NULL;
  30. wndclass.style = CS_VREDRAW | CS_HREDRAW;
  31. ATOM atom = RegisterClassEx(&wndclass);
  32. if (!atom) {
  33. MessageBox(NULL, L"Register Fail", L"Error", MB_OK);
  34. return 0;
  35. }
  36. /*��������*/
  37. RECT rect;
  38. rect.left = 0;
  39. rect.right = 800;
  40. rect.top = 0;
  41. rect.bottom = 600;
  42. AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, NULL);
  43. int windowWidth = rect.right - rect.left;
  44. int windowHeight = rect.bottom - rect.top;
  45. HWND hwnd = CreateWindowEx(NULL, L"GLWindow", L"OpenGL Window", WS_OVERLAPPEDWINDOW,
  46. 100, 100, windowWidth, windowHeight,
  47. NULL, NULL, hInstance, NULL);
  48. ShowWindow(hwnd, SW_SHOW);
  49. UpdateWindow(hwnd);
  50. MSG msg;
  51. while (true)
  52. {
  53. if (PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE))
  54. {
  55. if (msg.message == WM_QUIT)
  56. {
  57. break;
  58. }
  59. TranslateMessage(&msg);
  60. DispatchMessage(&msg);
  61. }
  62. }
  63. return 0;
  64. }