ReactOS  0.4.11-dev-946-g431643b
ddtest.c File Reference
#include "precomp.h"
Include dependency graph for ddtest.c:

Go to the source code of this file.

Macros

#define TEST_DURATION   10000
 
#define DD_TEST_WIDTH   640
 
#define DD_TEST_HEIGHT   480
 
#define DD_TEST_STEP   5
 
#define DD_SQUARE_SIZE   100
 
#define DD_SQUARE_STEP   2
 

Functions

BOOL DDPrimarySurfaceTest (HWND hWnd)
 
BOOL DDOffscreenBufferTest (HWND hWnd, BOOL Fullscreen)
 
VOID DDRedrawFrame (LPDIRECTDRAWSURFACE lpDDSurface)
 
VOID DDUpdateFrame (LPDIRECTDRAWSURFACE lpDDPrimarySurface, LPDIRECTDRAWSURFACE lpDDBackBuffer, BOOL Fullscreen, INT *posX, INT *posY, INT *gainX, INT *gainY, RECT *rectDD)
 
BOOL StartDDTest (HWND hWnd, HINSTANCE hInstance, INT resTestDescription, INT resResult, INT TestNr)
 
VOID DDTests ()
 

Macro Definition Documentation

◆ DD_SQUARE_SIZE

#define DD_SQUARE_SIZE   100

Definition at line 21 of file ddtest.c.

Referenced by DDUpdateFrame().

◆ DD_SQUARE_STEP

#define DD_SQUARE_STEP   2

Definition at line 22 of file ddtest.c.

Referenced by DDOffscreenBufferTest().

◆ DD_TEST_HEIGHT

#define DD_TEST_HEIGHT   480

Definition at line 19 of file ddtest.c.

Referenced by DDOffscreenBufferTest(), DDRedrawFrame(), DDTests(), and DDUpdateFrame().

◆ DD_TEST_STEP

#define DD_TEST_STEP   5

Definition at line 20 of file ddtest.c.

Referenced by DDRedrawFrame().

◆ DD_TEST_WIDTH

#define DD_TEST_WIDTH   640

Definition at line 18 of file ddtest.c.

Referenced by DDOffscreenBufferTest(), DDRedrawFrame(), DDTests(), and DDUpdateFrame().

◆ TEST_DURATION

#define TEST_DURATION   10000

Definition at line 17 of file ddtest.c.

Referenced by DDOffscreenBufferTest(), and DDPrimarySurfaceTest().

Function Documentation

◆ DDOffscreenBufferTest()

BOOL DDOffscreenBufferTest ( HWND  hWnd,
BOOL  Fullscreen 
)

Definition at line 201 of file ddtest.c.

Referenced by StartDDTest().

