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