Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Revalidating Devices

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

Hello, I''m using Direct 3d 8 to make a 2d engine and I am having a litte problem. When I alt-tab and then come back i loose the device or something because it doesn''t redraw the scene. I made this function to restore the device:
	    D3DDISPLAYMODE d3ddm;
     if( FAILED( dx8.pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT,
     &d3ddm )))
          return E_FAIL;

     // Parameters for the D3DDevice. Most parameters are zero''d out.

     // This sets the video format to match the current desktop display.

     // Check docs for other options you can set here, such as

     // ''Windowed'' which would create a window-based app (not full screen)

     ZeroMemory( &d3dpp, sizeof(d3dpp) );
     d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
     d3dpp.BackBufferWidth = 1024;
     d3dpp.BackBufferHeight = 768;
     d3dpp.BackBufferFormat = d3ddm.Format;

		return E_FAIL;		
It basically just sets the D3DPRESENT_PARAMETERS back to what they were and calls reset. Im not even sure if that is the right thing to do, is it? My main problem is i don''t know what messege i should be acting on to call this function. I tried WM_ACTIVATE but couldn''t get it to work. I''m pretty sure the RestoreDevices function itself works because i made it so when i press the space bar it calls the function. and when i Alt-tab out and back the screen doesn''t show up at first but when i press space it does. Any help would be appreciated. Thanks, Jake.

Share this post

Link to post
Share on other sites
I think WM_ACTIVATE should work, maybe the mechanism you used to try and trap this message didnt work? You probably don''t want to do the other things to try and catch tab outs. Another good lead here would be to look at the CD3DApplication class and see how the RestoreDeviceObjects function gets called. (Sorry I was a little too busy to look it up ). But I am pretty confident they handle WM_ACTIVATE message.

Homepage: http://students.washington.edu/andrey

Share this post

Link to post
Share on other sites
Ok i figgured out a solution.
I used the WM_ACTIVATEAPP message instead and for some reason that worked. Does anybody know if i need to restore anything other than the LPDIRECT3DDEVICE8? should I reset all the textures that are created as well?

Share this post

Link to post
Share on other sites

  • 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!