2 * Unit tests for (a few) ddraw surface functions
4 * Copyright (C) 2005 Antoine Chavasse (a.chavasse@gmail.com)
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 static LPDIRECTDRAW lpDD = NULL;
27 static void CreateDirectDraw()
31 rc = DirectDrawCreate(NULL, &lpDD, NULL);
32 ok(rc==DD_OK,"DirectDrawCreate returned: %lx\n",rc);
34 rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL);
35 ok(rc==DD_OK,"SetCooperativeLevel returned: %lx\n",rc);
39 static void ReleaseDirectDraw()
43 IDirectDraw_Release(lpDD);
48 static void MipMapCreationTest()
50 LPDIRECTDRAWSURFACE lpDDSMipMapTest;
54 /* First mipmap creation test: create a surface with DDSCAPS_COMPLEX,
55 DDSCAPS_MIPMAP, and DDSD_MIPMAPCOUNT. This create the number of
56 requested mipmap levels. */
57 ddsd.dwSize = sizeof(ddsd);
58 ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT;
59 ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
60 U2(ddsd).dwMipMapCount = 3;
63 rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSMipMapTest, NULL);
64 ok(rc==DD_OK,"CreateSurface returned: %lx\n",rc);
66 /* Check the number of created mipmaps */
67 memset(&ddsd, 0, sizeof(DDSURFACEDESC));
68 ddsd.dwSize = sizeof(ddsd);
69 rc = IDirectDrawSurface_GetSurfaceDesc(lpDDSMipMapTest, &ddsd);
70 ok(rc==DD_OK,"GetSurfaceDesc returned: %lx\n",rc);
71 ok(ddsd.dwFlags & DDSD_MIPMAPCOUNT,
72 "GetSurfaceDesc returned no mipmapcount.\n");
73 ok(U2(ddsd).dwMipMapCount == 3, "Incorrect mipmap count: %ld.\n",
74 U2(ddsd).dwMipMapCount);
76 /* Destroy the surface. */
77 IDirectDrawSurface_Release(lpDDSMipMapTest);
80 /* Second mipmap creation test: create a surface without a mipmap
81 count, with DDSCAPS_MIPMAP and without DDSCAPS_COMPLEX.
82 This creates a single mipmap level. */
83 memset(&ddsd, 0, sizeof(DDSURFACEDESC));
84 ddsd.dwSize = sizeof(ddsd);
85 ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
86 ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP;
89 rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSMipMapTest, NULL);
90 ok(rc==DD_OK,"CreateSurface returned: %lx\n",rc);
92 /* Check the number of created mipmaps */
93 memset(&ddsd, 0, sizeof(DDSURFACEDESC));
94 ddsd.dwSize = sizeof(ddsd);
95 rc = IDirectDrawSurface_GetSurfaceDesc(lpDDSMipMapTest, &ddsd);
96 ok(rc==DD_OK,"GetSurfaceDesc returned: %lx\n",rc);
97 ok(ddsd.dwFlags & DDSD_MIPMAPCOUNT,
98 "GetSurfaceDesc returned no mipmapcount.\n");
99 ok(U2(ddsd).dwMipMapCount == 1, "Incorrect mipmap count: %ld.\n",
100 U2(ddsd).dwMipMapCount);
103 /* Third mipmap creation test: create a surface with DDSCAPS_MIPMAP,
104 DDSCAPS_COMPLEX and without DDSD_MIPMAPCOUNT.
105 It's an undocumented features where a chain of mipmaps, starting from
106 he specified size and down to the smallest size, is automatically
108 Anarchy Online needs this feature to work. */
109 memset(&ddsd, 0, sizeof(DDSURFACEDESC));
110 ddsd.dwSize = sizeof(ddsd);
111 ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
112 ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
115 rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSMipMapTest, NULL);
116 ok(rc==DD_OK,"CreateSurface returned: %lx\n",rc);
118 /* Check the number of created mipmaps */
119 memset(&ddsd, 0, sizeof(DDSURFACEDESC));
120 ddsd.dwSize = sizeof(ddsd);
121 rc = IDirectDrawSurface_GetSurfaceDesc(lpDDSMipMapTest, &ddsd);
122 ok(rc==DD_OK,"GetSurfaceDesc returned: %lx\n",rc);
123 ok(ddsd.dwFlags & DDSD_MIPMAPCOUNT,
124 "GetSurfaceDesc returned no mipmapcount.\n");
125 ok(U2(ddsd).dwMipMapCount == 6, "Incorrect mipmap count: %ld.\n",
126 U2(ddsd).dwMipMapCount);
129 /* Fourth mipmap creation test: same as above with a different texture
131 The purpose is to verify that the number of generated mipmaps is
132 dependant on the smallest dimension. */
133 memset(&ddsd, 0, sizeof(DDSURFACEDESC));
134 ddsd.dwSize = sizeof(ddsd);
135 ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
136 ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
139 rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSMipMapTest, NULL);
140 ok(rc==DD_OK,"CreateSurface returned: %lx\n",rc);
142 /* Check the number of created mipmaps */
143 memset(&ddsd, 0, sizeof(DDSURFACEDESC));
144 ddsd.dwSize = sizeof(ddsd);
145 rc = IDirectDrawSurface_GetSurfaceDesc(lpDDSMipMapTest, &ddsd);
146 ok(rc==DD_OK,"GetSurfaceDesc returned: %lx\n",rc);
147 ok(ddsd.dwFlags & DDSD_MIPMAPCOUNT,
148 "GetSurfaceDesc returned no mipmapcount.\n");
149 ok(U2(ddsd).dwMipMapCount == 6, "Incorrect mipmap count: %ld.\n",
150 U2(ddsd).dwMipMapCount);
152 /* Destroy the surface. */
153 IDirectDrawSurface_Release(lpDDSMipMapTest);
160 MipMapCreationTest();