Create DDraw-obj with one prim. surface
Hi,
i have problems initializing my Directdraw object. I want to have an object which has only one primary surface and no backbuffers.
Here''s my code:
// Create the primary surface with 1 back buffer
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize=sizeof(ddsd);
ddsd.dwFlags=DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount=1;
hRet=g_pDD->CreateSurface(&ddsd, &g_pDDSPrimary, NULL);
if (hRet!=DD_OK) {
TRACE("Could not create primary surface - error code %d\n", hRet);
return false;
}
I have tried to set dwBackBufferCount to 0 but this didn''t work.
When i try to lock the primary surface, i get an DERR_INVALIDPARAMS, and i guess it''s due to this initialization.
Can anyone help me please?
Thanks,
Chris
Try doing like this instead...
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize=sizeof(ddsd);
// enable valid fields
ddsd.dwFlags = DDSD_CAPS;
// request primary surface
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
// create the primary surface
hRet = g_pDD->CreateSurface(&ddsd, &g_pDDSPrimary, NULL);
if (hRet!=DD_OK)
{
TRACE("Could not create primary surface - error code %d\n", hRet);
return false;
}
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize=sizeof(ddsd);
// enable valid fields
ddsd.dwFlags = DDSD_CAPS;
// request primary surface
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
// create the primary surface
hRet = g_pDD->CreateSurface(&ddsd, &g_pDDSPrimary, NULL);
if (hRet!=DD_OK)
{
TRACE("Could not create primary surface - error code %d\n", hRet);
return false;
}
Thanks, this works. My problem is that i always tried to lock() the primary surface and i needed some time to figure out that the primary surface can''t be locked...
Therefore another question: Why can''t the primary surface be locked? Sure, this is a decision of the guys at microsoft, but i don''t see the advantage of this...
Chris
Therefore another question: Why can''t the primary surface be locked? Sure, this is a decision of the guys at microsoft, but i don''t see the advantage of this...
Chris
Mode X modes (320x200 and 320x240 without the DDSDM_STANDARDVGAMODE) cannot have their primary surfaces locked, but this is because of the nature of Windows and the fact that it does not support these modes. Apart from that you should be able to lock the primary surface. Well, I can.
Please state the nature of the debugging emergency.
Please state the nature of the debugging emergency.
Everybody can lock but me
OK, i create my primary surface as written above, and then try to lock it:
HRESULT hRes;
DDSURFACEDESC2 DDSurfaceDesc;
hRes=g_pDDSPrimary->Lock(NULL, &DDSurfaceDesc,
DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hRes!=DD_OK) {
TRACE("Could not lock - return code %d\n", hRes);
return false;
}
The error value is INVALID_PARAMETER. What am i doing wrong?
Chris
OK, i create my primary surface as written above, and then try to lock it:
HRESULT hRes;
DDSURFACEDESC2 DDSurfaceDesc;
hRes=g_pDDSPrimary->Lock(NULL, &DDSurfaceDesc,
DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hRes!=DD_OK) {
TRACE("Could not lock - return code %d\n", hRes);
return false;
}
The error value is INVALID_PARAMETER. What am i doing wrong?
Chris
You might want to try...
//==========================================
DDSURFACEDESC2 surfaceDesc;
memset (&surfaceDesc,0,(sizeof(surfaceDesc)));
surfaceDesc.dwSize = sizeof (surfaceDesc);
//========================================
before passing the DDSURFACEDESC to Lock.
/ Tooon
//==========================================
DDSURFACEDESC2 surfaceDesc;
memset (&surfaceDesc,0,(sizeof(surfaceDesc)));
surfaceDesc.dwSize = sizeof (surfaceDesc);
//========================================
before passing the DDSURFACEDESC to Lock.
/ Tooon
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement