Advertisement Jump to content
Sign in to follow this  

Anyone know why I get an error when using GetDC on a backbuffer?

This topic is 4972 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 am getting an ERR_INVALIDCALL error when I call GetDC. I've tried with the endscene after the getdc call as well. Makes no difference. I'm still a beginner with directx so this error might be really obvious. Here is my code ... gD3dDevice->EndScene(); IDirect3DSurface9 *BackBuffer; gD3dDevice->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO,&BackBuffer); HDC hdc; BackBuffer->GetDC(&hdc); ... Any ideas what the problem is?

Share this post

Link to post
Share on other sites
From the SDK Docs:
The following restrictions apply.

IDirect3DSurface9::GetDC is valid on the following formats only: D3DFMT_R5G6B5, D3DFMT_X1R5G5B5, D3DFMT_R8G8B8, and D3DFMT_X8R8G8B8. Formats that contain Alpha are not supported because the Microsoft Windows Graphics Device Interface (GDI) implementations don't have a well-defined behavior on the alpha channel. For more information about formats, see D3DFORMAT.
Only one device context per surface can be returned at a time.
IDirect3DSurface9::GetDC will fail if the surface is already locked. If the surface is a member of a mipmap or cubemap, IDirect3DSurface9::GetDC fails if any other mipmap or cubemap member is locked.
IDirect3DSurface9::GetDC fails on render targets unless they were created lockable (or, in the case of back buffers, with the D3DPRESENTFLAG_LOCKABLE_BACKBUFFER flag).
For surfaces not created with IDirect3DDevice9::CreateOffscreenPlainSurface, IDirect3DSurface9::GetDC will fail on default pool (D3DPOOL_DEFAULT) surfaces unless they are dynamic (D3DUSAGE_DYNAMIC) or are lockable render targets.
IDirect3DSurface9::GetDC will fail on D3DPOOL_SCRATCH surfaces.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!