Sign in to follow this  
Xandev

ID3DXSprite and DrawPrimitive

Recommended Posts

Hi, i need to draw primitive between 2 sprites, but sprites rendered with ID3DXSprite are always on top. I tried to flush sprite interface before drawing primitive and after, but it doesn't work. I don't care if I have to use a vertex buffer or DrawPrimitiveUp function. Important for me is that it need to work. Thanks in advance for your help.

Share this post


Link to post
Share on other sites
Disable depth writing before drawing the sprites and reenable afterwards. The sprites will be drawn as normal, but their depth position won't be written to the z-buffer so everything else will draw over them.

[code]d3ddevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);[/code]

Share this post


Link to post
Share on other sites
[quote name='turch' timestamp='1347976440' post='4981251']
Disable depth writing before drawing the sprites and reenable afterwards. The sprites will be drawn as normal, but their depth position won't be written to the z-buffer so everything else will draw over them.

[code]d3ddevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);[/code]
[/quote]

[CODE]void XRendererDX9::DrawTexture(XTexture* Texture, float X, float Y, XRect<int> Rect)
{
if(!Texture || Texture->Color.Alpha <= 0)
return;
static RECT rect;
static D3DXVECTOR3 Position;
Position.x = X;
Position.y = Y;
Position.z = 0.0f;
rect.left = Rect.X;
rect.top = Rect.Y;
rect.right = Rect.X + Rect.Width;
rect.bottom = Rect.Y + Rect.Height;
Direct3D9Device->SetRenderState(D3DRS_ZWRITEENABLE, 0);
Direct3D9Sprite->Draw(static_cast<IDirect3DTexture9*>(Texture->Get()), &rect, 0, &Position,
D3DCOLOR_ARGB(Texture->Color.Alpha, Texture->Color.Red, Texture->Color.Green, Texture->Color.Blue));
Direct3D9Device->SetRenderState(D3DRS_ZWRITEENABLE, 1);
}[/CODE]

Still not working. Edited by Xandev

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this