Original Post
Here is the problem, I''ve been trying for hours to get this code to work, but I keep getting an error.
Here is the DirectDraw Initilization code:
I get the "Co-Op Error", and I can''t figure out why? I tried setting it to normal, but then I get the "Surface Error". Thanks alot.
// Attempt to create a Direct Draw interface
if ((DirectDrawCreateEx(NULL, (void **) &lpDD, IID_IDirectDraw7, NULL)) != DD_OK)
{
MessageBox(NULL, "Create Error", "ERROR", MB_OK);
return false;
}
// Attempt to take full control of the system
if ((lpDD->SetCooperativeLevel(hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE)) != DD_OK)
{
MessageBox(NULL, "Co-Op Error", "ERROR", MB_OK);
return false;
}
// Attempt to change the screen resolution
if ((lpDD->SetDisplayMode(800, 600, 16, 0, 0)) !=DD_OK)
{
MessageBox(NULL, "Display Error", "ERROR", MB_OK);
return false;
}
// Prepare to create the primary Direct Draw surface
DDSURFACEDESC2 ddsd;
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP |
DDSCAPS_3DDEVICE | DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;
// Attempt to create the primary Direct Draw surface
if ((lpDD->CreateSurface(&ddsd, &lpDDSPrimary, NULL)) != DD_OK)
{
MessageBox(NULL, "Surface Error", "ERROR", MB_OK);
return false;
}
// Prepare to retrieve the back buffer surface
DDSCAPS2 ddscaps;
ZeroMemory(&ddscaps, sizeof(ddscaps));
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
// Attempt to retrieve the back buffer surface
if ((lpDDSPrimary->GetAttachedSurface(&ddscaps, &lpDDSBackBuffer)) != DD_OK)
{
MessageBox(NULL, "Get Surface Error", "ERROR", MB_OK);
return false;
}
|