Jump to content
  • Advertisement
Sign in to follow this  

D3DSurfaces and Reset/Lost device.[SOLVED]

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

Hey all, I'm having a hell of a time dealing with Reset/Lost device in a post process effect I've been working on. I thought I was releasing and re-creating surfaces properly, but I guess not. DirectX debug libraries is telling me I'm leaking memory and going from Window mode to Fullscreen results in a crash(lock up). I've had windowed to fullscreen working flawlessly until I added this new effect so I know the problem lies here. Anyway, here is the surfaces I'm working with.
        LPDIRECT3DSURFACE9     m_Surface, m_OldBackBuffer;
        LPDIRECT3DTEXTURE9     m_SceneTexture;

Pretty simple. One surface for rendering, the other to hold the previous back buffer. Texture is the fully rendered scene. On Lost Device:
    // Release the target surface
    // Release the original back buffer
    // Release the scene texture;

On Reset Device:
    // Create the texture to write to.
    m_pDevice->CreateTexture(640, 480, 0, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_SceneTexture, NULL);

    // Grab the surface level of the texture.
    m_SceneTexture->GetSurfaceLevel(0, &m_Surface);

The OldBackBuffer variable is released every frame:
    // Begin Scene
    m_pDevice->GetRenderTarget(0, &m_OldBackBuffer);

    m_pDevice->SetRenderTarget( 0, m_Surface);


    // End Scene, restore old back buffer.
    m_pDevice->SetRenderTarget(0, m_OldBackBuffer );


It's a fairly simple class so I'm really stumped as to how I am now dealing with Reset/Lost device properly. EDIT: My problem was that Reset device is called before a scene begins and my resources were being created twice. I removed my resource creation code from my constructor and all seems to be well now. [Edited by - ChaosPhoenix on May 8, 2007 11:49:03 AM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!