# 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.

## 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 on other sites
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 on other sites
Quote:
 Original post by sirobI'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!

1. 1
Rutin
26
2. 2
3. 3
4. 4
5. 5

• 9
• 11
• 10
• 13
• 20
• ### Forum Statistics

• Total Topics
632948
• Total Posts
3009389
• ### Who's Online (See full list)

There are no registered users currently online

×