Sign in to follow this  
soulsfish

Problem -- UpdateSurface()

Recommended Posts

soulsfish    122
There is the code:

D3DXIMAGE_INFO Info;
	if(FAILED(D3DXGetImageInfoFromFile(szFileName, &Info))){
		return E_FAIL;
	}
	if(FAILED(m_pd3dDevice->CreateOffscreenPlainSurface(Info.Width, 
		Info.Height, Info.Format,
		D3DPOOL_SYSTEMMEM, &m_pSurface, 0))){
		return E_FAIL;
	}
	if(FAILED(D3DXLoadSurfaceFromFile(m_pSurface, 0, 0, szFileName, 0,
		D3DX_FILTER_NONE, 0xffff0000, &Info))){
		return E_FAIL;
	}	

	LPDIRECT3DSURFACE9 BackBuffer = NULL;
	if(FAILED(m_pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &BackBuffer))){
		return E_FAIL;
	}
	if(FAILED(m_pd3dDevice->UpdateSurface(m_pSurface, 0, BackBuffer, 0))){
		return E_FAIL;   // Terminate.
	}

	SAFE_RELEASE(BackBuffer);
	SAFE_RELEASE(m_pSurface);


I'm not sure which parameter is invalid.

Share this post


Link to post
Share on other sites
Dave Hunt    4872
From the SDK Docs:
Quote:
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.


If any of those conditions fails, the UpdateSurface call will fail.

Share this post


Link to post
Share on other sites
Agony    3452
StretchRect() does more or less the same thing that UpdateSurface() does (plus a little more), but it seems to have slighly different constraints. Maybe for some reason or another it might work even when UpdateSurface() does not. Might at least give it a try.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this