milligram
Revisión | 44065f750b951e4ca760190741435dfeac1073d2 (tree) |
---|---|
Tiempo | 2011-03-21 21:19:44 |
Autor | beru <berupon@gmai...> |
Commiter | beru |
changed frame rates adjustment routine
@@ -27,26 +27,27 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, | ||
27 | 27 | { |
28 | 28 | UNREFERENCED_PARAMETER(hPrevInstance); |
29 | 29 | UNREFERENCED_PARAMETER(lpCmdLine); |
30 | - | |
30 | + | |
31 | 31 | // TODO: ここにコードを挿入してください。 |
32 | 32 | MSG msg; |
33 | 33 | HACCEL hAccelTable; |
34 | - | |
34 | + | |
35 | 35 | // グローバル文字列を初期化しています。 |
36 | 36 | LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); |
37 | 37 | LoadString(hInstance, IDC_MG, szWindowClass, MAX_LOADSTRING); |
38 | 38 | MyRegisterClass(hInstance); |
39 | - | |
39 | + | |
40 | 40 | // アプリケーションの初期化を実行します: |
41 | 41 | if (!InitInstance (hInstance, nCmdShow)) |
42 | 42 | { |
43 | 43 | return FALSE; |
44 | 44 | } |
45 | - | |
45 | + | |
46 | 46 | hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_MG)); |
47 | - | |
48 | - DWORD lastTime = ::timeGetTime(); | |
49 | - | |
47 | + | |
48 | + static const size_t MS_PER_FRAME = 20; | |
49 | + DWORD lastTime = ::timeGetTime() + MS_PER_FRAME; | |
50 | + | |
50 | 51 | // メイン メッセージ ループ: |
51 | 52 | while (1) { |
52 | 53 | BOOL ret = GetMessage(&msg, NULL, 0, 0); |
@@ -62,14 +63,13 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, | ||
62 | 63 | TranslateMessage(&msg); |
63 | 64 | DispatchMessage(&msg); |
64 | 65 | } |
65 | - | |
66 | 66 | DWORD now = ::timeGetTime(); |
67 | - if (now - lastTime >= 10) { | |
67 | + if (now - lastTime >= MS_PER_FRAME) { | |
68 | 68 | OnTime(msg.hwnd); |
69 | - lastTime = now; | |
69 | + lastTime += MS_PER_FRAME; | |
70 | 70 | } |
71 | 71 | } |
72 | - | |
72 | + | |
73 | 73 | return (int) msg.wParam; |
74 | 74 | } |
75 | 75 |
@@ -157,7 +157,9 @@ void OnCreate(HWND hWnd, WPARAM wParam, LPARAM lParam) | ||
157 | 157 | hMemDC = ::CreateCompatibleDC(hWndDC); |
158 | 158 | ::SetMapMode(hMemDC, ::GetMapMode(hWndDC)); |
159 | 159 | ::ReleaseDC(hWnd, hWndDC); |
160 | - ::SelectObject(hMemDC, hBMP); | |
160 | + ::SelectObject(hMemDC, hBMP); | |
161 | + | |
162 | + mg.Draw(0, 0, renderer); | |
161 | 163 | } |
162 | 164 | |
163 | 165 | void OnDestroy(HWND hWnd, WPARAM wParam, LPARAM lParam) |