• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

milligram


Commit MetaInfo

Révision44065f750b951e4ca760190741435dfeac1073d2 (tree)
l'heure2011-03-21 21:19:44
Auteurberu <berupon@gmai...>
Commiterberu

Message de Log

changed frame rates adjustment routine

Change Summary

Modification

--- a/main.cpp
+++ b/main.cpp
@@ -27,26 +27,27 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
2727 {
2828 UNREFERENCED_PARAMETER(hPrevInstance);
2929 UNREFERENCED_PARAMETER(lpCmdLine);
30-
30+
3131 // TODO: ここにコードを挿入してください。
3232 MSG msg;
3333 HACCEL hAccelTable;
34-
34+
3535 // グローバル文字列を初期化しています。
3636 LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
3737 LoadString(hInstance, IDC_MG, szWindowClass, MAX_LOADSTRING);
3838 MyRegisterClass(hInstance);
39-
39+
4040 // アプリケーションの初期化を実行します:
4141 if (!InitInstance (hInstance, nCmdShow))
4242 {
4343 return FALSE;
4444 }
45-
45+
4646 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+
5051 // メイン メッセージ ループ:
5152 while (1) {
5253 BOOL ret = GetMessage(&msg, NULL, 0, 0);
@@ -62,14 +63,13 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
6263 TranslateMessage(&msg);
6364 DispatchMessage(&msg);
6465 }
65-
6666 DWORD now = ::timeGetTime();
67- if (now - lastTime >= 10) {
67+ if (now - lastTime >= MS_PER_FRAME) {
6868 OnTime(msg.hwnd);
69- lastTime = now;
69+ lastTime += MS_PER_FRAME;
7070 }
7171 }
72-
72+
7373 return (int) msg.wParam;
7474 }
7575
--- a/main_plus.cpp
+++ b/main_plus.cpp
@@ -157,7 +157,9 @@ void OnCreate(HWND hWnd, WPARAM wParam, LPARAM lParam)
157157 hMemDC = ::CreateCompatibleDC(hWndDC);
158158 ::SetMapMode(hMemDC, ::GetMapMode(hWndDC));
159159 ::ReleaseDC(hWnd, hWndDC);
160- ::SelectObject(hMemDC, hBMP);
160+ ::SelectObject(hMemDC, hBMP);
161+
162+ mg.Draw(0, 0, renderer);
161163 }
162164
163165 void OnDestroy(HWND hWnd, WPARAM wParam, LPARAM lParam)