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

Started by
1 comment, last by CodaKiller 15 years, 4 months ago
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);
			}



Remember Codeka is my alternate account, just remember that!
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.
Sirob Yes.» - status: Work-O-Rama.
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!
Remember Codeka is my alternate account, just remember that!

This topic is closed to new replies.

Advertisement