rw_ddraw.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. /*
  2. Copyright (C) 1997-2001 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. /*
  16. ** RW_DDRAW.C
  17. **
  18. ** This handles DirecTDraw management under Windows.
  19. */
  20. #ifndef _WIN32
  21. # error You should not be compiling this file on this platform
  22. #endif
  23. #include <float.h>
  24. #include "..\ref_soft\r_local.h"
  25. #define INITGUID
  26. #include "rw_win.h"
  27. static const char *DDrawError( int code );
  28. /*
  29. ** DDRAW_Init
  30. **
  31. ** Builds our DDRAW stuff
  32. */
  33. qboolean DDRAW_Init( unsigned char **ppbuffer, int *ppitch )
  34. {
  35. HRESULT ddrval;
  36. DDSURFACEDESC ddsd;
  37. DDSCAPS ddscaps;
  38. PALETTEENTRY palentries[256];
  39. int i;
  40. extern cvar_t *sw_allow_modex;
  41. HRESULT (WINAPI *QDirectDrawCreate)( GUID FAR *lpGUID, LPDIRECTDRAW FAR * lplpDDRAW, IUnknown FAR * pUnkOuter );
  42. ri.Con_Printf( PRINT_ALL, "Initializing DirectDraw\n");
  43. for ( i = 0; i < 256; i++ )
  44. {
  45. palentries[i].peRed = ( d_8to24table[i] >> 0 ) & 0xff;
  46. palentries[i].peGreen = ( d_8to24table[i] >> 8 ) & 0xff;
  47. palentries[i].peBlue = ( d_8to24table[i] >> 16 ) & 0xff;
  48. }
  49. /*
  50. ** load DLL and fetch pointer to entry point
  51. */
  52. if ( !sww_state.hinstDDRAW )
  53. {
  54. ri.Con_Printf( PRINT_ALL, "...loading DDRAW.DLL: ");
  55. if ( ( sww_state.hinstDDRAW = LoadLibrary( "ddraw.dll" ) ) == NULL )
  56. {
  57. ri.Con_Printf( PRINT_ALL, "failed\n" );
  58. goto fail;
  59. }
  60. ri.Con_Printf( PRINT_ALL, "ok\n" );
  61. }
  62. if ( ( QDirectDrawCreate = ( HRESULT (WINAPI *)( GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR * ) ) GetProcAddress( sww_state.hinstDDRAW, "DirectDrawCreate" ) ) == NULL )
  63. {
  64. ri.Con_Printf( PRINT_ALL, "*** DirectDrawCreate == NULL ***\n" );
  65. goto fail;
  66. }
  67. /*
  68. ** create the direct draw object
  69. */
  70. ri.Con_Printf( PRINT_ALL, "...creating DirectDraw object: ");
  71. if ( ( ddrval = QDirectDrawCreate( NULL, &sww_state.lpDirectDraw, NULL ) ) != DD_OK )
  72. {
  73. ri.Con_Printf( PRINT_ALL, "failed - %s\n", DDrawError( ddrval ) );
  74. goto fail;
  75. }
  76. ri.Con_Printf( PRINT_ALL, "ok\n" );
  77. /*
  78. ** see if linear modes exist first
  79. */
  80. sww_state.modex = false;
  81. ri.Con_Printf( PRINT_ALL, "...setting exclusive mode: ");
  82. if ( ( ddrval = sww_state.lpDirectDraw->lpVtbl->SetCooperativeLevel( sww_state.lpDirectDraw,
  83. sww_state.hWnd,
  84. DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN ) ) != DD_OK )
  85. {
  86. ri.Con_Printf( PRINT_ALL, "failed - %s\n",DDrawError (ddrval) );
  87. goto fail;
  88. }
  89. ri.Con_Printf( PRINT_ALL, "ok\n" );
  90. /*
  91. ** try changing the display mode normally
  92. */
  93. ri.Con_Printf( PRINT_ALL, "...finding display mode\n" );
  94. ri.Con_Printf( PRINT_ALL, "...setting linear mode: " );
  95. if ( ( ddrval = sww_state.lpDirectDraw->lpVtbl->SetDisplayMode( sww_state.lpDirectDraw, vid.width, vid.height, 8 ) ) == DD_OK )
  96. {
  97. ri.Con_Printf( PRINT_ALL, "ok\n" );
  98. }
  99. /*
  100. ** if no linear mode found, go for modex if we're trying 320x240
  101. */
  102. else if ( ( sw_mode->value == 0 ) && sw_allow_modex->value )
  103. {
  104. ri.Con_Printf( PRINT_ALL, "failed\n" );
  105. ri.Con_Printf( PRINT_ALL, "...attempting ModeX 320x240: ");
  106. /*
  107. ** reset to normal cooperative level
  108. */
  109. sww_state.lpDirectDraw->lpVtbl->SetCooperativeLevel( sww_state.lpDirectDraw,
  110. sww_state.hWnd,
  111. DDSCL_NORMAL );
  112. /*
  113. ** set exclusive mode
  114. */
  115. if ( ( ddrval = sww_state.lpDirectDraw->lpVtbl->SetCooperativeLevel( sww_state.lpDirectDraw,
  116. sww_state.hWnd,
  117. DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_NOWINDOWCHANGES | DDSCL_ALLOWMODEX ) ) != DD_OK )
  118. {
  119. ri.Con_Printf( PRINT_ALL, "failed SCL - %s\n",DDrawError (ddrval) );
  120. goto fail;
  121. }
  122. /*
  123. ** change our display mode
  124. */
  125. if ( ( ddrval = sww_state.lpDirectDraw->lpVtbl->SetDisplayMode( sww_state.lpDirectDraw, vid.width, vid.height, 8 ) ) != DD_OK )
  126. {
  127. ri.Con_Printf( PRINT_ALL, "failed SDM - %s\n", DDrawError( ddrval ) );
  128. goto fail;
  129. }
  130. ri.Con_Printf( PRINT_ALL, "ok\n" );
  131. sww_state.modex = true;
  132. }
  133. else
  134. {
  135. ri.Con_Printf( PRINT_ALL, "failed\n" );
  136. goto fail;
  137. }
  138. /*
  139. ** create our front buffer
  140. */
  141. memset( &ddsd, 0, sizeof( ddsd ) );
  142. ddsd.dwSize = sizeof( ddsd );
  143. ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
  144. ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
  145. ddsd.dwBackBufferCount = 1;
  146. ri.Con_Printf( PRINT_ALL, "...creating front buffer: ");
  147. if ( ( ddrval = sww_state.lpDirectDraw->lpVtbl->CreateSurface( sww_state.lpDirectDraw, &ddsd, &sww_state.lpddsFrontBuffer, NULL ) ) != DD_OK )
  148. {
  149. ri.Con_Printf( PRINT_ALL, "failed - %s\n", DDrawError( ddrval ) );
  150. goto fail;
  151. }
  152. ri.Con_Printf( PRINT_ALL, "ok\n" );
  153. /*
  154. ** see if we're a ModeX mode
  155. */
  156. sww_state.lpddsFrontBuffer->lpVtbl->GetCaps( sww_state.lpddsFrontBuffer, &ddscaps );
  157. if ( ddscaps.dwCaps & DDSCAPS_MODEX )
  158. ri.Con_Printf( PRINT_ALL, "...using ModeX\n" );
  159. /*
  160. ** create our back buffer
  161. */
  162. ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
  163. ri.Con_Printf( PRINT_ALL, "...creating back buffer: " );
  164. if ( ( ddrval = sww_state.lpddsFrontBuffer->lpVtbl->GetAttachedSurface( sww_state.lpddsFrontBuffer, &ddsd.ddsCaps, &sww_state.lpddsBackBuffer ) ) != DD_OK )
  165. {
  166. ri.Con_Printf( PRINT_ALL, "failed - %s\n", DDrawError( ddrval ) );
  167. goto fail;
  168. }
  169. ri.Con_Printf( PRINT_ALL, "ok\n" );
  170. /*
  171. ** create our rendering buffer
  172. */
  173. memset( &ddsd, 0, sizeof( ddsd ) );
  174. ddsd.dwSize = sizeof( ddsd );
  175. ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
  176. ddsd.dwHeight = vid.height;
  177. ddsd.dwWidth = vid.width;
  178. ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
  179. ri.Con_Printf( PRINT_ALL, "...creating offscreen buffer: " );
  180. if ( ( ddrval = sww_state.lpDirectDraw->lpVtbl->CreateSurface( sww_state.lpDirectDraw, &ddsd, &sww_state.lpddsOffScreenBuffer, NULL ) ) != DD_OK )
  181. {
  182. ri.Con_Printf( PRINT_ALL, "failed - %s\n", DDrawError( ddrval ) );
  183. goto fail;
  184. }
  185. ri.Con_Printf( PRINT_ALL, "ok\n" );
  186. /*
  187. ** create our DIRECTDRAWPALETTE
  188. */
  189. ri.Con_Printf( PRINT_ALL, "...creating palette: " );
  190. if ( ( ddrval = sww_state.lpDirectDraw->lpVtbl->CreatePalette( sww_state.lpDirectDraw,
  191. DDPCAPS_8BIT | DDPCAPS_ALLOW256,
  192. palentries,
  193. &sww_state.lpddpPalette,
  194. NULL ) ) != DD_OK )
  195. {
  196. ri.Con_Printf( PRINT_ALL, "failed - %s\n", DDrawError( ddrval ) );
  197. goto fail;
  198. }
  199. ri.Con_Printf( PRINT_ALL, "ok\n" );
  200. ri.Con_Printf( PRINT_ALL, "...setting palette: " );
  201. if ( ( ddrval = sww_state.lpddsFrontBuffer->lpVtbl->SetPalette( sww_state.lpddsFrontBuffer,
  202. sww_state.lpddpPalette ) ) != DD_OK )
  203. {
  204. ri.Con_Printf( PRINT_ALL, "failed - %s\n", DDrawError( ddrval ) );
  205. goto fail;
  206. }
  207. ri.Con_Printf( PRINT_ALL, "ok\n" );
  208. DDRAW_SetPalette( ( const unsigned char * ) sw_state.currentpalette );
  209. /*
  210. ** lock the back buffer
  211. */
  212. memset( &ddsd, 0, sizeof( ddsd ) );
  213. ddsd.dwSize = sizeof( ddsd );
  214. ri.Con_Printf( PRINT_ALL, "...locking backbuffer: " );
  215. if ( ( ddrval = sww_state.lpddsOffScreenBuffer->lpVtbl->Lock( sww_state.lpddsOffScreenBuffer, NULL, &ddsd, DDLOCK_WAIT, NULL ) ) != DD_OK )
  216. {
  217. ri.Con_Printf( PRINT_ALL, "failed - %s\n", DDrawError( ddrval ) );
  218. goto fail;
  219. }
  220. ri.Con_Printf( PRINT_ALL, "ok\n" );
  221. *ppbuffer = ddsd.lpSurface;
  222. *ppitch = ddsd.lPitch;
  223. for ( i = 0; i < vid.height; i++ )
  224. {
  225. memset( *ppbuffer + i * *ppitch, 0, *ppitch );
  226. }
  227. sww_state.palettized = true;
  228. return true;
  229. fail:
  230. ri.Con_Printf( PRINT_ALL, "*** DDraw init failure ***\n" );
  231. DDRAW_Shutdown();
  232. return false;
  233. }
  234. /*
  235. ** DDRAW_SetPalette
  236. **
  237. ** Sets the color table in our DIB section, and also sets the system palette
  238. ** into an identity mode if we're running in an 8-bit palettized display mode.
  239. **
  240. ** The palette is expected to be 1024 bytes, in the format:
  241. **
  242. ** R = offset 0
  243. ** G = offset 1
  244. ** B = offset 2
  245. ** A = offset 3
  246. */
  247. void DDRAW_SetPalette( const unsigned char *pal )
  248. {
  249. PALETTEENTRY palentries[256];
  250. int i;
  251. if (!sww_state.lpddpPalette)
  252. return;
  253. for ( i = 0; i < 256; i++, pal += 4 )
  254. {
  255. palentries[i].peRed = pal[0];
  256. palentries[i].peGreen = pal[1];
  257. palentries[i].peBlue = pal[2];
  258. palentries[i].peFlags = PC_RESERVED | PC_NOCOLLAPSE;
  259. }
  260. if ( sww_state.lpddpPalette->lpVtbl->SetEntries( sww_state.lpddpPalette,
  261. 0,
  262. 0,
  263. 256,
  264. palentries ) != DD_OK )
  265. {
  266. ri.Con_Printf( PRINT_ALL, "DDRAW_SetPalette() - SetEntries failed\n" );
  267. }
  268. }
  269. /*
  270. ** DDRAW_Shutdown
  271. */
  272. void DDRAW_Shutdown( void )
  273. {
  274. if ( sww_state.lpddsOffScreenBuffer )
  275. {
  276. ri.Con_Printf( PRINT_ALL, "...releasing offscreen buffer\n");
  277. sww_state.lpddsOffScreenBuffer->lpVtbl->Unlock( sww_state.lpddsOffScreenBuffer, vid.buffer );
  278. sww_state.lpddsOffScreenBuffer->lpVtbl->Release( sww_state.lpddsOffScreenBuffer );
  279. sww_state.lpddsOffScreenBuffer = NULL;
  280. }
  281. if ( sww_state.lpddsBackBuffer )
  282. {
  283. ri.Con_Printf( PRINT_ALL, "...releasing back buffer\n");
  284. sww_state.lpddsBackBuffer->lpVtbl->Release( sww_state.lpddsBackBuffer );
  285. sww_state.lpddsBackBuffer = NULL;
  286. }
  287. if ( sww_state.lpddsFrontBuffer )
  288. {
  289. ri.Con_Printf( PRINT_ALL, "...releasing front buffer\n");
  290. sww_state.lpddsFrontBuffer->lpVtbl->Release( sww_state.lpddsFrontBuffer );
  291. sww_state.lpddsFrontBuffer = NULL;
  292. }
  293. if (sww_state.lpddpPalette)
  294. {
  295. ri.Con_Printf( PRINT_ALL, "...releasing palette\n");
  296. sww_state.lpddpPalette->lpVtbl->Release ( sww_state.lpddpPalette );
  297. sww_state.lpddpPalette = NULL;
  298. }
  299. if ( sww_state.lpDirectDraw )
  300. {
  301. ri.Con_Printf( PRINT_ALL, "...restoring display mode\n");
  302. sww_state.lpDirectDraw->lpVtbl->RestoreDisplayMode( sww_state.lpDirectDraw );
  303. ri.Con_Printf( PRINT_ALL, "...restoring normal coop mode\n");
  304. sww_state.lpDirectDraw->lpVtbl->SetCooperativeLevel( sww_state.lpDirectDraw, sww_state.hWnd, DDSCL_NORMAL );
  305. ri.Con_Printf( PRINT_ALL, "...releasing lpDirectDraw\n");
  306. sww_state.lpDirectDraw->lpVtbl->Release( sww_state.lpDirectDraw );
  307. sww_state.lpDirectDraw = NULL;
  308. }
  309. if ( sww_state.hinstDDRAW )
  310. {
  311. ri.Con_Printf( PRINT_ALL, "...freeing library\n");
  312. FreeLibrary( sww_state.hinstDDRAW );
  313. sww_state.hinstDDRAW = NULL;
  314. }
  315. }
  316. static const char *DDrawError (int code)
  317. {
  318. switch(code) {
  319. case DD_OK:
  320. return "DD_OK";
  321. case DDERR_ALREADYINITIALIZED:
  322. return "DDERR_ALREADYINITIALIZED";
  323. case DDERR_BLTFASTCANTCLIP:
  324. return "DDERR_BLTFASTCANTCLIP";
  325. case DDERR_CANNOTATTACHSURFACE:
  326. return "DDER_CANNOTATTACHSURFACE";
  327. case DDERR_CANNOTDETACHSURFACE:
  328. return "DDERR_CANNOTDETACHSURFACE";
  329. case DDERR_CANTCREATEDC:
  330. return "DDERR_CANTCREATEDC";
  331. case DDERR_CANTDUPLICATE:
  332. return "DDER_CANTDUPLICATE";
  333. case DDERR_CLIPPERISUSINGHWND:
  334. return "DDER_CLIPPERUSINGHWND";
  335. case DDERR_COLORKEYNOTSET:
  336. return "DDERR_COLORKEYNOTSET";
  337. case DDERR_CURRENTLYNOTAVAIL:
  338. return "DDERR_CURRENTLYNOTAVAIL";
  339. case DDERR_DIRECTDRAWALREADYCREATED:
  340. return "DDERR_DIRECTDRAWALREADYCREATED";
  341. case DDERR_EXCEPTION:
  342. return "DDERR_EXCEPTION";
  343. case DDERR_EXCLUSIVEMODEALREADYSET:
  344. return "DDERR_EXCLUSIVEMODEALREADYSET";
  345. case DDERR_GENERIC:
  346. return "DDERR_GENERIC";
  347. case DDERR_HEIGHTALIGN:
  348. return "DDERR_HEIGHTALIGN";
  349. case DDERR_HWNDALREADYSET:
  350. return "DDERR_HWNDALREADYSET";
  351. case DDERR_HWNDSUBCLASSED:
  352. return "DDERR_HWNDSUBCLASSED";
  353. case DDERR_IMPLICITLYCREATED:
  354. return "DDERR_IMPLICITLYCREATED";
  355. case DDERR_INCOMPATIBLEPRIMARY:
  356. return "DDERR_INCOMPATIBLEPRIMARY";
  357. case DDERR_INVALIDCAPS:
  358. return "DDERR_INVALIDCAPS";
  359. case DDERR_INVALIDCLIPLIST:
  360. return "DDERR_INVALIDCLIPLIST";
  361. case DDERR_INVALIDDIRECTDRAWGUID:
  362. return "DDERR_INVALIDDIRECTDRAWGUID";
  363. case DDERR_INVALIDMODE:
  364. return "DDERR_INVALIDMODE";
  365. case DDERR_INVALIDOBJECT:
  366. return "DDERR_INVALIDOBJECT";
  367. case DDERR_INVALIDPARAMS:
  368. return "DDERR_INVALIDPARAMS";
  369. case DDERR_INVALIDPIXELFORMAT:
  370. return "DDERR_INVALIDPIXELFORMAT";
  371. case DDERR_INVALIDPOSITION:
  372. return "DDERR_INVALIDPOSITION";
  373. case DDERR_INVALIDRECT:
  374. return "DDERR_INVALIDRECT";
  375. case DDERR_LOCKEDSURFACES:
  376. return "DDERR_LOCKEDSURFACES";
  377. case DDERR_NO3D:
  378. return "DDERR_NO3D";
  379. case DDERR_NOALPHAHW:
  380. return "DDERR_NOALPHAHW";
  381. case DDERR_NOBLTHW:
  382. return "DDERR_NOBLTHW";
  383. case DDERR_NOCLIPLIST:
  384. return "DDERR_NOCLIPLIST";
  385. case DDERR_NOCLIPPERATTACHED:
  386. return "DDERR_NOCLIPPERATTACHED";
  387. case DDERR_NOCOLORCONVHW:
  388. return "DDERR_NOCOLORCONVHW";
  389. case DDERR_NOCOLORKEY:
  390. return "DDERR_NOCOLORKEY";
  391. case DDERR_NOCOLORKEYHW:
  392. return "DDERR_NOCOLORKEYHW";
  393. case DDERR_NOCOOPERATIVELEVELSET:
  394. return "DDERR_NOCOOPERATIVELEVELSET";
  395. case DDERR_NODC:
  396. return "DDERR_NODC";
  397. case DDERR_NODDROPSHW:
  398. return "DDERR_NODDROPSHW";
  399. case DDERR_NODIRECTDRAWHW:
  400. return "DDERR_NODIRECTDRAWHW";
  401. case DDERR_NOEMULATION:
  402. return "DDERR_NOEMULATION";
  403. case DDERR_NOEXCLUSIVEMODE:
  404. return "DDERR_NOEXCLUSIVEMODE";
  405. case DDERR_NOFLIPHW:
  406. return "DDERR_NOFLIPHW";
  407. case DDERR_NOGDI:
  408. return "DDERR_NOGDI";
  409. case DDERR_NOHWND:
  410. return "DDERR_NOHWND";
  411. case DDERR_NOMIRRORHW:
  412. return "DDERR_NOMIRRORHW";
  413. case DDERR_NOOVERLAYDEST:
  414. return "DDERR_NOOVERLAYDEST";
  415. case DDERR_NOOVERLAYHW:
  416. return "DDERR_NOOVERLAYHW";
  417. case DDERR_NOPALETTEATTACHED:
  418. return "DDERR_NOPALETTEATTACHED";
  419. case DDERR_NOPALETTEHW:
  420. return "DDERR_NOPALETTEHW";
  421. case DDERR_NORASTEROPHW:
  422. return "Operation could not be carried out because there is no appropriate raster op hardware present or available.\0";
  423. case DDERR_NOROTATIONHW:
  424. return "Operation could not be carried out because there is no rotation hardware present or available.\0";
  425. case DDERR_NOSTRETCHHW:
  426. return "Operation could not be carried out because there is no hardware support for stretching.\0";
  427. case DDERR_NOT4BITCOLOR:
  428. return "DirectDrawSurface is not in 4 bit color palette and the requested operation requires 4 bit color palette.\0";
  429. case DDERR_NOT4BITCOLORINDEX:
  430. return "DirectDrawSurface is not in 4 bit color index palette and the requested operation requires 4 bit color index palette.\0";
  431. case DDERR_NOT8BITCOLOR:
  432. return "DDERR_NOT8BITCOLOR";
  433. case DDERR_NOTAOVERLAYSURFACE:
  434. return "Returned when an overlay member is called for a non-overlay surface.\0";
  435. case DDERR_NOTEXTUREHW:
  436. return "Operation could not be carried out because there is no texture mapping hardware present or available.\0";
  437. case DDERR_NOTFLIPPABLE:
  438. return "DDERR_NOTFLIPPABLE";
  439. case DDERR_NOTFOUND:
  440. return "DDERR_NOTFOUND";
  441. case DDERR_NOTLOCKED:
  442. return "DDERR_NOTLOCKED";
  443. case DDERR_NOTPALETTIZED:
  444. return "DDERR_NOTPALETTIZED";
  445. case DDERR_NOVSYNCHW:
  446. return "DDERR_NOVSYNCHW";
  447. case DDERR_NOZBUFFERHW:
  448. return "Operation could not be carried out because there is no hardware support for zbuffer blitting.\0";
  449. case DDERR_NOZOVERLAYHW:
  450. return "Overlay surfaces could not be z layered based on their BltOrder because the hardware does not support z layering of overlays.\0";
  451. case DDERR_OUTOFCAPS:
  452. return "The hardware needed for the requested operation has already been allocated.\0";
  453. case DDERR_OUTOFMEMORY:
  454. return "DDERR_OUTOFMEMORY";
  455. case DDERR_OUTOFVIDEOMEMORY:
  456. return "DDERR_OUTOFVIDEOMEMORY";
  457. case DDERR_OVERLAYCANTCLIP:
  458. return "The hardware does not support clipped overlays.\0";
  459. case DDERR_OVERLAYCOLORKEYONLYONEACTIVE:
  460. return "Can only have ony color key active at one time for overlays.\0";
  461. case DDERR_OVERLAYNOTVISIBLE:
  462. return "Returned when GetOverlayPosition is called on a hidden overlay.\0";
  463. case DDERR_PALETTEBUSY:
  464. return "DDERR_PALETTEBUSY";
  465. case DDERR_PRIMARYSURFACEALREADYEXISTS:
  466. return "DDERR_PRIMARYSURFACEALREADYEXISTS";
  467. case DDERR_REGIONTOOSMALL:
  468. return "Region passed to Clipper::GetClipList is too small.\0";
  469. case DDERR_SURFACEALREADYATTACHED:
  470. return "DDERR_SURFACEALREADYATTACHED";
  471. case DDERR_SURFACEALREADYDEPENDENT:
  472. return "DDERR_SURFACEALREADYDEPENDENT";
  473. case DDERR_SURFACEBUSY:
  474. return "DDERR_SURFACEBUSY";
  475. case DDERR_SURFACEISOBSCURED:
  476. return "Access to surface refused because the surface is obscured.\0";
  477. case DDERR_SURFACELOST:
  478. return "DDERR_SURFACELOST";
  479. case DDERR_SURFACENOTATTACHED:
  480. return "DDERR_SURFACENOTATTACHED";
  481. case DDERR_TOOBIGHEIGHT:
  482. return "Height requested by DirectDraw is too large.\0";
  483. case DDERR_TOOBIGSIZE:
  484. return "Size requested by DirectDraw is too large, but the individual height and width are OK.\0";
  485. case DDERR_TOOBIGWIDTH:
  486. return "Width requested by DirectDraw is too large.\0";
  487. case DDERR_UNSUPPORTED:
  488. return "DDERR_UNSUPPORTED";
  489. case DDERR_UNSUPPORTEDFORMAT:
  490. return "FOURCC format requested is unsupported by DirectDraw.\0";
  491. case DDERR_UNSUPPORTEDMASK:
  492. return "Bitmask in the pixel format requested is unsupported by DirectDraw.\0";
  493. case DDERR_VERTICALBLANKINPROGRESS:
  494. return "Vertical blank is in progress.\0";
  495. case DDERR_WASSTILLDRAWING:
  496. return "DDERR_WASSTILLDRAWING";
  497. case DDERR_WRONGMODE:
  498. return "This surface can not be restored because it was created in a different mode.\0";
  499. case DDERR_XALIGN:
  500. return "Rectangle provided was not horizontally aligned on required boundary.\0";
  501. default:
  502. return "UNKNOWN\0";
  503. }
  504. }