201  {
202  UINT_PTR TimerID, TimerIDUpdate;
203  LPDIRECTDRAW lpDD;
204  LPDIRECTDRAWSURFACE lpDDPrimarySurface;
205  LPDIRECTDRAWSURFACE lpDDBackBuffer;
206  DDSURFACEDESC DDSurfaceDesc;
207  DDSURFACEDESC DDBBSurfaceDesc;
208  DDSCAPS DDSCaps;
209  MSG msg;
210  RECT rectDD;
211  POINT wndPoint;
212  INT posX = 0, posY = 10, xGain = DD_SQUARE_STEP, yGain = DD_SQUARE_STEP;
213 
214  if(DirectDrawCreate(NULL, &lpDD, NULL) != DD_OK)
215  return FALSE;
216 
217  ZeroMemory(&DDSurfaceDesc, sizeof(DDSurfaceDesc));
218  DDSurfaceDesc.dwSize = sizeof(DDSurfaceDesc);
219 
220  if(Fullscreen)
221  {
222  if(lpDD->lpVtbl->SetCooperativeLevel(lpDD, hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) != DD_OK)
223  {
224  lpDD->lpVtbl->Release(lpDD);
225  return FALSE;
226  }
227  if(lpDD->lpVtbl->SetDisplayMode(lpDD, DD_TEST_WIDTH, DD_TEST_HEIGHT, 32) != DD_OK)
228  {
229  lpDD->lpVtbl->Release(lpDD);
230  return FALSE;
231  }
232  DDSurfaceDesc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
233  DDSurfaceDesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
234  DDSurfaceDesc.dwBackBufferCount = 1;
235  }
236  else
237  {
238  if(lpDD->lpVtbl->SetCooperativeLevel(lpDD, hWnd, DDSCL_NORMAL) != DD_OK)
239  {
240  lpDD->lpVtbl->Release(lpDD);
241  return FALSE;
242  }
243  DDSurfaceDesc.dwFlags = DDSD_CAPS;
244  DDSurfaceDesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
245  }
246 
247 
248  if(lpDD->lpVtbl->CreateSurface(lpDD, &DDSurfaceDesc, &lpDDPrimarySurface, NULL) != DD_OK)
249  {
250  lpDD->lpVtbl->Release(lpDD);
251  return FALSE;
252  }
253 
254  if(Fullscreen)
255  {
256  DDSCaps.dwCaps = DDSCAPS_BACKBUFFER;
257  if (lpDDPrimarySurface->lpVtbl->GetAttachedSurface(lpDDPrimarySurface, &DDSCaps,&lpDDBackBuffer) != DD_OK)
258  {
259  lpDDPrimarySurface->lpVtbl->Release(lpDDPrimarySurface);
260  lpDD->lpVtbl->Release(lpDD);
261  return FALSE;
262  }
263  }
264  else
265  {
266  /* create our offscreen back buffer */
267  ZeroMemory(&DDBBSurfaceDesc,sizeof(DDBBSurfaceDesc));
268  DDBBSurfaceDesc.dwSize = sizeof(DDBBSurfaceDesc);
269  DDBBSurfaceDesc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
270  DDBBSurfaceDesc.dwHeight = DD_TEST_HEIGHT;
271  DDBBSurfaceDesc.dwWidth = DD_TEST_WIDTH;
272  DDBBSurfaceDesc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
273 
274  if(lpDD->lpVtbl->CreateSurface(lpDD, &DDBBSurfaceDesc, &lpDDBackBuffer, NULL) != DD_OK)
275  {
276  lpDD->lpVtbl->Release(lpDD);
277  lpDDPrimarySurface->lpVtbl->Release(lpDDPrimarySurface);
278  return FALSE;
279  }
280  wndPoint.x = 0;
281  wndPoint.y = 0;
282  ClientToScreen(hWnd, &wndPoint);
283  GetClientRect(hWnd, &rectDD);
284  OffsetRect(&rectDD, wndPoint.x, wndPoint.y);
285  }
286 
287  /* set our timers, TimerID - for test timeout, TimerIDUpdate - for frame updating */
288  TimerID = SetTimer(hWnd, -1, (UINT)TEST_DURATION, NULL);
289  TimerIDUpdate = SetTimer(hWnd, 2, (UINT)10, NULL);
290  (void)TimerIDUpdate;
291 
292  while (TRUE)
293  {
294  if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
295  {
296  if (msg.message == WM_TIMER)
297  {
298  if(msg.wParam == TimerID)
299  {
300  break;
301  }
302  else
303  {
304  DDUpdateFrame(lpDDPrimarySurface,lpDDBackBuffer, Fullscreen,&posX, &posY, &xGain, &yGain, &rectDD);
305  }
306  }
307  TranslateMessage(&msg);
308  DispatchMessage(&msg);
309  }
310  }
311 
312  lpDDPrimarySurface->lpVtbl->Release(lpDDPrimarySurface);
313  /* backbuffer is released automatically when in fullscreen */
314  if(!Fullscreen)
315  lpDDBackBuffer->lpVtbl->Release(lpDDBackBuffer);
316  lpDD->lpVtbl->Release(lpDD);
317 
318 return TRUE;
319 }
#define DispatchMessage
Definition: winuser.h:5631
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define PeekMessage
Definition: winuser.h:5696
#define TRUE
Definition: types.h:120
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
long y
Definition: polytest.cpp:48
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
long x
Definition: polytest.cpp:48
DWORD dwCaps
Definition: ddraw.h:727
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define ZeroMemory
Definition: winbase.h:1635
#define DD_TEST_WIDTH
Definition: ddtest.c:18
#define DD_TEST_HEIGHT
Definition: ddtest.c:19
int32_t INT
Definition: typedefs.h:56
#define TEST_DURATION
Definition: ddtest.c:17
#define DDSCL_EXCLUSIVE
Definition: ddraw.h:536
#define DDSCAPS_FLIP
Definition: ddraw.h:253
HRESULT WINAPI DirectDrawCreate(LPGUID lpGUID, LPDIRECTDRAW *lplpDD, LPUNKNOWN pUnkOuter)
Definition: main.c:86
#define DD_OK
Definition: ddraw.h:186
#define DDSD_BACKBUFFERCOUNT
Definition: ddraw.h:212
#define DDSD_CAPS
Definition: ddraw.h:208
MMRESULT TimerID
Definition: cylfrac.c:37
struct IDirectDraw * LPDIRECTDRAW
Definition: ddraw.h:710
smooth NULL
Definition: ftsmooth.c:416
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define DDSCAPS_COMPLEX
Definition: ddraw.h:252
#define DDSD_HEIGHT
Definition: ddraw.h:209
VOID DDUpdateFrame(LPDIRECTDRAWSURFACE lpDDPrimarySurface, LPDIRECTDRAWSURFACE lpDDBackBuffer, BOOL Fullscreen, INT *posX, INT *posY, INT *gainX, INT *gainY, RECT *rectDD)
Definition: ddtest.c:322
#define WM_TIMER
Definition: winuser.h:1718
unsigned int UINT
Definition: ndis.h:50
#define DD_SQUARE_STEP
Definition: ddtest.c:22
nsrefcnt Release()
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define DDSD_WIDTH
Definition: ddraw.h:210
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DDSCAPS_BACKBUFFER
Definition: ddraw.h:251
#define DDSCL_FULLSCREEN
Definition: ddraw.h:532
#define DDSCAPS_PRIMARYSURFACE
Definition: ddraw.h:258
#define msg(x)
Definition: auth_time.c:54
#define DDSCAPS_OFFSCREENPLAIN
Definition: ddraw.h:255
#define DDSCL_NORMAL
Definition: ddraw.h:535
#define PM_REMOVE
Definition: winuser.h:1182

