SOLVED - XNA - DrawableGameComponent questions

Started by
5 comments, last by diginerd 14 years, 2 months ago
I'm working on a game for school and I'm currently trying to add a point sprite based particle system. I created the particle system and derived it from DrawableGameComponent, and when I went to draw the particles, they were drawing over everything in my scene, even my hud stuff which is drawn last. My question is, how can I control when my particles are drawn if they derive from DrawableGameComponent? If I understand correctly, DrawableGameComponent automatically does updating and drawing for you. So when does this updating and drawing happen? I tried not deriving from DrawableGameComponent and instead used my graphics engine's GraphicDevice to draw the particles, but they wouldn't draw at all. Any ideas? Thanks. Diginerd [Edited by - diginerd on February 7, 2010 11:41:01 AM]
Advertisement
Quote:I tried not deriving from DrawableGameComponent and instead used my graphics engine's GraphicDevice to draw the particles, but they wouldn't draw at all.


Did you call this particle drawing code from your game's Draw()?
Yep, I sure did and nothing. Obviously my update/Render code is correct or it wouldn't have drawn, even deriving from DrawableGameComponent, so I have no idea.
Ok, so I got them rendering. I wasn't using the correct GraphicsDevice. The problem I'm having now is that they're still drawing on top of my scenery (not drawing over HUD anymore). The depth buffer is on for comparing and it's off for writing. Am I missing some other renderstate?
I was being dumb. My post-processing pass was covering it up because the particles aren't drawn into the render target I use in post-processing. I have a new problem. When in my render loop should I handle particles? For example, I have an outline post-process effect and I obviously don't want the particles getting outlined, but I can't draw the particles after the post-process because then I can't do depth testing and they'll always draw on top. Any ideas?
Why won't you be able to do depth testing after the post process? Does your post process (need to) write to the depth buffer? If not, it should still be intact and usable after the post process.
I didn't even think about that, Hinch. That worked perfectly! Thanks for the suggestion.!

This topic is closed to new replies.

Advertisement