Jump to content
  • Advertisement

Archived

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

chr1701

Create DDraw-obj with one prim. surface

This topic is 6458 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
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
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
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!