◆ DDPrimarySurfaceTest()

BOOL DDPrimarySurfaceTest ( HWND  hWnd)

Definition at line 117 of file ddtest.c.

Referenced by StartDDTest().

117  {
118  UINT TimerID;
119  MSG msg;
120 
121  LPDIRECTDRAW lpDD = NULL;
122  LPDIRECTDRAWSURFACE lpDDSurface = NULL;
123  DDSURFACEDESC DDSurfaceDesc;
124 
125  if(DirectDrawCreate(NULL, &lpDD, NULL) != DD_OK)
126  return FALSE;
127 
128  if(lpDD->lpVtbl->SetCooperativeLevel(lpDD, hWnd, DDSCL_NORMAL) != DD_OK)
129  {
130  lpDD->lpVtbl->Release(lpDD);
131  return FALSE;
132  }
133 
134  /* create our primary surface */
135  ZeroMemory(&DDSurfaceDesc, sizeof(DDSurfaceDesc));
136  DDSurfaceDesc.dwSize = sizeof(DDSurfaceDesc);
137  DDSurfaceDesc.dwFlags = DDSD_CAPS;
138  DDSurfaceDesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE;
139  DDSurfaceDesc.dwBackBufferCount = 0;
140 
141  if(lpDD->lpVtbl->CreateSurface(lpDD, &DDSurfaceDesc, &lpDDSurface, NULL) != DD_OK)
142  {
143  lpDD->lpVtbl->Release(lpDD);
144  return FALSE;
145  }
146 
147  TimerID = SetTimer(hWnd, -1, (UINT)TEST_DURATION, NULL);
148 
149  while (TRUE)
150  {
151  if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
152  {
153  if (msg.message == WM_TIMER && TimerID == msg.wParam)
154  break;
155  TranslateMessage(&msg);
156  DispatchMessage(&msg);
157  if (msg.message == WM_PAINT)
158  DDRedrawFrame(lpDDSurface);
159  }
160  }
161  KillTimer(hWnd, TimerID);
162  lpDDSurface->lpVtbl->Release(lpDDSurface);
163  lpDD->lpVtbl->Release(lpDD);
164 
165 return TRUE;
166 }
#define DDSCAPS_3DDEVICE
Definition: ddraw.h:263
#define DispatchMessage
Definition: winuser.h:5631
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define PeekMessage
Definition: winuser.h:5696
#define TRUE
Definition: types.h:120
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define ZeroMemory
Definition: winbase.h:1635
VOID DDRedrawFrame(LPDIRECTDRAWSURFACE lpDDSurface)
Definition: ddtest.c:168
#define TEST_DURATION
Definition: ddtest.c:17
HRESULT WINAPI DirectDrawCreate(LPGUID lpGUID, LPDIRECTDRAW *lplpDD, LPUNKNOWN pUnkOuter)
Definition: main.c:86
#define DD_OK
Definition: ddraw.h:186
#define DDSD_CAPS
Definition: ddraw.h:208
MMRESULT TimerID
Definition: cylfrac.c:37
struct IDirectDraw * LPDIRECTDRAW
Definition: ddraw.h:710
smooth NULL
Definition: ftsmooth.c:416
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_TIMER
Definition: winuser.h:1718
unsigned int UINT
Definition: ndis.h:50
nsrefcnt Release()
#define WM_PAINT
Definition: winuser.h:1602
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define DDSCAPS_PRIMARYSURFACE
Definition: ddraw.h:258
#define msg(x)
Definition: auth_time.c:54
#define DDSCL_NORMAL
Definition: ddraw.h:535
#define PM_REMOVE
Definition: winuser.h:1182

