XNA Bloom Sample - Blank purple screen
I have placed the two bloom classes into my project from the Bloom sample and followed the same steps as the sample, although when I start the project, all I am getting now is a blank purple screen?
I'm not getting an error or anything, All I did was literally include the two bloom classes from the sample, added it as a component and placed the begin draw call in my main draw function just like in the sample. I have other render targets in my project but they're not necessarily being used right away. If I take out the bloom stuff everything is as normal. As soon as I call the begindraw() function, all I get is the infamous blank purple screen...
Does anyone have an idea开发者_如何学运维 why I am getting this?
- Jamie.
The best way to diagnose this kind of problem is to use PIX (in the DirectX SDK).
The purple colour indicates that the render target contents have been cleared by the framework. This blog post explains why and offers some solutions.
Put simply, you cannot draw stuff to the back-buffer, switch to a render target, and then switch to the back-buffer again and expect what was drawn to still be there. At least not on the XBox 360 - and the PC version of the XNA framework emulates this behaviour.
If you'd like to be able to switch back to the back-buffer and have it unscathed, you can change the RenderTargetUsage
setting for the back-buffer (or render target, depending on how you're rendering) to PreserveContents
, as explained in that blog post. Be aware that on the Xbox 360 this is a huge performance hit.
A possibly better and more compatable method would be to adjust the order of your drawing so you never have to "return" to a surface.
(Link to a similar, recent question/answer.)
精彩评论