Skip to main content
gamedev.net
🔒 Locked

Fullscreen Problems

Started by Jazonxyz 15 replies 2.7k views
Original Post
Jazonxyz
Jazonxyz
Whenever my program looses focus in fullscreen, nothing is rendered. I tried using LPDIRECT3DDEVICE9->Reset(&D3DPRESENT_PARAMETERS) but it doesn't work and my game is not rendered. How do I fix it?
Evil Steve
Evil Steve
Define "doesn't work". Does it crash? If so, with what error? Does Reset() fail?Do you release all D3DPOOL_DEFAULT resources before the reset and recreate them after? Do you call OnLostDevice() for all D3DX classes you create and call OnReset() after? Do you reset all your render states, streams, textures, materials, lights, matrices, etc after? Are you using the debug runtimes? Do they spit out any useful debug information? Have you tried resetting the device to go to/from windowed mode? Does that work?
Jazonxyz
Jazonxyz
Well the game does not crash, but the fullscreen is gone.
After loosing focus, all i see when i set focus is an empty window
and I don't get any messageboxes. And all I did was call Reset()
and thats it.
Evil Steve
Evil Steve
Quote:
Original post by Evil Steve
Define "doesn't work". Does it crash? If so, with what error? Does Reset() fail?Do you release all D3DPOOL_DEFAULT resources before the reset and recreate them after? Do you call OnLostDevice() for all D3DX classes you create and call OnReset() after? Do you reset all your render states, streams, textures, materials, lights, matrices, etc after? Are you using the debug runtimes? Do they spit out any useful debug information? Have you tried resetting the device to go to/from windowed mode? Does that work?

Jazonxyz
Jazonxyz
Reset Does Fail.
I made a D3DXSPRITE so that might be the problem.
and TestCooperativeLevel() prooved that the cause was D3DERR_DEVICE LOST
Evil Steve
Evil Steve
Quote:
Original post by Jazonxyz
Reset Does Fail.
I made a D3DXSPRITE so that might be the problem.
and TestCooperativeLevel() prooved that the cause was D3DERR_DEVICE LOST
What error does it return? If you have an ID3DXSprite, you need to call ID3DXSprite::OnLostDevice() before resetting the device, and then ID3DXSprite::OnResetDevice() after.
Jazonxyz
Jazonxyz
This is what I just did.


switch(D3DDevice->TestCooperativeLevel()) (D3DDevice is LPDIRECT3DDEVICE);
{
case D3DERR_DEVICENOTRESET:
SpriteHandler->OnLostDevice(); (SpriteHandler is D3DXSPRITE);
D3DDevice->Reset(&d3dpp);
SpriteHandler->OnResetDevice();
break;

case D3DERR_DEVICELOST:
SpriteHandler->OnLostDevice();
D3DDevice->Reset(&d3dpp);
SpriteHandler->OnResetDevice();
break;

and it did not work.
I am not getting any messages or error codes
Evil Steve
Evil Steve
Quote:
Original post by Evil Steve
Define "doesn't work". Does it crash? If so, with what error? Does Reset() fail? Do you release all D3DPOOL_DEFAULT resources before the reset and recreate them after? Do you call OnLostDevice() for all D3DX classes you create and call OnReset() after? Do you reset all your render states, streams, textures, materials, lights, matrices, etc after? Are you using the debug runtimes? Do they spit out any useful debug information? Have you tried resetting the device to go to/from windowed mode? Does that work?


Quote:
Original post by Evil Steve
What error does it return?


Also, although it's unrelated here, it's usually a bad idea to switch() on HRESULT error codes. You're only checking 2 of the 2 billion possible error codes. Also, the SDK docs don't cover all error codes. You should check the return value with FAILED() or SUCCEEDED)(, and then switch if it failed, and be sure to have a default case.
Jazonxyz
Jazonxyz
I dont know how to releae all D3DPOOL_DEFAULT resources and recreate them
What render state?
I have textures but I dont know how to reset them.
I am using debug runtimes
I dont get much debug information
I haven't tried resetting the device to go to/from windowed mode.
Evil Steve
Evil Steve
Quote:
Original post by Jazonxyz
I dont know how to releae all D3DPOOL_DEFAULT resources and recreate them
What render state?
I have textures but I dont know how to reset them.
I am using debug runtimes
I dont get much debug information
I haven't tried resetting the device to go to/from windowed mode.
If you create any resources like vertex buffers, textures, render targets, etc in D3DPOOL_DEFAULT, then you need to destroy them and then re-create them after the reset, because they exist in video memory and when you reset the device, you wipe all video memory. Resources in D3DPOOL_MANAGED are ok, D3D will take care of them for you.

When Reset() succeeds, the device is in the same state as it was just after creating it. That means you need to set all of your renderstates (IDirect3DDevice9::SetRenderState()), textures (IDirect3DDevice9::SetTexture()), matrices (IDirect3DDevice9::SetTransform() - unless you're using shaders), etc.

If any D3D function fails and you're using the debug runtimes, D3D will spit out information i nthe debug output window, something like "(D3D) ERROR: Must release all D3DPOOL_DEFAULT resources before resetting device. Reset fails with D3DERR_INVALIDCALL." (Or something similar).
Jazonxyz
Jazonxyz
OK so I must release the things and reload them?
(I am only using textures and surfaces for a 2D game)
Evil Steve
Evil Steve
Quote:
Original post by Jazonxyz
OK so I must release the things and reload them?
(I am only using textures and surfaces for a 2D game)
If any of your textures or surfaces are in the default pool (Not system memory, managed or scratch pools), then yes.
Jazonxyz
Jazonxyz
I tried releasing them before D3DDevice->Reset() and Loading them afterwards
but it didn't work.

I still can't go back to fullscreen.
Evil Steve
Evil Steve
Quote:
Original post by Jazonxyz
I tried releasing them before D3DDevice->Reset() and Loading them afterwards
but it didn't work.

I still can't go back to fullscreen.
The debug runtimes (I see you're looking for how to enable them in your Other Thread) will tell you what the problem is in the debug output - it's not nessecarily that you haven't reset something.
Jazonxyz
Jazonxyz
So how do I fix the problem???
Jazonxyz
Jazonxyz
FIXED FIXED FIXED
FIXED FIXED
FIXED FIXED FIXED
FIXED FIXED
FIXED FIXED
Jazonxyz
Jazonxyz
Thanks Evil Steve! Thank You!

I forgot to release the BackBuffer which in this case was a LPDIRECT3DSURFACE

thanks!!!!!!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.