Sign in to follow this  

Help with updating a surface to back buffer

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

see code below:

//after I create my D3Device, I get a pointer to the back buffer
m_pD3Device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &m_pSurfaceBack)

// I create an off screen Surface
m_pD3Device->CreateOffscreenPlainSurface(m_iWidth, m_iHeight,m_PresentParameters.BackBufferFormat,D3DPOOL_SYSTEMMEM,&m_pSurfaceLevel, NULL);

// I load a tga file to this surface
D3DXLoadSurfaceFromFile(m_pSurfaceLevel, NULL, NULL, "test.tga", NULL, D3DX_FILTER_NONE, 0, &pInfo)

//try to copy the tga surface to the back buffer but this fails!
m_pD3Device->UpdateSurface(m_pSurfaceLevel, NULL, m_pSurfaceBack, NULL)

the last stage fails, and I don't know why. Can anyone help?

Share this post


Link to post
Share on other sites
What does the debug spew say? What kind of failure are you getting? If you're using the Debug Runtime, you should be getting some kind of sentence in the debug spew stating why the function failed. If you're not sure what the Debug Runtime is, see the Forum FAQ.

neneboricua

Share this post


Link to post
Share on other sites
Quote:
DirectX Documentation on the UpdateSurface method
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.


Check to make sure all these restrictions are avoided. Hope it helps.

-AJ

Share this post


Link to post
Share on other sites
Quote:
Original post by neneboricua19
What does the debug spew say? What kind of failure are you getting? If you're using the Debug Runtime, you should be getting some kind of sentence in the debug spew stating why the function failed. If you're not sure what the Debug Runtime is, see the Forum FAQ.

neneboricua


I check the error code and I get D3DERR_INVALIDCALL. The documentation on UpdateSurface says:

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

I checked the following:
1. okay
2. I don't know. Is the backbuffer created using D3DPOOL_DEFAULT? how do I check or make it be created using D3DPOOL_DEFAULT?
3. okay
4. okay
5. okay
6. okay
7. okay
8. okay

Share this post


Link to post
Share on other sites
Quote:
Original post by mmakrzem
I check the error code and I get D3DERR_INVALIDCALL. The documentation on UpdateSurface says: [snip]

You still need to check the Debug Spew. The error code tells you that something messed up, but not exactly WHAT. The debug spew will tell you in plain english exactly why the function failed. As you can imagine, this is an invaluable tool when debugging DirectX applications.

If you're using Visual Studio, the debug spew is basically the output window. Any error messages generated by DirectX will show up there. For it to work, you have to be running the Debug Runtime. You can select this by going to Control Panel->DirectX->Direct3D and selecting the Debug Runtime radio button. This is all in the Forum FAQ.

Once you know WHY the function is failing, you'll have a much better idea as to how to fix it.

neneboricua

Share this post


Link to post
Share on other sites
I would love to turn the debug output on but unfortunately I don't know how!

I took a look into:
You can select this by going to Control Panel->DirectX->Direct3D and selecting the Debug Runtime radio button

but in my Control Panel I don't have a DirectX option!

I'm running WinXP SP2. I have DX9c(oct 2005)SDK installed

Share this post


Link to post
Share on other sites
Quote:
Original post by mmakrzem
I would love to turn the debug output on but unfortunately I don't know how!

I took a look into:
You can select this by going to Control Panel->DirectX->Direct3D and selecting the Debug Runtime radio button

but in my Control Panel I don't have a DirectX option!

I'm running WinXP SP2. I have DX9c(oct 2005)SDK installed

When you first install the SDK, you have the option of installing the Debug Runtime. Sometimes new users choose not to do this because they also use the same machine to play games as well as develop them and they think that installing the Debug Runtime will cause the games they play to run slower. This is NOT the case.

Installing the Debug Runtime also installs the DirectX Control Panel application. This application allows you to easily toggle between Debug and Release Runtimes; when you want to play a game, just hit the toggle. No reboot or anything is necessary

Since you don't have the DirectX application in your Control Panel, that means you never installed the Debug Runtime. So you need to uninstall the SDK, and reinstall it. But this time make sure you select to install the Debug Runtime.

After that, please, PLEASE, read the Forum FAQ... Especially the sections "What's the DirectX Control Panel for?" and "How do I debug a DirectX application?"

neneboricua

Share this post


Link to post
Share on other sites
Quote:
Original post by neneboricua19
After that, please, PLEASE, read the Forum FAQ... Especially the sections "What's the DirectX Control Panel for?" and "How do I debug a DirectX application?"

Just to make it easier, follow this link [smile]

Jack

Share this post


Link to post
Share on other sites

This topic is 4342 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.

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