I have a Direct3D 9 application that is able to switch between windowed mode and full-screen mode. When toggling between these 2 modes using the Direct3D 9 debug runtime, I sometimes see the screen fill with a random color - usually a bright green, or a bright pink. This usually happens when going from full-screen mode back to windowed mode. Is this an indication that there's something wrong with my application, or is this just a debugging aid?
Stupid Direct3D 9 Question
This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.
-
-
My first guess is that the display buffer isn't cleared to black before it is presented. DirectX9 doesn't do anything but allocate video memory when you create a surface - so clearing it to a specific color is your responsibility.
Anyone else have any bright ideas???Mr.Mike
Author, Programmer, Brewer, Patriot -
that would make sence, that if it isn't defined, it would contain a random number many times.
But i would be the wrong person to ask about that, i have very little experiance with DirectX.Wort wort wort. -
I am clearing the frame buffer to black.
Looking at the debug spew from the debugging console it says something about a GetClientRect() failure, and a warning saying something about not being able to create a driver index buffer.
Any ideas? -
I think I have solved the problem.
According to the DirectX 9 SDK docs:
D3DSWAPEFFECT_DISCARD will be enforced in the debug runtime by filling any buffer with noise after it is presented.
Sure enough when I explicitly set the SwapEffect member of the D3DPRESENT_PARAMETERS structure to D3DSWAPEFFECT_COPY for windowed mode and D3DSWAPEFFECT_FLIP for full-screen mode I no longer saw any random colors filling the screen. -
Thats good to know, atleast it makes sence.Wort wort wort.
-
The Debug runtime fills the back buffer with either a flash green or flash pink color after every present call. It wont happen in the final build (well it shouldnt). It's just there so that you can easily tell when you are having back buffer clearing/flipping problems. I would assume it would happen because:
Right before you switch from fluuscreen to windowed, you have a final call to pDevice->Present() and pDevice->EndScene(). After these calls D3D will fill the back buffer with either pink or green. Now the application will probably switch modes at this point before going in to the game loop again. Therefore you wont be calling clear until after you are safely in windowed mode and back in teh game loop. I would assume clearing the screen right after calling Present()/EndScene() might help. -
Ah - this brings up a great point to remember, and lots of programmers (including myself) forget to run their app under both DirectX runtimes (debug and release).
Think of how hard that would have been to notice without the debug runtime flashing colors at you...Mr.Mike
Author, Programmer, Brewer, Patriot
-
Share
- Facebook 0
- Twitter 0
- Google Plus 0
- Reddit 0