Jump to content
  • Advertisement


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


easy ddraw question

This topic is 6443 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

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

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


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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!