質問編集履歴
1
提示コードをリファクタリングしました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -31,8 +31,10 @@
|
|
31
31
|
|
32
32
|
}
|
33
33
|
break;
|
34
|
+
|
35
|
+
//////////////////////////////////////////////////////////////
|
34
36
|
case WM_PAINT:
|
35
|
-
{
|
37
|
+
{
|
36
38
|
printf("Paint\n");
|
37
39
|
|
38
40
|
PAINTSTRUCT ps;
|
@@ -51,8 +53,10 @@
|
|
51
53
|
EndPaint( hWnd, &ps );
|
52
54
|
|
53
55
|
|
54
|
-
}
|
56
|
+
}
|
55
57
|
break;
|
58
|
+
//////////////////////////////////////////////////////////////
|
59
|
+
|
56
60
|
case WM_SIZE:
|
57
61
|
{
|
58
62
|
printf("Size\n");
|
@@ -74,24 +78,23 @@
|
|
74
78
|
{
|
75
79
|
Debug::CreateConsoleWindow();
|
76
80
|
|
77
|
-
|
81
|
+
HWND hWnd = { 0 };//ウインドウハンドル
|
78
|
-
MSG msg
|
82
|
+
MSG msg = { 0 };//スレッドのメッセージキュー情報
|
79
|
-
WNDCLASS wc;//汎用ウインドウ
|
83
|
+
WNDCLASS wc; //汎用ウインドウ
|
80
|
-
HGLRC glRC;
|
84
|
+
HGLRC glRC; //OpenGLレンダリングコンテキスト
|
81
|
-
HDC dc;
|
85
|
+
HDC dc; //デバイスコンテキスト
|
82
86
|
|
83
|
-
int _format;
|
84
87
|
|
85
|
-
wc.style
|
88
|
+
wc.style = CS_HREDRAW | CS_VREDRAW; //ウインドウのスタイル(ウインドウサイズを変更すると自動調整)
|
86
|
-
wc.lpfnWndProc
|
89
|
+
wc.lpfnWndProc = WndProc; //ウインドウプロシージャを設定
|
87
|
-
wc.cbClsExtra
|
90
|
+
wc.cbClsExtra = 0; //構造体の後ろに補足バイト数
|
88
|
-
wc.cbWndExtra
|
91
|
+
wc.cbWndExtra = 0; //ウインドウインスタンスの後ろに補足バイト数
|
89
|
-
wc.hInstance
|
92
|
+
wc.hInstance = hInstance; //ウインドウプロシージャがあるインスタンスハンドル
|
90
|
-
wc.hIcon
|
93
|
+
wc.hIcon = NULL; //アイコンのハンドル
|
91
|
-
wc.hCursor
|
94
|
+
wc.hCursor = LoadCursor(NULL,IDC_ARROW); //マウスカーソルのハンドル
|
92
|
-
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);//ウインドウ背景色
|
95
|
+
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); //ウインドウ背景色
|
93
|
-
wc.lpszMenuName
|
96
|
+
wc.lpszMenuName = NULL; //デフォルトのメニュー名
|
94
|
-
wc.lpszClassName = TEXT("WinAPITest");//ウインドウクラスに付ける名前
|
97
|
+
wc.lpszClassName = TEXT("WinAPITest"); //ウインドウクラスに付ける名前
|
95
98
|
|
96
99
|
if( !RegisterClass(&wc))
|
97
100
|
{
|
@@ -133,8 +136,10 @@
|
|
133
136
|
0,0,0
|
134
137
|
};
|
135
138
|
|
139
|
+
|
136
|
-
dc = GetDC(hWnd);
|
140
|
+
dc = GetDC(hWnd);//ディスプレイデバイスコンテキスト
|
141
|
+
int _format;
|
137
|
-
_format = ChoosePixelFormat(dc,&pfd);
|
142
|
+
_format = ChoosePixelFormat(dc,&pfd);//ピクセルフォーマットを指定
|
138
143
|
if(_format == 0)
|
139
144
|
{
|
140
145
|
printf("%d\n",GetLastError());//Error
|
@@ -153,13 +158,7 @@
|
|
153
158
|
printf("%d\n",GetLastError());//Error
|
154
159
|
}
|
155
160
|
|
156
|
-
glewExperimental = TRUE;
|
157
|
-
GLenum err = glewInit();
|
158
|
-
if(err != GLEW_OK)
|
159
|
-
{
|
160
|
-
|
161
|
+
//指定されたOpenGLのレンダリングコンテキスト呼び出す
|
161
|
-
}
|
162
|
-
|
163
162
|
wglMakeCurrent(dc, glRC);
|
164
163
|
|
165
164
|
while(true)
|
@@ -174,6 +173,10 @@
|
|
174
173
|
glFlush();
|
175
174
|
SwapBuffers(dc);
|
176
175
|
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
//終了処理
|
177
180
|
MSG msg;
|
178
181
|
if( PeekMessageW(&msg,hWnd,0,0,PM_REMOVE) )
|
179
182
|
{
|
@@ -184,8 +187,7 @@
|
|
184
187
|
|
185
188
|
TranslateMessage(&msg);
|
186
189
|
DispatchMessage(&msg);
|
187
|
-
|
190
|
+
|
188
|
-
//printf("%s\n",msg.message);
|
189
191
|
}
|
190
192
|
|
191
193
|
UpdateWindow(hWnd);
|