DDraw 7 Question

Started by
1 comment, last by Analazon 21 years, 5 months ago
Ok, this is my first post on the GameDev.net forums, so hello! Now then, onto my question. I am (attempting) to learn how to use DirectDraw. I have it down fairly well in one single .cpp file, but I''m having trouble using it in an object. I created the engine object, and have most of the code working (I think...) but the problem lies in the fact that when I try to get fullscreen exclusive mode, it somehow fails. This is in the function HRESULT ENGINE::init_ddraw( HWND &hWnd ). It somehow doesn''t return DD_OK in this: hRet = g_pDD->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT); If you need any other part of the code, I can post it. Oh, BTW, this is running on my laptop (running XP Home). Thanks! ___________________ ~Analazon
___________________~Analazon
Advertisement
Well, the function call looks alright, so it''s probably something else you did wrong. So check the return value. I use this function at the moment for that purpose, although it currently doesn''t have all the possible return values (I add them in as I go along):


  // Return this error as a string -----------------------------------------const char* GetDXError(HRESULT err){    switch(err)    {    case DDERR_INCOMPATIBLEPRIMARY: return "DDERR_INCOMPATIBLEPRIMARY";    case DDERR_INVALIDCAPS: return "DDERR_INVALIDCAPS";     case DDERR_INVALIDOBJECT: return "DDERR_INVALIDOBJECT";     case DDERR_INVALIDPARAMS: return "DDERR_INVALIDPARAMS";     case DDERR_INVALIDPIXELFORMAT: return "DDERR_INVALIDPIXELFORMAT";     case DDERR_NOALPHAHW: return "DDERR_NOALPHAHW";     case DDERR_NOCOOPERATIVELEVELSET: return "DDERR_NOCOOPERATIVELEVELSET";     case DDERR_NODIRECTDRAWHW: return "DDERR_NODIRECTDRAWHW";     case DDERR_NOEMULATION: return "DDERR_NOEMULATION";     case DDERR_NOEXCLUSIVEMODE: return "DDERR_NOEXCLUSIVEMODE";     case DDERR_NOFLIPHW: return "DDERR_NOFLIPHW";     case DDERR_NOMIPMAPHW: return "DDERR_NOMIPMAPHW";     case DDERR_NOOVERLAYHW: return "DDERR_NOOVERLAYHW";     case DDERR_NOZBUFFERHW: return "DDERR_NOZBUFFERHW";     case DDERR_OUTOFMEMORY: return "DDERR_OUTOFMEMORY";     case DDERR_OUTOFVIDEOMEMORY: return "DDERR_OUTOFVIDEOMEMORY";     case DDERR_PRIMARYSURFACEALREADYEXISTS: return "DDERR_PRIMARYSURFACEALREADYEXISTS";     case DDERR_UNSUPPORTEDMODE: return "DDERR_UNSUPPORTEDMODE";     case DDERR_NOTFOUND: return "DDERR_NOTFOUND";    case DDERR_SURFACELOST: return "DDERR_SURFACELOST";    case DDERR_DIRECTDRAWALREADYCREATED: return "DDERR_DIRECTDRAWALREADYCREATED";    case DDERR_GENERIC: return "DDERR_GENERIC";    case DDERR_INVALIDDIRECTDRAWGUID: return "DDERR_INVALIDDIRECTDRAWGUID";    case DDERR_INVALIDMODE: return "DDERR_INVALIDMODE";    case DDERR_LOCKEDSURFACES: return "DDERR_LOCKEDSURFACES";    case DDERR_SURFACEBUSY: return "DDERR_SURFACEBUSY";    case DDERR_UNSUPPORTED: return "DDERR_UNSUPPORTED";    case DDERR_WASSTILLDRAWING: return "DDERR_WASSTILLDRAWING";    case DDERR_CANNOTATTACHSURFACE: return "DDERR_CANNOTATTACHSURFACE";    case DDERR_SURFACEALREADYATTACHED: return "DDERR_SURFACEALREADYATTACHED";    // D3D errors too    case D3DERR_STENCILBUFFER_NOTPRESENT: return "D3DERR_STENCILBUFFER_NOTPRESENT";    case D3DERR_VIEWPORTHASNODEVICE: return "D3DERR_VIEWPORTHASNODEVICE";    case D3DERR_ZBUFFER_NOTPRESENT: return "D3DERR_ZBUFFER_NOTPRESENT";    default: return "No error or undocumented error";    }}  


Once you get the appropriate char*, you can write it to a file so that you can see what went wrong, then look it up in the SDK docs. That is usually enough for me to fix any error.

(PS. If anyone has a complete version of something like the above function that works for DirectX 7, I''d love to see it. )

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]
heh, I did that, and I fuond out that I accidentally called the init_ddraw function twice....don''t I feel stupid...

but thanx, I wrote what you said into it

if(hRet == DDER_whatever)
initfail(hWnd, hRet, "DDER_whatever");

___________________~Analazon

This topic is closed to new replies.

Advertisement