[.net] [DirectX, c#] Drawing a 2d HUD on a 3d Device
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.
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.
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 :PS.End();
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.
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.
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. :)
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement