Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 17 Sep 2012
Offline Last Active Oct 25 2012 01:26 PM

Posts I've Made

In Topic: ID3DXSprite and DrawPrimitive

18 September 2012 - 08:12 AM

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