◆ DDRedrawFrame()

VOID DDRedrawFrame ( LPDIRECTDRAWSURFACE  lpDDSurface)

Definition at line 168 of file ddtest.c.

Referenced by DDPrimarySurfaceTest().

169 {
170  HDC hdc;
171 
172  if (lpDDSurface->lpVtbl->GetDC(lpDDSurface, &hdc) == DD_OK)
173  {
174  RECT rct;
175  HBRUSH BlackBrush, WhiteBrush;
176  BOOL Colour = FALSE;
177 
182 
183  BlackBrush = CreateSolidBrush(RGB(0,0,0));
184  WhiteBrush = CreateSolidBrush(RGB(255,255,255));
185 
186  while((rct.bottom - rct.top) > DD_TEST_STEP){
187  (Colour)? FillRect(hdc, &rct, WhiteBrush) : FillRect(hdc, &rct, BlackBrush);
188  rct.top += DD_TEST_STEP;
189  rct.bottom -= DD_TEST_STEP;
190  rct.left += DD_TEST_STEP;
191  rct.right -= DD_TEST_STEP;
192  Colour = !Colour;
193  }
194  DeleteObject((HGDIOBJ)BlackBrush);
195  DeleteObject((HGDIOBJ)WhiteBrush);
196  lpDDSurface->lpVtbl->ReleaseDC(lpDDSurface, hdc);
197  }
198 }
#define HDC
Definition: msvc.h:22
#define DD_TEST_STEP
Definition: ddtest.c:20
LONG top
Definition: windef.h:297
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define DD_TEST_WIDTH
Definition: ddtest.c:18
LONG left
Definition: windef.h:296
#define DD_TEST_HEIGHT
Definition: ddtest.c:19
LONG right
Definition: windef.h:298
#define SM_CXSCREEN
Definition: winuser.h:949
#define DD_OK
Definition: ddraw.h:186
HDC hdc
Definition: msvc.h:53
#define SM_CYSCREEN
Definition: winuser.h:950
unsigned int BOOL
Definition: ntddk_ex.h:94
#define RGB(r, g, b)
Definition: wingdi.h:2917
int WINAPI GetSystemMetrics(_In_ int)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
LONG bottom
Definition: windef.h:299
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)

