directx.cc 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810
  1. /********************************************************************** <BR>
  2. This file is part of Crack dot Com's free source code release of
  3. Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
  4. information about compiling & licensing issues visit this URL</a>
  5. <PRE> If that doesn't help, contact Jonathan Clark at
  6. golgotha_source@usa.net (Subject should have "GOLG" in it)
  7. ***********************************************************************/
  8. #ifdef _WINDOWS
  9. //#define INITGUID
  10. #include "video/win32/directx.hh"
  11. #include "device/event.hh"
  12. #include <d3d.h>
  13. #include <d3drm.h>
  14. //#include "video/win32/dx_cursor.hh"
  15. #endif
  16. // this should be defined in main/win_main
  17. extern HINSTANCE my_instance;
  18. extern int my_nCmdShow;
  19. extern sw32 win32_mouse_x, win32_mouse_y;
  20. static directx_display_class directx_display_instance;
  21. char* D3DAppErrorToString(HRESULT error);
  22. void dx_error(sw32 result)
  23. {
  24. i4_error(D3DAppErrorToString(result));
  25. }
  26. // called when windows gives us a WM_MOVE message, this tells everyone else interested
  27. void directx_display_class::move_screen(i4_coord x, i4_coord y)
  28. {
  29. if (back_buffer) // make sure the screen has been created so far
  30. {
  31. // if the location is not word alligned move the
  32. // window and exit (we will get another message later when this takes effect)
  33. if (x&3)
  34. {
  35. SetWindowPos(input.get_window_handle(),
  36. HWND_TOP,
  37. x&(~3),y,
  38. cur_mode.xres,
  39. cur_mode.yres,
  40. 0);
  41. return ;
  42. }
  43. }
  44. }
  45. i4_bool directx_display_class::set_mouse_shape(i4_cursor_class *c)
  46. {
  47. return i4_T;
  48. }
  49. directx_display_class::directx_display_class()
  50. {
  51. mouse_pict=0;
  52. mouse_save=0;
  53. mouse_trans=0;
  54. context=0;
  55. direct_draw_driver=0;
  56. primary_surface=0;
  57. exclusive_mode=i4_F;
  58. full_screen=i4_F;
  59. back_buffer=0;
  60. back_surface=0;
  61. }
  62. HRESULT __stdcall dx_mode_callback(LPDDSURFACEDESC desc, LPVOID context)
  63. {
  64. directx_display_class *dx=(directx_display_class *)context;
  65. if (((desc->ddpfPixelFormat.dwRGBBitCount+1)&(~1)) == I4_BYTES_PER_PIXEL*8)
  66. {
  67. if (dx->last_found &&
  68. dx->last_found->xres==desc->dwWidth &&
  69. dx->last_found->yres==desc->dwHeight)
  70. dx->saw_last=i4_T;
  71. else if (!dx->last_found || (dx->saw_last))
  72. {
  73. dx->saw_last=i4_F;
  74. dx->last_found=&dx->amode;
  75. dx->last_found->xres=desc->dwWidth;
  76. dx->last_found->yres=desc->dwHeight;
  77. dx->last_found->flags = i4_display_class::mode::PAGE_FLIPPED;
  78. dx->last_found->bits_per_pixel = desc->ddpfPixelFormat.dwRGBBitCount;
  79. dx->last_found->assoc=dx;
  80. w32 rbits=0, gbits=0, bbits=0,m,tbits, depth;
  81. m = desc->ddpfPixelFormat.dwRBitMask;
  82. if (!m) return D3DENUMRET_OK;
  83. dx->last_found->red_mask=m;
  84. for (; !(m & 1); m >>= 1);
  85. for (; m&1; m>>=1) rbits++;
  86. m = desc->ddpfPixelFormat.dwGBitMask;
  87. if (!m) return D3DENUMRET_OK;
  88. dx->last_found->green_mask=m;
  89. for (; !(m & 1); m >>= 1);
  90. for (; m&1; m>>=1) gbits++;
  91. m = desc->ddpfPixelFormat.dwBBitMask;
  92. if (!m) return D3DENUMRET_OK;
  93. dx->last_found->blue_mask=m;
  94. for (; !(m & 1); m >>= 1);
  95. for (; m&1; m>>=1) bbits++;
  96. sprintf(dx->last_found->name,"Page flipped %d x %d x %d (%d%d%d)",
  97. desc->dwWidth,
  98. desc->dwHeight,
  99. desc->ddpfPixelFormat.dwRGBBitCount,
  100. rbits, gbits, bbits);
  101. i4_warning("Mode : %s\n",dx->last_found->name);
  102. }
  103. }
  104. return D3DENUMRET_OK;
  105. }
  106. i4_display_class::mode *directx_display_class::get_next_mode(i4_display_class::mode *last_mode)
  107. {
  108. sw32 last_w=last_mode->xres,
  109. last_h=last_mode->yres;
  110. if (!full_screen)
  111. return 0;
  112. else
  113. {
  114. saw_last = i4_F;
  115. last_found = (directx_display_class::directx_mode *)last_mode;
  116. if (!exclusive_mode)
  117. {
  118. direct_draw_driver->SetCooperativeLevel(input.get_window_handle(),
  119. DDSCL_ALLOWREBOOT |
  120. DDSCL_EXCLUSIVE |
  121. DDSCL_FULLSCREEN );
  122. direct_draw_driver->EnumDisplayModes(0, 0, this, dx_mode_callback);
  123. direct_draw_driver->SetCooperativeLevel(input.get_window_handle(),
  124. DDSCL_NORMAL);
  125. }
  126. else
  127. direct_draw_driver->EnumDisplayModes(0, 0, this, dx_mode_callback);
  128. if (last_found->xres==last_w && last_found->yres==last_h)
  129. return 0;
  130. else
  131. return last_found;
  132. }
  133. }
  134. i4_display_class::mode *directx_display_class::get_first_mode()
  135. {
  136. if (!direct_draw_driver)
  137. {
  138. if (!create_direct_draw()) // initialize the direct draw driver if not already
  139. return 0;
  140. }
  141. if (full_screen)
  142. {
  143. saw_last = i4_F;
  144. last_found = 0;
  145. if (!exclusive_mode)
  146. {
  147. direct_draw_driver->SetCooperativeLevel(input.get_window_handle(),
  148. DDSCL_ALLOWREBOOT |
  149. DDSCL_EXCLUSIVE |
  150. DDSCL_FULLSCREEN );
  151. direct_draw_driver->EnumDisplayModes(0, 0, this, dx_mode_callback);
  152. direct_draw_driver->SetCooperativeLevel(input.get_window_handle(),
  153. DDSCL_NORMAL);
  154. }
  155. else
  156. direct_draw_driver->EnumDisplayModes(0, 0, this, dx_mode_callback);
  157. return last_found;
  158. }
  159. else
  160. {
  161. // get the current video mode that windows is running in
  162. DDSURFACEDESC surface_description;
  163. // just for luck, clear this out
  164. memset(&surface_description,0,sizeof(surface_description));
  165. // need to tell win how big this structure is
  166. surface_description.dwSize=sizeof(surface_description);
  167. // ask windows to fill in the struct
  168. direct_draw_driver->GetDisplayMode(&surface_description);
  169. // since we only support one bit depth per
  170. // executable make sure windows is running in the bit depth
  171. // this executable was made for
  172. if (surface_description.ddpfPixelFormat.dwRGBBitCount!=I4_BYTES_PER_PIXEL*8)
  173. return 0;
  174. // fill in one of our own mode strucutres to report to the caller
  175. memset(&amode,0,sizeof(amode));
  176. strcpy(amode.name,"Win32 direct screen window");
  177. amode.flags=i4_display_class::mode::RESOLUTION_DETERMINED_ON_OPEN;
  178. amode.bits_per_pixel=I4_SCREEN_DEPTH;
  179. amode.xres=surface_description.dwWidth;
  180. amode.yres=surface_description.dwHeight;
  181. amode.red_mask=surface_description.ddpfPixelFormat.dwRBitMask;
  182. amode.green_mask=surface_description.ddpfPixelFormat.dwGBitMask;
  183. amode.blue_mask=surface_description.ddpfPixelFormat.dwBBitMask;
  184. amode.assoc=this; // so we know in 'initialize_mode' that we created this mode
  185. }
  186. return &amode;
  187. }
  188. i4_bool directx_display_class::create_direct_draw()
  189. {
  190. if (direct_draw_driver) // is it already created?
  191. return i4_T;
  192. // try to create it
  193. HRESULT ret = DirectDrawCreate( NULL, &direct_draw_driver, NULL );
  194. // failed ?
  195. if ( ret != DD_OK )
  196. return i4_F;
  197. return i4_T;
  198. }
  199. void directx_display_class::destroy_direct_draw()
  200. {
  201. if (direct_draw_driver)
  202. {
  203. direct_draw_driver->Release();
  204. direct_draw_driver=0;
  205. }
  206. }
  207. i4_bool directx_display_class::close()
  208. {
  209. if (context)
  210. {
  211. delete context;
  212. context=0;
  213. }
  214. if (exclusive_mode && direct_draw_driver)
  215. {
  216. direct_draw_driver->SetCooperativeLevel(input.get_window_handle(), DDSCL_NORMAL );
  217. direct_draw_driver->RestoreDisplayMode();
  218. exclusive_mode=i4_F;
  219. }
  220. if (primary_surface)
  221. {
  222. primary_surface->Release();
  223. primary_surface=0;
  224. }
  225. if (back_buffer)
  226. {
  227. delete back_buffer;
  228. back_buffer=0;
  229. }
  230. input.destroy_window();
  231. return i4_T;
  232. }
  233. i4_bool directx_display_class::initialize_mode(i4_display_class::mode *which_one)
  234. {
  235. // make sure this is a mode we listed, and not some other driver
  236. if ((((directx_mode *)which_one)->assoc)==this)
  237. {
  238. memcpy(&cur_mode,which_one,sizeof(cur_mode));
  239. close();
  240. w32 width=which_one->xres, height=which_one->yres;
  241. if (!direct_draw_driver)
  242. {
  243. if (!create_direct_draw()) // initialize the direct draw driver if not already
  244. return i4_F;
  245. }
  246. input.create_window(0,0,width, height, this);
  247. HRESULT ddrval;
  248. if (!full_screen)
  249. ddrval = direct_draw_driver->SetCooperativeLevel(input.get_window_handle(),
  250. DDSCL_NORMAL );
  251. else if (!exclusive_mode)
  252. {
  253. ddrval = direct_draw_driver->SetCooperativeLevel( input.get_window_handle(),
  254. DDSCL_ALLOWREBOOT |
  255. DDSCL_EXCLUSIVE |
  256. DDSCL_FULLSCREEN );
  257. exclusive_mode=i4_T;
  258. if (ddrval!=DD_OK)
  259. dx_error(ddrval);
  260. /*
  261. SetWindowPos(win32_display_instance.window_handle, HWND_BOTTOM,
  262. 0,600, 320, 100, SWP_NOACTIVATE | SWP_NOZORDER);
  263. */
  264. }
  265. if (full_screen)
  266. direct_draw_driver->SetDisplayMode(which_one->xres,
  267. which_one->yres,
  268. I4_BYTES_PER_PIXEL*8
  269. );
  270. if (ddrval != DD_OK)
  271. {
  272. input.destroy_window();
  273. return i4_F;
  274. }
  275. if (!create_surfaces(&cur_mode))
  276. {
  277. primary_surface=0;
  278. input.destroy_window();
  279. return i4_F;
  280. }
  281. if (context)
  282. delete context;
  283. context=new i4_draw_context_class(0,0,width-1,height-1);
  284. context->both_dirty=new i4_rect_list_class;
  285. context->both_dirty->add_area(0,0,width-1,height-1);
  286. context->single_dirty=new i4_rect_list_class;
  287. return i4_T;
  288. } else return i4_F;
  289. }
  290. void directx_display_class::flush()
  291. {
  292. // add the single dirty area into the both dirty list
  293. i4_rect_list_class::area_iter a;
  294. for (a=context->single_dirty->list.begin();
  295. a!=context->single_dirty->list.end();
  296. ++a)
  297. context->both_dirty->add_area(a->x1, a->y1, a->x2, a->y2);
  298. context->single_dirty->delete_list();
  299. if (context->both_dirty->empty())
  300. return ;
  301. context->both_dirty->delete_list();
  302. }
  303. w32 directx_display_class::priority()
  304. {
  305. if (create_direct_draw())
  306. {
  307. destroy_direct_draw();
  308. return 2;
  309. }
  310. else
  311. return 0;
  312. }
  313. i4_bool directx_display_class::create_surfaces(directx_mode *mode)
  314. {
  315. // Create the primary surface
  316. DDSURFACEDESC ddsd;
  317. ddsd.dwSize = sizeof( ddsd );
  318. ddsd.dwFlags = DDSD_CAPS;
  319. ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
  320. HRESULT ddrval = direct_draw_driver->CreateSurface( &ddsd, &primary_surface,0);
  321. if (ddrval != DD_OK)
  322. {
  323. dx_error(ddrval);
  324. return i4_F;
  325. }
  326. create_back_surface(mode);
  327. win32_mouse_x=-1; // the mouse thread will wait till this is not -1 before it
  328. // starts tracking the mouse (then we will know where the system mouse is)
  329. return i4_T;
  330. }
  331. i4_bool directx_display_class::create_back_surface(directx_mode *mode)
  332. {
  333. DDSURFACEDESC ddsd;
  334. ddsd.dwSize = sizeof(ddsd);
  335. ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
  336. ddsd.dwWidth = mode->xres;
  337. ddsd.dwHeight = mode->yres;
  338. ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; // | DDSCAPS_SYSTEMMEMORY;
  339. // create a new back buffer
  340. HRESULT er = direct_draw_driver->CreateSurface(&ddsd, &back_surface, 0);
  341. if (er != DD_OK)
  342. {
  343. dx_error(er);
  344. return i4_F;
  345. }
  346. i4_pixel_format fmt;
  347. fmt.pixel_depth=I4_16BIT;
  348. fmt.red_mask=mode->red_mask;
  349. fmt.green_mask=mode->green_mask;
  350. fmt.blue_mask=mode->blue_mask;
  351. fmt.alpha_mask=0;
  352. fmt.calc_shift();
  353. pal = i4_pal_man.register_pal(&fmt);
  354. // create the i4_image_class which points to the surface memory
  355. er=back_surface->Lock(0, &ddsd, DDLOCK_WAIT, 0);
  356. if (er == DD_OK)
  357. {
  358. w8 *v_addr=(w8 *)ddsd.lpSurface; // this is the address
  359. back_surface->Unlock(0); // Now that we have the video address, unlock so we can debug!
  360. if (back_surface)
  361. delete back_buffer; // delete the old screen
  362. // create the image that maps to screen memory
  363. back_buffer=new I4_SCREEN_TYPE(cur_mode.xres,
  364. cur_mode.yres,
  365. pal,
  366. ddsd.lPitch,
  367. v_addr);
  368. if (context)
  369. delete context;
  370. context=new i4_draw_context_class(0,0,
  371. back_buffer->width()-1,
  372. back_buffer->height()-1);
  373. context->both_dirty=new i4_rect_list_class;
  374. context->single_dirty=new i4_rect_list_class;
  375. }
  376. else
  377. {
  378. dx_error(er);
  379. return i4_F;
  380. }
  381. return i4_T;
  382. }
  383. void directx_display_class::get_window_pos(sw32 &x, sw32 &y)
  384. {
  385. POINT p;
  386. p.x=0;
  387. p.y=0;
  388. ClientToScreen(input.get_window_handle(), &p);
  389. x=p.x;
  390. y=p.y;
  391. }
  392. void directx_display_class::active(i4_bool act)
  393. {
  394. /* if (cursor)
  395. cursor->active(act); */
  396. }
  397. i4_bool directx_display_class::available()
  398. {
  399. int need_destroy=direct_draw_driver != NULL;
  400. if (create_direct_draw())
  401. {
  402. if (need_destroy)
  403. destroy_direct_draw();
  404. return i4_T;
  405. }
  406. else return i4_F;
  407. }
  408. i4_image_class *directx_display_class::get_screen()
  409. {
  410. return back_buffer;
  411. }
  412. char* D3DAppErrorToString(HRESULT error)
  413. {
  414. switch(error) {
  415. case DD_OK:
  416. return "No error.\0";
  417. case DDERR_ALREADYINITIALIZED:
  418. return "This object is already initialized.\0";
  419. case DDERR_BLTFASTCANTCLIP:
  420. return "Return if a clipper object is attached to the source surface passed into a BltFast call.\0";
  421. case DDERR_CANNOTATTACHSURFACE:
  422. return "This surface can not be attached to the requested surface.\0";
  423. case DDERR_CANNOTDETACHSURFACE:
  424. return "This surface can not be detached from the requested surface.\0";
  425. case DDERR_CANTCREATEDC:
  426. return "Windows can not create any more DCs.\0";
  427. case DDERR_CANTDUPLICATE:
  428. return "Can't duplicate primary & 3D surfaces, or surfaces that are implicitly created.\0";
  429. case DDERR_CLIPPERISUSINGHWND:
  430. return "An attempt was made to set a cliplist for a clipper object that is already monitoring an hwnd.\0";
  431. case DDERR_COLORKEYNOTSET:
  432. return "No src color key specified for this operation.\0";
  433. case DDERR_CURRENTLYNOTAVAIL:
  434. return "Support is currently not available.\0";
  435. case DDERR_DIRECTDRAWALREADYCREATED:
  436. return "A DirectDraw object representing this driver has already been created for this process.\0";
  437. case DDERR_EXCEPTION:
  438. return "An exception was encountered while performing the requested operation.\0";
  439. case DDERR_EXCLUSIVEMODEALREADYSET:
  440. return "An attempt was made to set the cooperative level when it was already set to exclusive.\0";
  441. case DDERR_GENERIC:
  442. return "Generic failure.\0";
  443. case DDERR_HEIGHTALIGN:
  444. return "Height of rectangle provided is not a multiple of reqd alignment.\0";
  445. case DDERR_HWNDALREADYSET:
  446. return "The CooperativeLevel HWND has already been set. It can not be reset while the process has surfaces or palettes created.\0";
  447. case DDERR_HWNDSUBCLASSED:
  448. return "HWND used by DirectDraw CooperativeLevel has been subclassed, this prevents DirectDraw from restoring state.\0";
  449. case DDERR_IMPLICITLYCREATED:
  450. return "This surface can not be restored because it is an implicitly created surface.\0";
  451. case DDERR_INCOMPATIBLEPRIMARY:
  452. return "Unable to match primary surface creation request with existing primary surface.\0";
  453. case DDERR_INVALIDCAPS:
  454. return "One or more of the caps bits passed to the callback are incorrect.\0";
  455. case DDERR_INVALIDCLIPLIST:
  456. return "DirectDraw does not support the provided cliplist.\0";
  457. case DDERR_INVALIDDIRECTDRAWGUID:
  458. return "The GUID passed to DirectDrawCreate is not a valid DirectDraw driver identifier.\0";
  459. case DDERR_INVALIDMODE:
  460. return "DirectDraw does not support the requested mode.\0";
  461. case DDERR_INVALIDOBJECT:
  462. return "DirectDraw received a pointer that was an invalid DIRECTDRAW object.\0";
  463. case DDERR_INVALIDPARAMS:
  464. return "One or more of the parameters passed to the function are incorrect.\0";
  465. case DDERR_INVALIDPIXELFORMAT:
  466. return "The pixel format was invalid as specified.\0";
  467. case DDERR_INVALIDPOSITION:
  468. return "Returned when the position of the overlay on the destination is no longer legal for that destination.\0";
  469. case DDERR_INVALIDRECT:
  470. return "Rectangle provided was invalid.\0";
  471. case DDERR_LOCKEDSURFACES:
  472. return "Operation could not be carried out because one or more surfaces are locked.\0";
  473. case DDERR_NO3D:
  474. return "There is no 3D present.\0";
  475. case DDERR_NOALPHAHW:
  476. return "Operation could not be carried out because there is no alpha accleration hardware present or available.\0";
  477. case DDERR_NOBLTHW:
  478. return "No blitter hardware present.\0";
  479. case DDERR_NOCLIPLIST:
  480. return "No cliplist available.\0";
  481. case DDERR_NOCLIPPERATTACHED:
  482. return "No clipper object attached to surface object.\0";
  483. case DDERR_NOCOLORCONVHW:
  484. return "Operation could not be carried out because there is no color conversion hardware present or available.\0";
  485. case DDERR_NOCOLORKEY:
  486. return "Surface doesn't currently have a color key\0";
  487. case DDERR_NOCOLORKEYHW:
  488. return "Operation could not be carried out because there is no hardware support of the destination color key.\0";
  489. case DDERR_NOCOOPERATIVELEVELSET:
  490. return "Create function called without DirectDraw object method SetCooperativeLevel being called.\0";
  491. case DDERR_NODC:
  492. return "No DC was ever created for this surface.\0";
  493. case DDERR_NODDROPSHW:
  494. return "No DirectDraw ROP hardware.\0";
  495. case DDERR_NODIRECTDRAWHW:
  496. return "A hardware-only DirectDraw object creation was attempted but the driver did not support any hardware.\0";
  497. case DDERR_NOEMULATION:
  498. return "Software emulation not available.\0";
  499. case DDERR_NOEXCLUSIVEMODE:
  500. return "Operation requires the application to have exclusive mode but the application does not have exclusive mode.\0";
  501. case DDERR_NOFLIPHW:
  502. return "Flipping visible surfaces is not supported.\0";
  503. case DDERR_NOGDI:
  504. return "There is no GDI present.\0";
  505. case DDERR_NOHWND:
  506. return "Clipper notification requires an HWND or no HWND has previously been set as the CooperativeLevel HWND.\0";
  507. case DDERR_NOMIRRORHW:
  508. return "Operation could not be carried out because there is no hardware present or available.\0";
  509. case DDERR_NOOVERLAYDEST:
  510. return "Returned when GetOverlayPosition is called on an overlay that UpdateOverlay has never been called on to establish a destination.\0";
  511. case DDERR_NOOVERLAYHW:
  512. return "Operation could not be carried out because there is no overlay hardware present or available.\0";
  513. case DDERR_NOPALETTEATTACHED:
  514. return "No palette object attached to this surface.\0";
  515. case DDERR_NOPALETTEHW:
  516. return "No hardware support for 16 or 256 color palettes.\0";
  517. case DDERR_NORASTEROPHW:
  518. return "Operation could not be carried out because there is no appropriate raster op hardware present or available.\0";
  519. case DDERR_NOROTATIONHW:
  520. return "Operation could not be carried out because there is no rotation hardware present or available.\0";
  521. case DDERR_NOSTRETCHHW:
  522. return "Operation could not be carried out because there is no hardware support for stretching.\0";
  523. case DDERR_NOT4BITCOLOR:
  524. return "DirectDrawSurface is not in 4 bit color palette and the requested operation requires 4 bit color palette.\0";
  525. case DDERR_NOT4BITCOLORINDEX:
  526. return "DirectDrawSurface is not in 4 bit color index palette and the requested operation requires 4 bit color index palette.\0";
  527. case DDERR_NOT8BITCOLOR:
  528. return "DirectDrawSurface is not in 8 bit color mode and the requested operation requires 8 bit color.\0";
  529. case DDERR_NOTAOVERLAYSURFACE:
  530. return "Returned when an overlay member is called for a non-overlay surface.\0";
  531. case DDERR_NOTEXTUREHW:
  532. return "Operation could not be carried out because there is no texture mapping hardware present or available.\0";
  533. case DDERR_NOTFLIPPABLE:
  534. return "An attempt has been made to flip a surface that is not flippable.\0";
  535. case DDERR_NOTFOUND:
  536. return "Requested item was not found.\0";
  537. case DDERR_NOTLOCKED:
  538. return "Surface was not locked. An attempt to unlock a surface that was not locked at all, or by this process, has been attempted.\0";
  539. case DDERR_NOTPALETTIZED:
  540. return "The surface being used is not a palette-based surface.\0";
  541. case DDERR_NOVSYNCHW:
  542. return "Operation could not be carried out because there is no hardware support for vertical blank synchronized operations.\0";
  543. case DDERR_NOZBUFFERHW:
  544. return "Operation could not be carried out because there is no hardware support for zbuffer blitting.\0";
  545. case DDERR_NOZOVERLAYHW:
  546. return "Overlay surfaces could not be z layered based on their BltOrder because the hardware does not support z layering of overlays.\0";
  547. case DDERR_OUTOFCAPS:
  548. return "The hardware needed for the requested operation has already been allocated.\0";
  549. case DDERR_OUTOFMEMORY:
  550. return "DirectDraw does not have enough memory to perform the operation.\0";
  551. case DDERR_OUTOFVIDEOMEMORY:
  552. return "DirectDraw does not have enough memory to perform the operation.\0";
  553. case DDERR_OVERLAYCANTCLIP:
  554. return "The hardware does not support clipped overlays.\0";
  555. case DDERR_OVERLAYCOLORKEYONLYONEACTIVE:
  556. return "Can only have ony color key active at one time for overlays.\0";
  557. case DDERR_OVERLAYNOTVISIBLE:
  558. return "Returned when GetOverlayPosition is called on a hidden overlay.\0";
  559. case DDERR_PALETTEBUSY:
  560. return "Access to this palette is being refused because the palette is already locked by another thread.\0";
  561. case DDERR_PRIMARYSURFACEALREADYEXISTS:
  562. return "This process already has created a primary surface.\0";
  563. case DDERR_REGIONTOOSMALL:
  564. return "Region passed to Clipper::GetClipList is too small.\0";
  565. case DDERR_SURFACEALREADYATTACHED:
  566. return "This surface is already attached to the surface it is being attached to.\0";
  567. case DDERR_SURFACEALREADYDEPENDENT:
  568. return "This surface is already a dependency of the surface it is being made a dependency of.\0";
  569. case DDERR_SURFACEBUSY:
  570. return "Access to this surface is being refused because the surface is already locked by another thread.\0";
  571. case DDERR_SURFACEISOBSCURED:
  572. return "Access to surface refused because the surface is obscured.\0";
  573. case DDERR_SURFACELOST:
  574. return "Access to this surface is being refused because the surface memory is gone. The DirectDrawSurface object representing this surface should have Restore called on it.\0";
  575. case DDERR_SURFACENOTATTACHED:
  576. return "The requested surface is not attached.\0";
  577. case DDERR_TOOBIGHEIGHT:
  578. return "Height requested by DirectDraw is too large.\0";
  579. case DDERR_TOOBIGSIZE:
  580. return "Size requested by DirectDraw is too large, but the individual height and width are OK.\0";
  581. case DDERR_TOOBIGWIDTH:
  582. return "Width requested by DirectDraw is too large.\0";
  583. case DDERR_UNSUPPORTED:
  584. return "Action not supported.\0";
  585. case DDERR_UNSUPPORTEDFORMAT:
  586. return "FOURCC format requested is unsupported by DirectDraw.\0";
  587. case DDERR_UNSUPPORTEDMASK:
  588. return "Bitmask in the pixel format requested is unsupported by DirectDraw.\0";
  589. case DDERR_VERTICALBLANKINPROGRESS:
  590. return "Vertical blank is in progress.\0";
  591. case DDERR_WASSTILLDRAWING:
  592. return "Informs DirectDraw that the previous Blt which is transfering information to or from this Surface is incomplete.\0";
  593. case DDERR_WRONGMODE:
  594. return "This surface can not be restored because it was created in a different mode.\0";
  595. case DDERR_XALIGN:
  596. return "Rectangle provided was not horizontally aligned on required boundary.\0";
  597. case D3DERR_BADMAJORVERSION:
  598. return "D3DERR_BADMAJORVERSION\0";
  599. case D3DERR_BADMINORVERSION:
  600. return "D3DERR_BADMINORVERSION\0";
  601. case D3DERR_EXECUTE_LOCKED:
  602. return "D3DERR_EXECUTE_LOCKED\0";
  603. case D3DERR_EXECUTE_NOT_LOCKED:
  604. return "D3DERR_EXECUTE_NOT_LOCKED\0";
  605. case D3DERR_EXECUTE_CREATE_FAILED:
  606. return "D3DERR_EXECUTE_CREATE_FAILED\0";
  607. case D3DERR_EXECUTE_DESTROY_FAILED:
  608. return "D3DERR_EXECUTE_DESTROY_FAILED\0";
  609. case D3DERR_EXECUTE_LOCK_FAILED:
  610. return "D3DERR_EXECUTE_LOCK_FAILED\0";
  611. case D3DERR_EXECUTE_UNLOCK_FAILED:
  612. return "D3DERR_EXECUTE_UNLOCK_FAILED\0";
  613. case D3DERR_EXECUTE_FAILED:
  614. return "D3DERR_EXECUTE_FAILED\0";
  615. case D3DERR_EXECUTE_CLIPPED_FAILED:
  616. return "D3DERR_EXECUTE_CLIPPED_FAILED\0";
  617. case D3DERR_TEXTURE_NO_SUPPORT:
  618. return "D3DERR_TEXTURE_NO_SUPPORT\0";
  619. case D3DERR_TEXTURE_NOT_LOCKED:
  620. return "D3DERR_TEXTURE_NOT_LOCKED\0";
  621. case D3DERR_TEXTURE_LOCKED:
  622. return "D3DERR_TEXTURELOCKED\0";
  623. case D3DERR_TEXTURE_CREATE_FAILED:
  624. return "D3DERR_TEXTURE_CREATE_FAILED\0";
  625. case D3DERR_TEXTURE_DESTROY_FAILED:
  626. return "D3DERR_TEXTURE_DESTROY_FAILED\0";
  627. case D3DERR_TEXTURE_LOCK_FAILED:
  628. return "D3DERR_TEXTURE_LOCK_FAILED\0";
  629. case D3DERR_TEXTURE_UNLOCK_FAILED:
  630. return "D3DERR_TEXTURE_UNLOCK_FAILED\0";
  631. case D3DERR_TEXTURE_LOAD_FAILED:
  632. return "D3DERR_TEXTURE_LOAD_FAILED\0";
  633. case D3DERR_MATRIX_CREATE_FAILED:
  634. return "D3DERR_MATRIX_CREATE_FAILED\0";
  635. case D3DERR_MATRIX_DESTROY_FAILED:
  636. return "D3DERR_MATRIX_DESTROY_FAILED\0";
  637. case D3DERR_MATRIX_SETDATA_FAILED:
  638. return "D3DERR_MATRIX_SETDATA_FAILED\0";
  639. case D3DERR_SETVIEWPORTDATA_FAILED:
  640. return "D3DERR_SETVIEWPORTDATA_FAILED\0";
  641. case D3DERR_MATERIAL_CREATE_FAILED:
  642. return "D3DERR_MATERIAL_CREATE_FAILED\0";
  643. case D3DERR_MATERIAL_DESTROY_FAILED:
  644. return "D3DERR_MATERIAL_DESTROY_FAILED\0";
  645. case D3DERR_MATERIAL_SETDATA_FAILED:
  646. return "D3DERR_MATERIAL_SETDATA_FAILED\0";
  647. case D3DERR_LIGHT_SET_FAILED:
  648. return "D3DERR_LIGHT_SET_FAILED\0";
  649. case D3DRMERR_BADOBJECT:
  650. return "D3DRMERR_BADOBJECT\0";
  651. case D3DRMERR_BADTYPE:
  652. return "D3DRMERR_BADTYPE\0";
  653. case D3DRMERR_BADALLOC:
  654. return "D3DRMERR_BADALLOC\0";
  655. case D3DRMERR_FACEUSED:
  656. return "D3DRMERR_FACEUSED\0";
  657. case D3DRMERR_NOTFOUND:
  658. return "D3DRMERR_NOTFOUND\0";
  659. case D3DRMERR_NOTDONEYET:
  660. return "D3DRMERR_NOTDONEYET\0";
  661. case D3DRMERR_FILENOTFOUND:
  662. return "The file was not found.\0";
  663. case D3DRMERR_BADFILE:
  664. return "D3DRMERR_BADFILE\0";
  665. case D3DRMERR_BADDEVICE:
  666. return "D3DRMERR_BADDEVICE\0";
  667. case D3DRMERR_BADVALUE:
  668. return "D3DRMERR_BADVALUE\0";
  669. case D3DRMERR_BADMAJORVERSION:
  670. return "D3DRMERR_BADMAJORVERSION\0";
  671. case D3DRMERR_BADMINORVERSION:
  672. return "D3DRMERR_BADMINORVERSION\0";
  673. case D3DRMERR_UNABLETOEXECUTE:
  674. return "D3DRMERR_UNABLETOEXECUTE\0";
  675. default:
  676. return "Unrecognized error value.\0";
  677. }
  678. }