Jump to content
  • Advertisement
Sign in to follow this  
Xandev

ID3DXSprite and DrawPrimitive

This topic is 2134 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, 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
Advertisement
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.

d3ddevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);

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.

d3ddevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);


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);
}


Still not working. Edited by Xandev

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!