◆ DDTests()

VOID DDTests ( )

Definition at line 71 of file ddtest.c.

Referenced by DisplayPageWndProc().

72 {
73  WNDCLASSEX winClass;
74  HWND hWnd;
76  WCHAR szDescription[256];
77  WCHAR szCaption[256];
78 
79  winClass.cbSize = sizeof(WNDCLASSEX);
81  winClass.lpfnWndProc = DefWindowProc;
82  winClass.cbClsExtra = 0;
83  winClass.cbWndExtra = 0;
84  winClass.hInstance = hInstance;
85  winClass.hIcon = 0;
86  winClass.hCursor = 0;
87  winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
88  winClass.lpszMenuName = NULL;
89  winClass.lpszClassName = L"ddtest";
90  winClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
91 
92  if (!RegisterClassEx(&winClass))
93  return;
94 
95  hWnd = CreateWindowEx(0, winClass.lpszClassName, NULL,WS_POPUP,
98  DD_TEST_WIDTH, DD_TEST_HEIGHT, NULL, NULL, hInstance, NULL);
99 
100  if (!hWnd){
101  return;
102  }
103 
104  LoadStringW(hInstance, IDS_DDTEST_DESCRIPTION, szDescription, sizeof(szDescription) / sizeof(WCHAR));
105  LoadStringW(hInstance, IDS_MAIN_DIALOG, szCaption, sizeof(szCaption) / sizeof(WCHAR));
106  if(MessageBox(NULL, szDescription, szCaption, MB_YESNO | MB_ICONQUESTION) == IDNO)
107  return;
108 
112 
113  DestroyWindow(hWnd);
114  UnregisterClass(winClass.lpszClassName, hInstance);
115 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
UINT style
Definition: winuser.h:3155
LPCSTR lpszMenuName
Definition: winuser.h:3163
#define RegisterClassEx
Definition: winuser.h:5703
HCURSOR hCursor
Definition: winuser.h:3161
WNDPROC lpfnWndProc
Definition: winuser.h:3156
LPCSTR lpszClassName
Definition: winuser.h:3164
__wchar_t WCHAR
Definition: xmlstorage.h:180
HWND hWnd
Definition: settings.c:17
#define IDS_DDOFFSCREEN_RESULT
Definition: resource.h:146
#define CS_HREDRAW
Definition: winuser.h:648
#define IDI_APPLICATION
Definition: winuser.h:699
#define DD_TEST_WIDTH
Definition: ddtest.c:18
HICON hIconSm
Definition: winuser.h:3165
#define CS_OWNDC
Definition: winuser.h:650
#define DD_TEST_HEIGHT
Definition: ddtest.c:19
BOOL WINAPI DestroyWindow(_In_ HWND)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define IDS_DDTEST_DESCRIPTION
Definition: resource.h:142
#define SM_CXSCREEN
Definition: winuser.h:949
HINSTANCE hInstance
Definition: charmap.c:20
#define MB_YESNO
Definition: winuser.h:811
HINSTANCE hInstance
Definition: winuser.h:3159
#define CreateWindowEx
Definition: winuser.h:5621
#define IDS_DDFULLSCREEN_DESCRIPTION
Definition: resource.h:147
smooth NULL
Definition: ftsmooth.c:416
#define MB_ICONQUESTION
Definition: winuser.h:783
UINT cbSize
Definition: winuser.h:3154
HBRUSH hbrBackground
Definition: winuser.h:3162
#define DefWindowProc
Definition: ros2win.h:31
#define BLACK_BRUSH
Definition: wingdi.h:894
#define IDS_DDFULLSCREEN_RESULT
Definition: resource.h:148
#define CS_VREDRAW
Definition: winuser.h:653
#define SM_CYSCREEN
Definition: winuser.h:950
int WINAPI GetSystemMetrics(_In_ int)
int cbWndExtra
Definition: winuser.h:3158
HICON hIcon
Definition: winuser.h:3160
#define IDS_DDOFFSCREEN_DESCRIPTION
Definition: resource.h:145
static const WCHAR L[]
Definition: oid.c:1087
#define MessageBox
Definition: winuser.h:5688
#define CS_DBLCLKS
Definition: winuser.h:646
#define IDS_DDPRIMARY_DESCRIPTION
Definition: resource.h:143
int cbClsExtra
Definition: winuser.h:3157
#define IDS_DDPRIMARY_RESULT
Definition: resource.h:144
#define WS_POPUP
Definition: pedump.c:616
BOOL StartDDTest(HWND hWnd, HINSTANCE hInstance, INT resTestDescription, INT resResult, INT TestNr)
Definition: ddtest.c:25
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5585
#define LoadIcon
Definition: winuser.h:5679
#define IDNO
Definition: winuser.h:830
#define IDS_MAIN_DIALOG
Definition: resource.h:103
#define UnregisterClass
Definition: winuser.h:5727
static const WCHAR szDescription[]
Definition: provider.c:52

◆ DDUpdateFrame()

VOID DDUpdateFrame ( LPDIRECTDRAWSURFACE  lpDDPrimarySurface,
LPDIRECTDRAWSURFACE  lpDDBackBuffer,
BOOL  Fullscreen,
INT posX,
INT posY,
INT gainX,
INT gainY,
RECT rectDD 
)

Definition at line 322 of file ddtest.c.

Referenced by DDOffscreenBufferTest().

323 {
324  HDC hdc;
325  DDBLTFX DDBlitFx;
326 
327  /* clear back buffer and paint it black */
328  ZeroMemory(&DDBlitFx, sizeof(DDBlitFx));
329  DDBlitFx.dwSize = sizeof(DDBlitFx);
330  DDBlitFx.dwFillColor = 0;
331 
332  lpDDBackBuffer->lpVtbl->Blt(lpDDBackBuffer, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &DDBlitFx);
333 
334  if (lpDDBackBuffer->lpVtbl->GetDC(lpDDBackBuffer, &hdc) == DD_OK)
335  {
336  RECT rct;
337  HBRUSH WhiteBrush;
338 
339  rct.left = *posX;
340  rct.right = *posX+DD_SQUARE_SIZE;
341  rct.top = *posY;
342  rct.bottom = *posY+DD_SQUARE_SIZE;
343 
344  WhiteBrush = CreateSolidBrush(RGB(255,255,255));
345  FillRect(hdc, &rct, WhiteBrush);
346 
347  if(*posX >= (DD_TEST_WIDTH - DD_SQUARE_SIZE)) *gainX = -(*gainX);
348  if(*posY >= (DD_TEST_HEIGHT - DD_SQUARE_SIZE)) *gainY = -(*gainY);
349  if(*posX < 0) *gainX = -1*(*gainX);
350  if(*posY < 0) *gainY = -1*(*gainY);
351 
352  *posX += *gainX;
353  *posY += *gainY;
354 
355  lpDDBackBuffer->lpVtbl->ReleaseDC(lpDDBackBuffer, hdc);
356 
357  if(Fullscreen)
358  {
359  lpDDPrimarySurface->lpVtbl->Flip(lpDDPrimarySurface, NULL, DDFLIP_WAIT);
360  }
361  else
362  {
363  lpDDPrimarySurface->lpVtbl->Blt(lpDDPrimarySurface, rectDD, lpDDBackBuffer, NULL, DDBLT_WAIT, NULL);
364  }
365  }
366 }
#define HDC
Definition: msvc.h:22
DWORD dwFillColor
Definition: ddraw.h:1310
DWORD dwSize
Definition: ddraw.h:1272
LONG top
Definition: windef.h:297
#define ZeroMemory
Definition: winbase.h:1635
#define DD_TEST_WIDTH
Definition: ddtest.c:18
LONG left
Definition: windef.h:296
#define DD_TEST_HEIGHT
Definition: ddtest.c:19
LONG right
Definition: windef.h:298
#define DD_OK
Definition: ddraw.h:186
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
#define DDBLT_COLORFILL
Definition: ddraw.h:555
#define DDBLT_WAIT
Definition: ddraw.h:569
#define RGB(r, g, b)
Definition: wingdi.h:2917
#define DDFLIP_WAIT
Definition: ddraw.h:583
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
LONG bottom
Definition: windef.h:299
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define DD_SQUARE_SIZE
Definition: ddtest.c:21

◆ StartDDTest()

BOOL StartDDTest ( HWND  hWnd,
HINSTANCE  hInstance,
INT  resTestDescription,
INT  resResult,
INT  TestNr 
)

Definition at line 25 of file ddtest.c.

Referenced by DDTests().

26 {
27  WCHAR szTestDescription[256];
28  WCHAR szCaption[256];
29  WCHAR szResult[256];
30  WCHAR szError[256];
31  BOOL Result;
32 
33  LoadStringW(hInstance, IDS_MAIN_DIALOG, szCaption, sizeof(szCaption) / sizeof(WCHAR));
34  LoadStringW(hInstance, IDS_DDTEST_ERROR, szError, sizeof(szError) / sizeof(WCHAR));
35  LoadStringW(hInstance, resTestDescription, szTestDescription, sizeof(szTestDescription) / sizeof(WCHAR));
36  LoadStringW(hInstance, resResult, szResult, sizeof(szResult) / sizeof(WCHAR));
37 
38  if(MessageBox(NULL, szTestDescription, szCaption, MB_YESNO | MB_ICONQUESTION) == IDNO)
39  return FALSE;
40 
41  ShowWindow(hWnd, SW_SHOW);
42 
43  switch(TestNr){
44  case 1:
45  Result = DDPrimarySurfaceTest(hWnd);
46  break;
47  case 2:
48  Result = DDOffscreenBufferTest(hWnd, FALSE);
49  break;
50  case 3:
51  Result = DDOffscreenBufferTest(hWnd, TRUE);
52  break;
53  default:
54  Result = FALSE;
55  }
56 
57  ShowWindow(hWnd, SW_HIDE);
58 
59  if(!Result)
60  {
61  MessageBox(NULL, szError, szCaption, MB_OK | MB_ICONERROR);
62  return FALSE;
63  }
64 
65  if(MessageBox(NULL, szResult, szCaption, MB_YESNO | MB_ICONQUESTION) == IDYES)
66  return TRUE;
67 
68  return FALSE;
69 }
#define TRUE
Definition: types.h:120
#define IDYES
Definition: winuser.h:829
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SW_HIDE
Definition: winuser.h:762
#define IDS_DDTEST_ERROR
Definition: resource.h:141
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define MB_YESNO
Definition: winuser.h:811
smooth NULL
Definition: ftsmooth.c:416
#define MB_ICONQUESTION
Definition: winuser.h:783
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define SW_SHOW
Definition: winuser.h:769
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL DDPrimarySurfaceTest(HWND hWnd)
Definition: ddtest.c:117
#define MB_ICONERROR
Definition: winuser.h:781
#define MessageBox
Definition: winuser.h:5688
BOOL DDOffscreenBufferTest(HWND hWnd, BOOL Fullscreen)
Definition: ddtest.c:201
#define MB_OK
Definition: winuser.h:784
#define IDNO
Definition: winuser.h:830
#define IDS_MAIN_DIALOG
Definition: resource.h:103