Jump to content
  • Advertisement
Sign in to follow this  
AverageJoeSSU

[d3d9] GetSwapChain segfaults?

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

simple as that...

trying to copy contents of backbuffer to texture and getting this error when i get the swap chain from the device....

IDirect3DDevice9 *pd3dDevice = pCtx->Get3DDevice();

IDirect3DSwapChain9 **pSwapChain;
res = pd3dDevice->GetSwapChain(0, pSwapChain);

the hresult seems to return 0?

do i need to do something special before a nab the swapchain?

-Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Is there anything more you have to do for this to work?

Or any weird things worth noting?


I call UpdateSurface and then SAFE_RELEASE(surface); yet my texture seems to always be black.


IDirect3DTexture9* tex = pRes->GetTexture();

IDirect3DSurface9* pTmpSurf;
tex->GetSurfaceLevel( 0, &pTmpSurf );

RECT r = {bx,by,bw,bh};
// fprintf()


IDirect3DSurface9* swapSurface;
pSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &swapSurface);
res = pd3dDevice->UpdateSurface( swapSurface, &r, pTmpSurf, NULL );

SAFE_RELEASE( pTmpSurf );



Share this post


Link to post
Share on other sites
Be sure to read the documentation properly: http://msdn.microsoft.com/en-us/library/bb205857(VS.85).aspx

In particular:

This function has the following restrictions.

The source surface must have been created with D3DPOOL_SYSTEMMEM.
The destination surface must have been created with D3DPOOL_DEFAULT.
Neither surface can be locked or holding an outstanding device context.
Neither surface can be created with multisampling. The only valid flag for both surfaces is D3DMULTISAMPLE_NONE.
The surface format cannot be a depth stencil format.
The source and dest rects must fit within the surface.
No stretching or shrinking is allowed (the rects must be the same size).
The source format must match the dest format.
[/quote]

Also, you must release the swapSurface too, and use the SUCCEEDED or FAILED macros to check which if any calls fail.

You might want to look into StretchRect: http://msdn.microsoft.com/en-us/library/bb174471(VS.85).aspx
Or UpdateTexture: http://msdn.microsoft.com/en-us/library/bb205858(VS.85).aspx

What exactly are you trying to achieve?

Share this post


Link to post
Share on other sites
I need the destination color for my shader for correct blending, and cannot use regular blending because I need to deal with gamma correction. dry.gif

I was planning on doing this with an RTT backbuffer, but found that we use a surface config for our backbuffer for possible performance reasons.

I'll double check and make sure i meet the spec in the docs.......

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.

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

Sign me up!