Archived

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

chr1701

Create DDraw-obj with one prim. surface

Recommended Posts

chr1701    122
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

Share this post


Link to post
Share on other sites
En3my    122
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;
}

Share this post


Link to post
Share on other sites
chr1701    122
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

Share this post


Link to post
Share on other sites
furby100    102
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.


sharewaregames.20m.com

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites
Tooon    122
You might want to try...

//==========================================
DDSURFACEDESC2 surfaceDesc;
memset (&surfaceDesc,0,(sizeof(surfaceDesc)));
surfaceDesc.dwSize = sizeof (surfaceDesc);
//========================================

before passing the DDSURFACEDESC to Lock.

/ Tooon

Share this post


Link to post
Share on other sites