2D Sprite help

Started by
1 comment, last by smittix 19 years, 1 month ago
I have rendered a 2d sprite that takes up the entire screen with a hole in the middle where I want 3d stuff to show through. No matter how I rearrange the order though, the 3d objects always get drawn on top of the 2d sprite which is supposed to be the top layer no matter what. The 2d sprite is loaded with: D3DXCreateTextureFromFileEx( d3dDevice, Filename, 1152, 864, 1, D3DPOOL_DEFAULT, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DCOLOR_COLORVALUE(1.0f,1.0f,1.0f,1.0f), &d3dxImageInfo, NULL, &Texture ); and it is rendered last with : Sprite->Begin( D3DXSPRITE_ALPHABLEND ); Sprite->Draw( Texture, &srcRect, &vCenter, &vPosition, D3DCOLOR_COLORVALUE(1.0f,1.0f,1.0f,1.0f) ); Sprite->End(); Any help as to why 3d objects are always drawn on top would be very helpfull. -Chris
Advertisement
If you render your 3D objects first and then render the sprites, you should be able to do this. If you take a look at my game Epoch Star in the opening screen I draw several 3D objects. Then I just render the sprites after that (the buttons on the screen are sprites) and it draws them on top.

Here's a quick screen shot to show you what I'm talking about:




What kind of texture file are you using for your sprite? Did you enable alpha blending?
I was trying to draw the 3d objects first and the sprite second and it wasn't working for a while, but it is working now. Basically when rendering, it asks for an (x, y, z) position to place the sprite, Z being the depth. It was set to 1, which set it behind everything else. I just changed it to 0 and now it gets rendered on top of everything else.

-Chris

This topic is closed to new replies.

Advertisement