Sign in to follow this  
diginerd

SOLVED - XNA - DrawableGameComponent questions

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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()?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this