Jump to content
  • Advertisement
Sign in to follow this  
Toolmaker

ID3DXSprite updates in the summer SDK...

This topic is 5473 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 am currently following the Direct3D9 tutorial on 32bits.co.uk. However, the tutorial STILL isn't updated for the summer update and I am completely confused as D3D9 n00b. First of all: In the tutorial they seem to be using 1 ID3DXSprite interface per texture(or sprite object). Is the sprite interface suppose to be used like this or is it better to create a "global" variable and use that? Second: Do I need to call Begin()/End() on the sprite interface before calling Draw? Third: They changed the interface in the summer update, and it now completely works differently. Can anyone explain me how it works now? The documentation isn't making much sense, since I'm COMPLETELY confused. Toolmaker

Share this post


Link to post
Share on other sites
Advertisement
Hi, you are best to have just one interface, call begin, do all sprite drawing for that frame and then call end. This way D3D can batch better for best performance.

In the latest update you have to provide x,y,z positions. Here is an example from something I have written which displays a sprite as a backdrop and then some animated cavemen - it should help you figure it out:


// Draw our sprite with alpha blending
gSprite->Begin(D3DXSPRITE_ALPHABLEND);

// Draw the backdrop
D3DXMATRIX mat;
D3DXVECTOR2 pos=D3DXVECTOR2(120,0);
D3DXVECTOR2 scaling(4.0f,4.0f);
D3DXVECTOR2 spriteCentre=D3DXVECTOR2(64.0f,64.0f); // // Texture being used is 128 by 128:

// out, scaling centre, scaling rotation, scaling, rotation centre, rotation, translation
D3DXMatrixTransformation2(&mat,NULL,0.0,&scaling,&spriteCentre,0.0f,&pos);

// Tell the sprite about the matrix
gSprite->SetTransform(&mat);
// Draw the sprite
gSprite->Draw(gTextureBackdrop,NULL,NULL,NULL,0xFFFFFFFF);

// Reset transform
D3DXMatrixIdentity(&mat);
gSprite->SetTransform(&mat);



for (int i=0;i<NUM_CAVEMEN;i++)
{
// First one
RECT drawRect;

drawRect.left=gCavemen.frameNumber*64;
drawRect.right=drawRect.left+64;

drawRect.top=gCavemen.topPixel;
if (gCavemen.right)
drawRect.top+=64;
else
drawRect.top+=0;

drawRect.bottom=drawRect.top+64;

gSprite->Draw(gTexture,&drawRect,NULL,&gCavemen.pos,0xFFFFFFFF);

}

// Finished drawing our sprite
gSprite->End();


Share this post


Link to post
Share on other sites
In the draw call yes but in the call to D3DXMatrixTransformation2 it takes a vector 2. Only part of my code is there obviously but gCavemen.pos is a vector 3

Share this post


Link to post
Share on other sites
I was quite surprised at how easy it was to get the D3DXsprite pipeline up and running. A massive improvement over DirectDraw7.

There was talk that "tiling" was a no-go, but I think it was for a previous version of the SDK. When I tried my tiling, it linked together perfectly.

With this, I'm now planing my next masterpiece!

Share this post


Link to post
Share on other sites
Yeh, just with sprites there are many games possible! All you need is to handle per pixel collision detection and you are away :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!