Jump to content
  • Advertisement
Sign in to follow this  
AtsusaKai

Help on Fullscreen

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

Hi, i'm new to directx(game) programming, and i am having problems with the fullscreen mode. On execution the app will go to fullscreen just fine, but when i try to change to another window, therefore minimizing or (alt+tab)ing the app, error occurs when I go back. It says something about a problem on the device reset, that i wasn't able to handle it when the device was lost. I hope you can help me or pinpoint me to topics that solve this problem. I'm using Microsoft Visual C++ 2005. Thanks a lot!

Share this post


Link to post
Share on other sites
Advertisement
Check out Direct3DDevice9::TestCooperativeLevel.
Call that in the main Render() function before you do any rendering.

Basically, when you switch to another app, your app loses the device (D3DERR_DEVICELOST). When this happens, you should release all D3DPOOL_DEFAULT resources that you have such as textures, vertex buffers and effects. The latter has the OnDeviceLost() function for you to call.

When you switch back to your app, you'll get D3DERR_DEVICENOTRESET, so you need to call IDirect3DDevice9::Reset to re-initialize the full-screen graphics mode, and then re-create the resources that you released when you lost the device.

It's important that you release all default-pool resources when you lose the device, otherwise the Reset() will fail.

Share this post


Link to post
Share on other sites
man..

That problem is horrible. It really sucks too because you can't really find answer anywhere about it. I'm new to games myself and I ran into this a couple of weeks back.

The short answer:

Your message pump needs to handle the alt+tab properly. The issue is not limited to full screen. It probably happens on window mode but you haven't noticed the full range of it's error.

The long answer:

WARNING: This code is not elegant, and more than is wrong on several levels. But it gets the job done, and solved the issue for me. Also, it doesn't handle ID3DXFont which needs to be release and recovered during alt+tabs if you're using it (i haven't implemented those recoveries yet). I'm also not doing the cooperative level test that it's mentioned above.

Here is the threat that i had with the same question: http://www.gamedev.net/community/forums/topic.asp?topic_id=499378&whichpage=1�



[source language=cpp]
LRESULT WINAPI WinProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{

case WM_CREATE:
break;

case WM_DESTROY:
//release the Direct3D objects
if (d3ddev != NULL) d3ddev->Release();
if (d3d != NULL) d3d->Release();

//release sound objects (this is a class not a DX object)
if (dsound != NULL) delete dsound;

//release input objects
if (dinput != NULL) dinput->Release();
Kill_Keyboard();
Kill_Mouse();

//call the "front-end" shutdown function
Game_End(hWnd);

//tell Windows to kill this program
PostQuitMessage(0);
return 0;

case WM_KILLFOCUS:
InvalidateRect (hWnd, NULL, true) ;
return 0;

case WM_SETFOCUS:

if(d3ddev != 0)
{
//acquire the keyboard
HRESULT result = dikeyboard->Acquire();
if (result != DI_OK)
{
MessageBox(hWnd, "Error recovering the Keyboard", "Error", MB_OK);
return 0;
}

result = dimouse->Acquire();
if (result != DI_OK)
{
MessageBox(hWnd, "Error recovering the Mouse", "Error", MB_OK);
return 0;

}
}
return 0;
break;


case WM_CLOSE:
// confirm quit
if (MessageBox(hWnd, "Are you sure you want to quit?",
"Quit the game", MB_YESNO | MB_ICONQUESTION |
MB_DEFBUTTON2) == IDYES)
return(DefWindowProc(hWnd, msg, wParam, lParam));
else
return(0);
break;
}
return DefWindowProc( hWnd, msg, wParam, lParam );
}




I hope this helps even if just a little.

I'd love to have a partner to learn all this with, so if you're interested in maybe doing some collaborative learning let me know!

Share this post


Link to post
Share on other sites
Quote:
Original post by Mike nl
Check out Direct3DDevice9::TestCooperativeLevel.
Call that in the main Render() function before you do any rendering.

Basically, when you switch to another app, your app loses the device (D3DERR_DEVICELOST). When this happens, you should release all D3DPOOL_DEFAULT resources that you have such as textures, vertex buffers and effects. The latter has the OnDeviceLost() function for you to call.

When you switch back to your app, you'll get D3DERR_DEVICENOTRESET, so you need to call IDirect3DDevice9::Reset to re-initialize the full-screen graphics mode, and then re-create the resources that you released when you lost the device.

It's important that you release all default-pool resources when you lose the device, otherwise the Reset() will fail.


Thanks I will try that! C# or C++, I had the same problem regarding fullscreen.

Share this post


Link to post
Share on other sites
Quote:
Original post by roloenusa
man..

That problem is horrible. It really sucks too because you can't really find answer anywhere about it. I'm new to games myself and I ran into this a couple of weeks back.

The short answer:

Your message pump needs to handle the alt+tab properly. The issue is not limited to full screen. It probably happens on window mode but you haven't noticed the full range of it's error.

The long answer:

WARNING: This code is not elegant, and more than is wrong on several levels. But it gets the job done, and solved the issue for me. Also, it doesn't handle ID3DXFont which needs to be release and recovered during alt+tabs if you're using it (i haven't implemented those recoveries yet). I'm also not doing the cooperative level test that it's mentioned above.

Here is the threat that i had with the same question: http://www.gamedev.net/community/forums/topic.asp?topic_id=499378&whichpage=1



*** Source Snippet Removed ***

I hope this helps even if just a little.

I'd love to have a partner to learn all this with, so if you're interested in maybe doing some collaborative learning let me know!


Thanks man, it sure sucked! That made me stuck to window mode, i haven't figured and learned the solution out yet!

The first time I tried dx programming was on Managed code, C#. Which I had the same problem with fullscreen. Then I transfered to C++ just recently (before that, I studied the tutorial at directxtutorial.com, the dxsdk and some other win32 programming).

So what I did was just create a window and the d3d device, set it to fullscreen and then test it. And there it was, the same error. I really didn't use any other devices or so yet, all i rendered was the background. It's kinda frustrating having to render a game, 2D or 3D on window mode. But I;m gonna have to stick with it though, while the solution isn't out.

Your code gave me good ideas, i was also thinking about the reacquiring of devices last time.

And about the partner thing, that's a good idea, i just hope i'd be of help too. In any case here's my email: kai.zard@yahoo.com

If any comes up, I'd ping you for sure!

Thanks!

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!