Created
June 3, 2016 17:40
-
-
Save daramkun/556ac504fd05a172411663abb808b92d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <Windows.h> | |
| ////////////////////////////////////////////////////////////////// | |
| // TODO: Global Variables for Direct3D | |
| bool InitializeDirect3D ( HWND hWnd ) | |
| { | |
| // TODO: Initializing Direct3D | |
| return true; | |
| } | |
| void UninitializeDirect3D () | |
| { | |
| // TODO: Uninitializing Direct3D | |
| } | |
| void Loop () | |
| { | |
| // TODO: Rendering | |
| } | |
| ////////////////////////////////////////////////////////////////// | |
| #pragma region Precode | |
| LRESULT CALLBACK WndProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) | |
| { | |
| switch ( uMsg ) | |
| { | |
| case WM_CLOSE: PostQuitMessage ( 0 ); break; | |
| default: return DefWindowProc ( hWnd, uMsg, wParam, lParam ); | |
| } | |
| return 0; | |
| } | |
| HWND InitializeWindow ( int width = 1280, int height = 720 ) | |
| { | |
| WNDCLASS wndClass = { CS_HREDRAW | CS_VREDRAW, WndProc, 0, 0, nullptr, | |
| LoadIcon ( nullptr, IDI_APPLICATION ), LoadCursor ( nullptr, IDC_ARROW ), | |
| nullptr, nullptr, TEXT ( "Win32AppWindow" ) }; | |
| if ( RegisterClass ( &wndClass ) == 0 ) | |
| return 0; | |
| RECT rect = { 0, 0, width, height }; | |
| AdjustWindowRect ( &rect, WS_OVERLAPPEDWINDOW, false ); | |
| int w = rect.right - rect.left, h = rect.bottom - rect.top; | |
| int x = GetSystemMetrics ( SM_CXSCREEN ) / 2 - w / 2, y = GetSystemMetrics ( SM_CYSCREEN ) / 2 - h / 2; | |
| return CreateWindow ( TEXT ( "Win32AppWindow" ), TEXT ( "Application" ), WS_OVERLAPPEDWINDOW, | |
| x, y, w, h, nullptr, nullptr, GetModuleHandle ( nullptr ), nullptr ); | |
| } | |
| void RunWindow ( HWND hWnd ) | |
| { | |
| ShowWindow ( hWnd, SW_SHOW ); | |
| UpdateWindow ( hWnd ); | |
| MSG msg; | |
| while ( true ) | |
| { | |
| if ( PeekMessage ( &msg, nullptr, 0, 0, PM_NOREMOVE ) ) | |
| { | |
| if ( !GetMessage ( &msg, nullptr, 0, 0 ) ) | |
| return; | |
| TranslateMessage ( &msg ); | |
| DispatchMessage ( &msg ); | |
| } | |
| else | |
| { | |
| Loop (); | |
| Sleep ( 1 ); | |
| } | |
| } | |
| } | |
| int WINAPI WinMain ( HINSTANCE, HINSTANCE, LPSTR, int ) | |
| { | |
| HWND hWnd = InitializeWindow (); | |
| if ( hWnd == nullptr ) return -1; | |
| if ( !InitializeDirect3D ( hWnd ) ) return -2; | |
| RunWindow ( hWnd ); | |
| UninitializeDirect3D (); | |
| return 0; | |
| } | |
| #pragma endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment