ID3DXSprite updates in the summer SDK...

Started by
6 comments, last by Toolmaker 19 years, 6 months ago
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

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 blendinggSprite->Begin(D3DXSPRITE_ALPHABLEND);// Draw the backdropD3DXMATRIX 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, translationD3DXMatrixTransformation2(&mat,NULL,0.0,&scaling,&spriteCentre,0.0f,&pos);// Tell the sprite about the matrixgSprite->SetTransform(&mat);// Draw the sprite gSprite->Draw(gTextureBackdrop,NULL,NULL,NULL,0xFFFFFFFF);	// Reset transformD3DXMatrixIdentity(&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 spritegSprite->End();
------------------------See my games programming site at: www.toymaker.info
Shouldn't you be using D3DXVector3 in the draw call?

Well, thank you, I'll test the code out later today!

Toolmaker

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
------------------------See my games programming site at: www.toymaker.info
OK, I have updated my sprites page on my site for Summer Update 2004: http://www.toymaker.info/Games/html/sprites.html
------------------------See my games programming site at: www.toymaker.info
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!

Languages; C, Java. Platforms: Android, Oculus Go, ZX Spectrum, Megadrive.

Website: Mega-Gen Garage

Yeh, just with sprites there are many games possible! All you need is to handle per pixel collision detection and you are away :)
------------------------See my games programming site at: www.toymaker.info
Quote:Original post by Trip99
OK, I have updated my sprites page on my site for Summer Update 2004: http://www.toymaker.info/Games/html/sprites.html


I love you man! I was kinda confused by the parameters of the Draw function, but you explained them nicely! Thanks.

EDIT: Rating++ for the help!
Toolmaker

This topic is closed to new replies.

Advertisement