Jump to content
  • Advertisement
Sign in to follow this  

Why to Lock the primary surface fail in this way

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

		HDC hDc;
		IDirectDraw7* pDDraw;
		DDSURFACEDESC2 dDrawSurfDesc={0};
		DDSCAPS2 ddscaps = {0};

		hr = DirectDrawCreateEx(NULL, (LPVOID*)&pDDraw, IID_IDirectDraw7, NULL);
		//hr = pDDraw->SetDisplayMode(100, 100, 24, 0, 0);
		RECT rc;
		GetWindowRect(hWnd, &rc);
		SetWindowPos(hWnd, 0, rc.left, rc.top, rc.left+200, rc.top+200, 0);
		dDrawSurfDesc.dwSize = sizeof(dDrawSurfDesc);
		dDrawSurfDesc.dwFlags = DDSD_CAPS;
		dDrawSurfDesc.ddsCaps.dwCaps =  DDSCAPS_PRIMARYSURFACE;
		hr = pDDraw->CreateSurface(&dDrawSurfDesc, &pDDrawSurf, NULL); 
		hr = pDDrawSurf->Lock(NULL, &dDrawSurfDesc, DDLOCK_SURFACEMEMORYPTR, NULL);

An error occurs at the last line. the error code is "0x887601b3 ". I don't know how to fix it 


How to lock the primary surface? 

Share this post

Link to post
Share on other sites

HRESULT: 0x887601b3 (2289435059)
Description: Access to this surface is being refused because no driver exists which can supply a pointer to the surface. This is most likely to happen when attempting to lock the primary surface when no DCI provider is present. Will also happen on attempts to lock an optimized surface.
Severity code: Failed
Facility Code: FACILITY_D3D (2166)
Error Code: 0x01b3 (435)


I believe that you can't effectively lock the primary surface on modern drivers and Windows versions.


A workaround is to create a secondary frame buffer (or a back buffer), lock and manipulate it, and copy or flip it to the front buffer.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!