Jump to content
  • Advertisement
Sign in to follow this  

Sprite Drawing (HUD)

This topic is 4413 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

Hi All, I'm relatively new to DirectX, so please excuse any striking stupidity on my part. I'm working on a simple 3D puzzle game with the basic code based largely around the Hazy Mind tutorials (http://www.thehazymind.com/3DEngine.htm). I have the 3D stuff working just fine...the problem is that I want to display some 2D buttons on the screen, sort of like a HUD, I guess. To do that, I'm attempting to use sprites, but can't seem to get them to actually draw on the screen. I have a simple GraphicsSprite class...
	public class GraphicsSprite
		private static readonly Vector3 Center = new Vector3(0,0,0);
		//instance data
		private Vector3 position;
		private float xUpdate = 1.4f;
		private float yUpdate = 1.4f;

		public GraphicsSprite(int posx, int posy)
			position = new Vector3(posx,posy,1);

		public void Draw(Sprite sprite, Texture t, Rectangle r)
And I have these variable set up:
	private Texture spriteTexture = null;
	private Sprite sprite = null;
	private Rectangle textureSize;
	private GraphicsSprite newSprite = new GraphicsSprite(0,0);
I load the texture and such:
	spriteTexture = TextureLoader.FromFile(device, "mainbuttons.png");

	using(Surface s = spriteTexture.GetSurfaceLevel(0))
		SurfaceDescription desc = s.Description;
		textureSize = new Rectangle(0,0,desc.Width,desc.Height);
	sprite = new Sprite(device);
And attempt to draw it just after the 3D scene has been rendered, and before my optional FPS display is shown:

I don't get any errors or anything, but I don't see any sprites, either. Everything else works fine. Any help is much appreciated. Thanks, Tom

Share this post

Link to post
Share on other sites
Correction! It is being drawn, but it's behind the 3D objects...I hadn't noticed that before, but moved the camera around, and there it was. How do I get the sprites to render in front of the 3D stuff? I'm calling it just before my call to device.EndScene() to no avail...


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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!