Index: dxgltest/Tests2D.cpp |
— | — | @@ -25,6 +25,7 @@ |
26 | 26 | void InitTest(int test);
|
27 | 27 | void RunTestTimed(int test);
|
28 | 28 | void RunTestLooped(int test);
|
| 29 | +void RunTestMouse(int test, UINT Msg, WPARAM wParam, LPARAM lParam);
|
29 | 30 | inline unsigned int rand32(unsigned int &n)
|
30 | 31 | {
|
31 | 32 | return n=(((unsigned int) 1103515245 * n) + (unsigned int) 12345) %
|
— | — | @@ -47,7 +48,7 @@ |
48 | 49 | HWND hWnd;
|
49 | 50 | int testnum;
|
50 | 51 | unsigned int randnum;
|
51 | | -int testtypes[] = {0,1,0,1,0,1};
|
| 52 | +int testtypes[] = {0,1,0,1,0,1,2};
|
52 | 53 |
|
53 | 54 | typedef struct
|
54 | 55 | {
|
— | — | @@ -70,6 +71,7 @@ |
71 | 72 | POINT p;
|
72 | 73 | RECT srcrect,destrect;
|
73 | 74 | HRESULT error;
|
| 75 | + PAINTSTRUCT paintstruct;
|
74 | 76 | switch(Msg)
|
75 | 77 | {
|
76 | 78 | case WM_CLOSE:
|
— | — | @@ -114,6 +116,7 @@ |
115 | 117 | break;
|
116 | 118 | case WM_SIZE:
|
117 | 119 | case WM_PAINT:
|
| 120 | + BeginPaint(hWnd,&paintstruct);
|
118 | 121 | if(!fullscreen)
|
119 | 122 | {
|
120 | 123 | p.x = 0;
|
— | — | @@ -124,7 +127,21 @@ |
125 | 128 | SetRect(&srcrect,0,0,width,height);
|
126 | 129 | if(ddsurface && ddsrender)error = ddsurface->Blt(&destrect,ddsrender,&srcrect,DDBLT_WAIT,NULL);
|
127 | 130 | }
|
128 | | - return FALSE;
|
| 131 | + EndPaint(hWnd,&paintstruct);
|
| 132 | + return 0;
|
| 133 | + case WM_MOUSEMOVE:
|
| 134 | + RunTestMouse(testnum,WM_MOUSEMOVE,wParam,lParam);
|
| 135 | + if(!fullscreen)
|
| 136 | + {
|
| 137 | + p.x = 0;
|
| 138 | + p.y = 0;
|
| 139 | + ClientToScreen(hWnd,&p);
|
| 140 | + GetClientRect(hWnd,&destrect);
|
| 141 | + OffsetRect(&destrect,p.x,p.y);
|
| 142 | + SetRect(&srcrect,0,0,width,height);
|
| 143 | + if(ddsurface && ddsrender)error = ddsurface->Blt(&destrect,ddsrender,&srcrect,DDBLT_WAIT,NULL);
|
| 144 | + }
|
| 145 | + break;
|
129 | 146 | default:
|
130 | 147 | return DefWindowProc(hWnd,Msg,wParam,lParam);
|
131 | 148 | }
|
— | — | @@ -131,10 +148,91 @@ |
132 | 149 | return FALSE;
|
133 | 150 | }
|
134 | 151 |
|
| 152 | +int ddtestnum;
|
| 153 | +int ddver;
|
135 | 154 |
|
| 155 | +void RunTestMouse(int test, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| 156 | +{
|
| 157 | + DDSURFACEDESC2 ddsd;
|
| 158 | + ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
| 159 | + DDBLTFX bltfx;
|
| 160 | + unsigned char *surface;
|
| 161 | + int bytes;
|
| 162 | + unsigned int x,y;
|
| 163 | + bool out = false;
|
| 164 | + bool msgbottom = false;
|
| 165 | + TCHAR message[256];
|
| 166 | + message[0] = 0;
|
| 167 | + HDC hDC;
|
| 168 | + switch(test)
|
| 169 | + {
|
| 170 | + case 6:
|
| 171 | + x = LOWORD(lParam);
|
| 172 | + y = HIWORD(lParam);
|
| 173 | + ZeroMemory(&bltfx,sizeof(DDBLTFX));
|
| 174 | + bltfx.dwSize = sizeof(DDBLTFX);
|
| 175 | + bltfx.dwFillColor = 0;
|
| 176 | + ddsrender->Blt(NULL,NULL,NULL,DDBLT_COLORFILL,&bltfx);
|
| 177 | + if(ddver > 3)ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
| 178 | + else ddsd.dwSize = sizeof(DDSURFACEDESC);
|
| 179 | + ddsrender->GetSurfaceDesc(&ddsd);
|
| 180 | + switch(ddsd.ddpfPixelFormat.dwRGBBitCount)
|
| 181 | + {
|
| 182 | + case 8:
|
| 183 | + bytes=1;
|
| 184 | + break;
|
| 185 | + case 15:
|
| 186 | + case 16:
|
| 187 | + bytes=2;
|
| 188 | + break;
|
| 189 | + case 24:
|
| 190 | + bytes=3;
|
| 191 | + break;
|
| 192 | + case 32:
|
| 193 | + default:
|
| 194 | + bytes=4;
|
| 195 | + }
|
| 196 | + _tcscpy(message,_T("Message: "));
|
| 197 | + switch(Msg)
|
| 198 | + {
|
| 199 | + case WM_MOUSEMOVE:
|
| 200 | + _tcscat(message,_T("WM_MOUSEMOVE "));
|
| 201 | + break;
|
| 202 | + default:
|
| 203 | + _tcscat(message,_T("unknown "));
|
| 204 | + }
|
| 205 | + _tcscat(message,_T("Keys: "));
|
| 206 | + if(wParam & MK_CONTROL) _tcscat(message, _T("CTRL "));
|
| 207 | + if(wParam & MK_SHIFT) _tcscat(message,_T("SHIFT "));
|
| 208 | + _tcscat(message,_T("Buttons: "));
|
| 209 | + if(wParam & MK_LBUTTON) _tcscat(message,_T("L "));
|
| 210 | + if(wParam & MK_MBUTTON) _tcscat(message,_T("M "));
|
| 211 | + if(wParam & MK_RBUTTON) _tcscat(message,_T("R "));
|
| 212 | + if(wParam & MK_XBUTTON1) _tcscat(message,_T("X1 "));
|
| 213 | + if(wParam & MK_XBUTTON2) _tcscat(message,_T("X2 "));
|
| 214 | + // Add X and Y
|
| 215 | + ddsrender->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL);
|
| 216 | + surface = (unsigned char *)ddsd.lpSurface;
|
| 217 | + if((x > ddsd.dwWidth) || (y > ddsd.dwHeight))
|
| 218 | + {
|
| 219 | + out = true;
|
| 220 | + _tcscat(message,_T(" OUT OF BOUNDS"));
|
| 221 | + }
|
| 222 | + else surface[(x*bytes)+(y*ddsd.lPitch)] = 0xFF;
|
| 223 | + ddsrender->Unlock(NULL);
|
| 224 | + ddsrender->GetDC(&hDC);
|
| 225 | + if(out)SetBkColor(hDC,RGB(255,0,0));
|
| 226 | + else SetBkColor(hDC,RGB(0,0,255));
|
| 227 | + SetTextColor(hDC,RGB(255,255,255));
|
| 228 | + if(y > ddsd.dwHeight / 2) TextOut(hDC,0,0,message,_tcslen(message));
|
| 229 | + else TextOut(hDC,0,ddsd.dwHeight-16,message,_tcslen(message));
|
| 230 | + ddsrender->ReleaseDC(hDC);
|
| 231 | + break;
|
| 232 | + default:
|
| 233 | + break;
|
| 234 | + }
|
| 235 | +}
|
136 | 236 |
|
137 | | -int ddtestnum;
|
138 | | -int ddver;
|
139 | 237 | const TCHAR wndclassname2d[] = _T("DDTestWndClass");
|
140 | 238 | void RunTest2D(int testnum, int width, int height, int bpp, int refresh, int backbuffers, int apiver,
|
141 | 239 | double fps, bool fullscreen, bool resizable)
|
— | — | @@ -168,7 +266,8 @@ |
169 | 267 | wc.hInstance = hinstance;
|
170 | 268 | wc.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(IDI_DXGL));
|
171 | 269 | wc.hIconSm = LoadIcon(hinstance,MAKEINTRESOURCE(IDI_DXGLSM));
|
172 | | - wc.hCursor = LoadCursor(NULL,IDC_ARROW);
|
| 270 | + if(testnum == 6) wc.hCursor = LoadCursor(NULL,IDC_CROSS);
|
| 271 | + else wc.hCursor = LoadCursor(NULL,IDC_ARROW);
|
173 | 272 | wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
174 | 273 | wc.lpszClassName = wndclassname2d;
|
175 | 274 | if(!RegisterClassEx(&wc))
|
— | — | @@ -259,7 +358,7 @@ |
260 | 359 | }
|
261 | 360 | }
|
262 | 361 | }
|
263 | | - else
|
| 362 | + else if(testtypes[testnum] == 0)
|
264 | 363 | {
|
265 | 364 | StartTimer(hWnd,WM_APP,fps);
|
266 | 365 | while(GetMessage(&Msg, NULL, 0, 0) > 0)
|
— | — | @@ -268,6 +367,14 @@ |
269 | 368 | DispatchMessage(&Msg);
|
270 | 369 | }
|
271 | 370 | }
|
| 371 | + else
|
| 372 | + {
|
| 373 | + while(GetMessage(&Msg, NULL, 0, 0) > 0)
|
| 374 | + {
|
| 375 | + TranslateMessage(&Msg);
|
| 376 | + DispatchMessage(&Msg);
|
| 377 | + }
|
| 378 | + }
|
272 | 379 | UnregisterClass(wndclassname2d,hinstance);
|
273 | 380 | StopTimer();
|
274 | 381 | }
|
Index: dxgltest/dxgltest.cpp |
— | — | @@ -198,7 +198,8 @@ |
199 | 199 | {1, 7, 0, 7, true, 1.0, false, false, _T("GDI Test patterns (GetDC() test)")},
|
200 | 200 | {1, 7, 0, 0, false, 0.0, false, false, _T("Random GDI patterns (does not clear screen between paints)")},
|
201 | 201 | {1, 7, 0, 1, true, 60.0, false, false, _T("BltFast background and sprites")},
|
202 | | - {1, 7, 0, 0, false, 0.0, false, false, _T("Random color fill Blt() patterns")}
|
| 202 | + {1, 7, 0, 0, false, 0.0, false, false, _T("Random color fill Blt() paterns")},
|
| 203 | + {1, 7, 0, 0, false, 0.0, false, false, _T("Mouse pointer event test")}
|
203 | 204 | };
|
204 | 205 | const int END_2D = __LINE__ - 4;
|
205 | 206 | const int numtests2d = END_2D - START_2D;
|