Jump to content
  • Advertisement
Sign in to follow this  
Mykre

[.net] [DirectX, c#] Drawing a 2d HUD on a 3d Device

This topic is 4917 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How would you go about drawing a 2d HUD on a 3D device. I have a basic system where I am drawing several Spheres and can now fly between them :) (only using simple d3d Graphics). Now I wish to put a HUD in the centre of the screen and some other 2d screens over the top.

Share this post


Link to post
Share on other sites
Advertisement
Mykre. Although I don't have a lot of experience with this, the best way I've heard (assuming Managed DirectX of course) is to draw your 3d world, and then switch the world projection to an Orthogonal projection and use transformed vertices to draw your hud (you could probably just do texture-mapped quads for your UI). I'm away from my development machine though so I can't give it a whirl. I hope this helps a little bit.

Share this post


Link to post
Share on other sites
Quote:
Original post by Mykre

How would you go about drawing a 2d HUD on a 3D device.

I have a basic system where I am drawing several Spheres and can now fly between them :) (only using simple d3d Graphics). Now I wish to put a HUD in the centre of the screen and some other 2d screens over the top.


You can save yourself a *heap* of time by making use of the uber Sprite class supplied in the Direct3D namespace. It's simple to use and is fast. Two thumbs up!


Sprite S = new Sprite(device);

// In render loop (inside of device.BeginScene())
S.Begin();
S.Draw( ... ) // See intellisense for arguments :P
S.End();

Share this post


Link to post
Share on other sites
Thanks...

So we can draw 2d sprites on top of 3d rendered images, just like we would if the complete app was in 2d..?

I have done some basic 2d apps using this method, but thought the camera and view ports might stuff up the d3d drawings. I will give it a go.

Share this post


Link to post
Share on other sites
Quote:
Original post by Mykre
Thanks...

So we can draw 2d sprites on top of 3d rendered images, just like we would if the complete app was in 2d..?


The sprite drawing is independant of the 3d scene transformations going on, so you're covered. :)

Share this post


Link to post
Share on other sites
Hi Mykre,

Just to clarify a little. A 2D sprite is just 2 triangles forming a quad and drawn directly to screen coordinates. So, you are still rendering 3D but faking a 2D.

I dont know if you are using C++ or C# but if you are still learning, stick with the Sprite classes (C#) or the D3DXSprite function (C++) unless you find that they don't cover your requirements.

Luck!
Guimo

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!