Jump to content
  • Advertisement
Sign in to follow this  
CodaKiller

I have a little problem with the DirectX 10 sprite interface.

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

This is how my game engine works, the engine runs a default lua script in which I create a window and lock a render target on a reign of the window. Then I create a scene object and add a camera to it, I pass the camera to the view of the render target object. Now I add interface objects to the renter target and this is where my problem begins, I have 2 types of interface objects that can be created. One is a text object and the other is a sprite object, I have to draw the objects in the order they are put in to the list. When I draw a text object before I draw a sprite the sprite is not drawn but if I use SetProjectionTransform before drawing the sprite then it works but the text is always on top. Here is a small code sample to show the drawing stage:
			if(Interfaces->sprite)
			{
				g_Sprite->DrawSpritesImmediate( Interfaces->sprite, 1, 0, 0 );
			}
			else
			{
				Interfaces->font->DrawTextA( g_Sprite, Interfaces->text.c_str(), -1, &Interfaces->rect, DT_LEFT | DT_WORDBREAK, Interfaces->color);
			}



Share this post


Link to post
Share on other sites
Advertisement
I'm not sure if this is exactly what you're after, but due to Z-Buffering, text rendered with a Font object should always appear on top. I assume that's by-design.

As for the sprite not appearing if rendered after the font, rendering text is likely changing the settings on the sprite. I'd recommend you use two Sprite objects, one for drawing your sprites, and one for drawing text. Otherwise, keeping track of which settings the Font object changes each time you draw text might be complicated.

Finally, if you do use 2 sprite objects, you'll be able to control the order in which they are rendered. This will only matter if Z-Buffering is disabled, but if you do this, you'll be able to easily control what appears above what, text or sprites.

Hope this helps.

Share this post


Link to post
Share on other sites
Quote:
Original post by sirob
I'm not sure if this is exactly what you're after, but due to Z-Buffering, text rendered with a Font object should always appear on top. I assume that's by-design.

As for the sprite not appearing if rendered after the font, rendering text is likely changing the settings on the sprite. I'd recommend you use two Sprite objects, one for drawing your sprites, and one for drawing text. Otherwise, keeping track of which settings the Font object changes each time you draw text might be complicated.

Finally, if you do use 2 sprite objects, you'll be able to control the order in which they are rendered. This will only matter if Z-Buffering is disabled, but if you do this, you'll be able to easily control what appears above what, text or sprites.

Hope this helps.


Yes that very much helped! Thank you!

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!