• Advertisement
Sign in to follow this  

Problem -- UpdateSurface()

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

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
Advertisement
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
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
I would suspect that the problem is that the backbuffer format and the texture format are not the same.

Share this post


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

  • Advertisement