0

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.
skaffman
  • 398,947
  • 96
  • 818
  • 769
Jamie
  • 683
  • 2
  • 11
  • 16
  • Can you post some code? It will make it a lot easier to assist you. Also, are you using `DrawableGameComponents`/`GameComponents` in your project? – Neil Knight Feb 23 '11 at 13:38

1 Answers1

1

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.)

Community
  • 1
  • 1
Andrew Russell
  • 26,924
  • 7
  • 58
  • 104
  • I'm not getting the purple anymore, i'm getting the colour you clear to before drawing - in this case cyan - which means nothing is actually being drawn on screen right ? – Jamie Feb 23 '11 at 13:53
  • @Jamie: I cannot remember what the clear colour is if you simply never draw anything (I think it might also be purple). You don't mean the default `CornflowerBlue` from the XNA template, do you? – Andrew Russell Feb 23 '11 at 13:57
  • yeah sorry I meant the cornflower blue line although I set it to Cyan in this case. – Jamie Feb 23 '11 at 13:59
  • Thank you very much for you help, I have managed to fix it using your help :) – Jamie Feb 23 '11 at 14:05
  • 2
    @Jamie: If Andrew's answer fixed the problem you should accept it and upvote it. – Jackson Pope Feb 23 '11 at 14:23