Sign in to follow this  
Kiristu

ID3DXSprite Draw freezes

Recommended Posts

Hi, I'm using the ID3DXSprite interface to draw some sprites in a 2D display. But, when drawing "too many" sprites, I got some texture artifacts, and somtimes the texture drawn is not the selected one. Then when I quit (or ALT+TAB) the application, Windows freezes and I got to reset the computer.

result = Globals::lpDirect3DDevice9->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
result = Globals::lpDirect3DDevice9->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );

result = Globals::dxSprite->Begin(D3DXSPRITE_ALPHABLEND || D3DXSPRITE_SORT_TEXTURE);

D3DXMatrixScaling(&scaleMat, sizeFact, sizeFact, 0);
for (int j = 0; j < nbSprites; j++)
{
    x = vertices[j].x;
    y = vertices[j].y;
    center = D3DXVECTOR3(x + size, y + size, 0);
    color = vertices[j].color;            
    result = Globals::dxSprite->SetTransform(
                                    D3DXMatrixMultiply(
                                        &transMat,
                                        &scaleMat,
                                        D3DXMatrixTranslation(&transMat, x, y, 0)
                                                      )
                                            );
    result = Globals::dxSprite->Draw(
		        textures[textureIndex],
		        NULL,
            		&center,
		        &D3DXVECTOR3(x, y, 0),
            		color);
    result = result;
}

Globals::dxSprite->SetTransform(D3DXMatrixIdentity(&identMat));
Globals::dxSprite->End();


If I comment the Draw call, it will "work" (no display but no freeze) whatever the number of sprites to draw is. With "too many" sprites (about 40) The program will run more or less correctly (artifacts and textures problems) until I quit, then Windows freezes. I tried to put a break point just after the main loop (that should be called before the program closes), and it is never called. But the most strange (I think this is really strange !), is that I can prevent the program to freeze the computer "simply" by setting a break point on the line :

result = result;


With that, whatever is the number of sprites I draw, the program will draw them, without any artefact, and will quit normally. I believe I have a bad video memory allocation somewhere but I don't know how to track it ... Configuration: Windows XP, Visual C++ 2005 Express, Athlon X264 4400+, GeForce 7900 GTX, 2Go RAM. Thanks for your help, K.

Share this post


Link to post
Share on other sites
Odd. :) Although I can't tell how much difference it'll actually make, you should probably change this tiny mistake:

dxSprite->Begin(D3DXSPRITE_ALPHABLEND || D3DXSPRITE_SORT_TEXTURE);

into this:

dxSprite->Begin(D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_TEXTURE);

Share this post


Link to post
Share on other sites
I tried to change it, but it still does not work, even if the behavior is not exactly the same. With one "|", I got noised textures, with "||" there are less ... but it keeps crashing my computer ...

Thanks,
K.


mmm ... in fact "||" is very different from "|", and my settings were incorrect from the beginning.
Even if this does not solve the problem, this is a point.

[Edited by - Kiristu on June 7, 2006 1:16:23 PM]

Share this post


Link to post
Share on other sites
Is the time between the Begin() and the End() important ?

Would it be possible to start the global loop with the Begin(), and to end it with the End() ? Or could it cause some trouble ?

If so, that could be the problem in my program ...

Thanks,
K.

Share this post


Link to post
Share on other sites
Is there a problem with drawing primitive (drawprimitive) between ID3DXSprite->Begin() and End() calls ?

I changed my configuration recently, from P4 2.66 + Radeon 9700 pro to Athlon 64 X2 4400+ + GeForce 7900 GTX, would it be possible something works correctlw with the first and not with the second ??
Is there any processor/graphic card optimizations that could be enabled ?

Thanks,
K.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this