2 * Unit tests for ddraw functions
4 * Copyright (C) 2003 Sami Aario
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "wine/test.h"
25 #ifdef NONAMELESSUNION
26 #define UNION_MEMBER(x, y) DUMMYUNIONNAME##x.y
28 #define UNION_MEMBER(x, y) y
31 static LPDIRECTDRAW lpDD;
35 static int modes_size;
36 static LPDDSURFACEDESC modes;
38 static void createdirectdraw()
42 wc.style = CS_HREDRAW | CS_VREDRAW;
43 wc.lpfnWndProc = DefWindowProcA;
46 wc.hInstance = GetModuleHandleA(0);
47 wc.hIcon = LoadIconA(wc.hInstance, IDI_APPLICATION);
48 wc.hCursor = LoadCursorA(NULL, IDC_ARROW);
49 wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
50 wc.lpszMenuName = NULL;
51 wc.lpszClassName = "TestWindowClass";
52 if(!RegisterClassA(&wc))
55 hwnd = CreateWindowExA(0, "TestWindowClass", "TestWindowClass",
57 GetSystemMetrics(SM_CXSCREEN),
58 GetSystemMetrics(SM_CYSCREEN),
59 NULL, NULL, GetModuleHandleA(0), NULL);
63 ShowWindow(hwnd, SW_HIDE);
67 rc = DirectDrawCreate(NULL, &lpDD, NULL);
68 ok(rc==DD_OK,"DirectDrawCreate returned: %lx\n",rc);
71 static void add_mode(LPDDSURFACEDESC lpddsd)
74 modes = malloc((modes_size = 2) * sizeof(DDSURFACEDESC));
75 if (modes_cnt == modes_size)
76 modes = realloc(modes, (modes_size *= 2) * sizeof(DDSURFACEDESC));
78 modes[modes_cnt++] = *lpddsd;
81 static void flush_modes()
85 modes_cnt = modes_size = 0;
88 HRESULT WINAPI enummodes_callback(LPDDSURFACEDESC lpddsd, LPVOID lpContext)
90 trace("Width = %lx, Height = %lx, Refresh Rate = %lx\r\n",
91 lpddsd->dwWidth, lpddsd->dwHeight,
92 lpddsd->UNION_MEMBER(2, dwRefreshRate));
98 void enumdisplaymodes()
103 ZeroMemory(&ddsd, sizeof(DDSURFACEDESC));
104 ddsd.dwSize = sizeof(DDSURFACEDESC);
105 ddsd.dwFlags = DDSD_CAPS;
106 ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
108 rc = IDirectDraw_EnumDisplayModes(lpDD,
109 DDEDM_STANDARDVGAMODES, &ddsd, 0, enummodes_callback);
110 ok(rc==DD_OK,"EnumDisplayModes returned: %lx\n",rc);
113 static void setdisplaymode_tests()
120 for (i = 0; i < modes_cnt; ++i)
122 rc = IDirectDraw_SetCooperativeLevel(lpDD,
123 hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
124 ok(rc==DD_OK,"SetCooperativeLevel returned: %lx\n",rc);
125 if (modes[i].dwFlags & DDSD_PIXELFORMAT)
127 if (modes[i].ddpfPixelFormat.dwFlags & DDPF_RGB)
129 rc = IDirectDraw_SetDisplayMode(lpDD,
130 modes[i].dwWidth, modes[i].dwHeight,
131 modes[i].ddpfPixelFormat.UNION_MEMBER(1, dwRGBBitCount));
132 ok(rc==DD_OK,"SetDisplayMode returned: %lx\n",rc);
133 rc = IDirectDraw_RestoreDisplayMode(lpDD);
134 ok(rc==DD_OK,"RestoreDisplayMode returned: %lx\n",rc);
141 START_TEST(ddrawmodes)
143 setdisplaymode_tests();