I\'m experimenting with trying to get 2D sprites to be drawn BEHIND 3D objects. I have no problem getting 2D sprites to draw over 3D objects but I want the reverse. In the sample program below, I display a 3d object in the middle of the screen (a .X file) and an animated 2D sprite of a walking bear at the bottom of the screen. The two objects in this sample don\'t actually overlap at all so in theory both objects should be visible regardless of the order in which they are drawn. Both objects are visible if I use dbDrawSpritesLast(). But, when I use the call to dbDrawSpritesFirst(), the 2D sprite does not get drawn at all. What am I doing wrong or not understanding?
#include \"DarkGDK.h\"
int ScreenWidth = 1360;
int ScreenHeight = 768;
int ipBearWalkRight = 1;
int ipCoin = 2;
int BearX = 10;
int BearY = 500;
void DarkGDK ( void )
{
dbSetWindowOff();
dbSetDisplayMode (ScreenWidth,ScreenHeight,32);
// Load 2D Bear Sprite
dbCreateAnimatedSprite(ipBearWalkRight,\"bearwalkright.bmp\", 3, 3, ipBearWalkRight );
// Set sprites vs. 3D display order
dbDrawSpritesLast(); // <-- If I use dbDrawSpritesFirst() here, my sprite does not get drawn at all
dbSyncOn ( );
dbSyncRate ( 60 );
dbRandomize ( dbTimer ( ) );
// Load and prep 3D Coin object
dbLoadObject(\"coin.x\",ipCoin);
dbColorObject ( ipCoin, dbRgb ( 255,214,56 ) );
dbSetObjectSpecularPower ( ipCoin, 255 );
dbSetObjectAmbient ( ipCoin, 0 );
while ( LoopGDK ( ) )
{
// display some text on screen
dbText ( 0, 0, \"Use the up and down arrow keys to move the camera\" );
dbPlaySprite(ipBearWalkRight,1,8,60);
dbSprite(ipBearWalkRight,BearX,BearY,ipBearWalkRight);
BearX = BearX + 3;
if (BearX > ScreenWidth) {BearX = 1;}
// move the camera forwards
if ( dbUpKey ( ) )
dbMoveCamera ( 1 );
// move the camera backwards
if ( dbDownKey ( ) )
dbMoveCamera ( -1 );
// spin coin around
dbRotateObject ( ipCoin, dbObjectAngleX ( ipCoin ) + 0.1, dbObjectAngleY ( ipCoin ) + 0.2, dbObjectAngleZ ( ipCoin ) + 0.3 );
// here we make a call to update the contents of the screen
dbSync ( );
}
dbDeleteObject ( ipCoin );
dbDeleteSprite ( ipBearWalkRight );
return;
}