Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

someone2

The big disaster experience!

This topic is 5246 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, Please help. i am starting to feel very bad! i can''t sleep! I want just to blit a bitmap on the screen using DirectX 7. here is the code to start with... //----------------------------------------------- hRet = Screen::getBackSurface()->Blt(&rcRect, g_pSurface,NULL,flag,NULL); if (hRet == DD_OK) return 0; //lost for some reason! restore it if(hRet==DDERR_SURFACELOST) { Screen::restore(); g_pSurface->Restore(); DDReLoadBitmap(); } return 0; //------------------------------------------------- This is the classic code you see everywhere. but, alas, this is WRONG! why, becuase, if you program was minimized when the program was loading, you will get some great response from Restore() of the surface that says DDERR_WRONGMODE, which is quite acceptable! so, what to do, this calls for this refinement //----------------------------------------------- hRet = Screen::getBackSurface()->Blt(&rcRect, g_pSurface,NULL,flag,NULL); if (hRet == DD_OK) return 0; //lost for some reason! restore it if(hRet==DDERR_SURFACELOST) { Screen::restore(); hRet = g_pSurface->Restore(); DDReLoadBitmap(); if(hRet==DDERR_WRONGMODE) {//we were in wrong mode when the surface was created, please re-create it! ZeroMemory(&ddsd, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.dwWidth = width; ddsd.dwHeight = height; Screen::getDirectDrawObject()->CreateSurface(&ddsd,&g_pSurface, NULL); } } return 0; //-------------------------------------------------------------- Now, you may think we have though about all possible cases! but, you are again WRONG!! the guys at micro$oft have made sure your life is going to be hell, if you try to play with this directX thing! Now, Blt() itself returns a more interesting response E_INVALIDARG! which means that the surface is invalid. "invalid" is a nice word, because i am now REALLY lost! what to do? //----------------------------------------------- hRet = Screen::getBackSurface()->Blt(&rcRect, g_pSurface,NULL,flag,NULL); if (hRet == DD_OK) return 0; //lost for some reason! restore it if(hRet==DDERR_SURFACELOST) { Screen::restore(); hRet = g_pSurface->Restore(); DDReLoadBitmap(); if(hRet==DDERR_WRONGMODE) {//we were in wrong mode when the surface was created, please re-create it! ZeroMemory(&ddsd, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.dwWidth = width; ddsd.dwHeight = height; Screen::getDirectDrawObject()->CreateSurface(&ddsd,&g_pSurface, NULL); } } else if(hRet==E_INVALIDARG) { //WHAT SHOULD I DO NOW? WILL MORE STRANGE RESPONSES ARISE? } return 0; //-------------------------------------------------------------- I am really feeling very bad right now, and my head is about to explode. So, please reply with anything. I will go nuts if nobody replies to this post!! Thank you in advance...

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by someone2
Now, you may think we have though about all possible cases!
but, you are again WRONG!! the guys at micro$oft have made sure your life is going to be hell, if you try to play with this directX thing!


Please don''t be like ''Microsoft has made this terrible and they are crap'', because:
(1) You are still using DirectDraw, not the new-and-updated DirectX (9), which is much easier. Yes, everybody knows DirectDraw was not so much fun, so Microsoft did a good job and made DX8 and DX9 much better

(2) If you''re life is hell and your head is about to explode, maybe you should just take a break

(3) Making 5 different topics about the same exact thing is not helpful to you at all. One topic will do. Not everybody knows all the details of DirectDraw anymore, as most have moved on to a newer version.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!