Sign in to follow this  

2D Sprite help

This topic is 4663 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

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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

This topic is 4663 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.

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