Archived

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

jimiwa

need help with ddraw

Recommended Posts

I am trying to start direct draw and am getting errors. SetCooperativeLevel is failing. When I take out the fail tests The mode is set and the screen switches to 640*480 fullscreen and then switches to 640*480 windows mode, gives a windows error, and only goes back to original mode if you choose continue on the compiler. The error is created by GetAttachedSurface, I found this out by commenting it out. How can I fix this so GetAttachedSurface works? Here’s the code: #include <ddraw.h> #include <windows.h> #include <mmsystem.h> #define INITGUID LPDIRECTDRAW7 lpdd; LPDIRECTDRAWSURFACE7 lpddsPrimary; LPDIRECTDRAWSURFACE7 lpddsBack; DDSURFACEDESC2 ddsd; LPDDSCAPS2 ddscaps; HWND g_hWnd; int DDInit(void); void DDClose(void); int CreateSurfaces(void); int main() { DDInit(); CreateSurfaces(); DDClose(); } int DDInit(void) { if (FAILED(DirectDrawCreateEx(NULL, (void **)&lpdd, IID_IDirectDraw7, NULL))) exit(10); if (FAILED(lpdd->SetCooperativeLevel(g_hWnd, DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT))) exit(11); if (FAILED(lpdd->SetDisplayMode(640,480,24,0,0))) exit(12); } void DDClose(void) { lpdd->Release(); return; } int CreateSurfaces() { HRESULT ddrval; memset(&ddsd,0,sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd.dwBackBufferCount = 1; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; if (FAILED(lpdd->CreateSurface(&ddsd, &lpddsPrimary, NULL))) return 0; ZeroMemory(&ddscaps, sizeof(ddscaps)); ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER; if (FAILED(lpddsPrimary->GetAttachedSurface(&ddsd.ddsCaps, &lpddsBack))) return 0; }

Share this post


Link to post
Share on other sites