Sprite drawing priority

Started by
3 comments, last by Supernat02 18 years, 11 months ago
I have an array of textures 0-5. it just happens that the last one is my background, so i set that to be at Z=1 and everything else i want to be infront of the background at Z=0. the array is drawn in order but for some reason, only the background is showing up...
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Advertisement
forgot to mention, i have an ortho projection with a min of 0 and a max of 5. (but also for some reason, when i put the background at anything greater than 1 like 3 or something, it doesn't show up at all...)
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Did you set up a z buffer?
First off sprites are drawn in screen space unless you specify otherwise (see sprte flags) so the projection is probably not doing anything. If you are not using a z-buffer things will appear in the order that they are drawn regardless of z-position so drawing your background last will cover up everything else you have drawn. Sprite will sort the textures for you either front-to-back or back-to-front. If you are using alpha you usualy want to turn off the z buffer and sort back-to-front, if you are not using alpha you usualy want to turn the z buffer on and sort front-to-back.
You're drawing in order from back to front, i.e. background first? If you're using the ID3DXSprite, it doesn't matter what your z value is unless you pass D3DXSPRITE_SORT_DEPTH_FRONTTOBACK in as the parameter to the Begin function. Otherwise, you will need to draw them in the proper order (background first).

EDIT: Doh, turnpast beat me to it. :)
Chris ByersMicrosoft DirectX MVP - 2005

This topic is closed to new replies.

Advertisement