Archived

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

godel

easy ddraw question

Recommended Posts

I''m new to directx and I''m trying to use a surface lock to get a pointer to the memory of the surface. Here is my code: LPDIRECTDRAWSURFACE pSurface = bitmap2surf(sPathname, pDD); if (pSurface == NULL) return FALSE; DDSURFACEDESC description; HRESULT hrResponse = pSurface->Lock(NULL, &description, 0, NULL); For some reason Lock keeps returning DDERR_INVALIDPARAMS but I don''t see what the problem could be. I''m pretty that the bitmap2surf functions works, but I don''t know how to look at it in the debugger since it just treats it as an IUnknown. I would really appreciate any help. Thanx.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi,

I''m not sure if this is your error, but make sure you zero and filling the size of the DDSURFACEDESC structure...

DDSURFACEDESC description;
ZeroMemory (&description, sizeof (DDSURFACEDESC));
description.dwSize = sizeof (DDSURFACEDESC);
HRESULT hrResponse = pSurface->Lock(NULL, &description, 0, NULL);

I''m pretty sure (I don''t have the DX docs here, but you might want to specify that you want a pointer to the memory by passing the necessary flag to pSurface->Lock().

Try this...

HRESULT hrResponse = pSurface->Lock(NULL, &description, DDLOCK_SURFACEMEMORYPTR, NULL);

Even if that flag isn''t required, it''s maybe good DirectX manners (if such a thing exists!) to specify it.

Hope this helps,
- Peter

peter@digital-animations.com

Share this post


Link to post
Share on other sites