Skip to main content
GameDev.net gamedev.net
🔒 Locked

I can't get ID3DXSprite to work

Started by PSioNiC Apr 18, 2001 at 5:59 PM 1 replies 850+ views
Original Post
PSioNiC
PSioNiC
i know it sounds bad, but i can''t even get ID3DXSprite to work. My code is just simple: LPD3DXSPRITE *Sprite; D3DXCreateSprite(D3DDevice, Sprite); and not even that works. how am supposed to know if i am to use LPD3DXSPRITE or ID3DXSPRITE ? whats the difference? if somebody could give me some working test code it would be much apprieciated. thanks
"This is stupid. I can't believe this! Ok, this time, there really IS a bug in the compiler."... 20 mins pass ..."I'M AN IDIOT!!!"
Psychocatt
Psychocatt
What happens when you run it? Do you get an error message? You should be testing the return value to see what error message you get. From the SDK, it says it could be either an invalid call or out of memory. Test and see what value you get back and that will give you a starting point.

As far as the difference between using ID3DXSprite and LPD3DXSPRITE, there isn''t much difference. LPD3DXSPRITE is defined as being a pointer to ID3DXSprite, so this would be equal:

// This ...
ID3DXSprite *pSprite;
// Is the same as...
LPD3DXSPRITE pSprite;


The D3DXCreateSprite() function needs a pointer to a LPD3DXSPRITE, so you would need either:

ID3DXSprite *pSprite;
D3DCreateSprite(D3DDevice, &pSprite);
// Or this
LPD3DXSPRITE *pSprite;
D3DCreateSprite(D3DDevice, pSprite);


I may have missed somthing or mistyped something as Im kinda sleepy right now. If there is a problem, please let me know! Hope that helps!

zechis
zechis
That last one should be:
// Or this
LPD3DXSPRITE pSprite;
D3DCreateSprite(D3DDevice, &pSprite);

LPD3DXSPRITE is already a pointer so you don''t need the extra *.
But you still need to pass the pointer''s address to D3DCreateSprite, hence the added &.

As for the original poster, check the return value from D3DXCreateSprite like this:

HRESULT hr = D3DXCreateSprite( D3DDevice, &pSprite );
if( FAILED( hr ))
{
char szErrorMessage[256];
D3DXGetErrorString( hr, szErrorMessage, 256 );
MessageBox( NULL, szErrorMessage, "ERROR!", MB_OK );
}



Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.