VERY strange: D3DXSprite::Draw glitches on XP, not on Vista

Recommended Posts

Hi, I have no idea why, but my sprite's animation is wrong on every machine with xp, I have tried. My original developing machine (with vista) displays it just fine. I have checked the calculated values of srcTex in the debugger, and they are always correct. Even more confusing is, that the player sprite animation, which is layed down vertically, works fine aswell - on all OS and PCs. Try the game out and press enter to fire a rocket. The resulting explosion will make the error apparent. (the d3dx library needs to be installed for the game to start) http://dl.getdropbox.com/u/700060/Setup.exe This is the function:
void SpriteObject::renderAnimated2(int animPhase)
{
srcTex.left = (animPhase % this->frameseX) * frameWidth;
srcTex.right = srcTex.left + frameWidth;
srcTex.top = (animPhase % this->frameseY) * frameHeight;
srcTex.bottom = srcTex.top + frameHeight;

D3DXMATRIX matrix;
D3DXMatrixTranslation(&matrix,posOnScreen.x,posOnScreen.y,0);
d3dManager.d3dspt->SetTransform(&matrix);
d3dManager.d3dspt->Draw(texture,&(this->srcTex),NULL,NULL,D3DCOLOR_ARGB(255,255,255,255));
D3DXMatrixIdentity(&matrix);
d3dManager.d3dspt->SetTransform(&matrix);
}


Share on other sites
Are the dimensions of your sprite texture powers of two? (The actual image file, not the individual sprites.)

Share on other sites
No, but that should not matter, because I set the width and height of CreateTextureFromFileEx to D3DX_DEFAULT_NONPOW2.And it works on Vista... I even use the same DirectX SDK on the XP machines. I tried it anyway and changed the glitching .png to a power of two. Didnt change a thing!

Share on other sites
Well, for future reference, specifying D3DX_DEFAULT_NONPOW2 doesn't guarantee that you won't get stretched images. That only works if the video card you're running on supports it. If it doesn't, you'll get stretching anyway.

At any rate, what is different about the machines you are running on besides XP vs Vista?

Share on other sites
Oh I didnt realize that at all! Well, thanks a million for your help on this very vague issue, I appreciate it. (it works now :))
2 things I learned in the process:
1, never work with nonpow2 images again
2, never work with color keys again and use alpha channels instead. (resampling my old sprites to pow2 created some ugly pink outlines which are very time consuming to correct)

Share on other sites
Quote:
 Original post by MeaiOh I didnt realize that at all! Well, thanks a million for your help on this very vague issue, I appreciate it. (it works now :))2 things I learned in the process:1, never work with nonpow2 images again2, never work with color keys again and use alpha channels instead. (resampling my old sprites to pow2 created some ugly pink outlines which are very time consuming to correct)
You can always specify D3DX_FILTER_NONE for the filter when calling D3DXCreateTextureFromFileEx - that'll cause a non-power-2 texture to be loaded in the top left of a power of 2 texture, with the rest transparent black. You can then use the D3DXIMAGE_INFO* parameter to D3DXIMAGE_INFO to get the size of the image, and specify a rect when drawing the sprite.

But yes, I always avoid np2 textures like the plague [smile]

Share on other sites
Since we were talking about graphic card abnormalities anyway now: My game now worked on every machine without glitch nor distortion until I tried it on a budget laptop with a "Mobile Intel® Graphics Media Accelerator 4500MHD".
It has a native resolution of 1280 x 800 Pixel, which my other laptop also has, and on that one it worked fine without distortions.
I want to emphasize that the game always runs in windowed mode (640x480), so there should not be any problems resolution wise..I think. What could be the problem here, since the graphics card is the latest integrated tech from Intel? The whole game is getting distorted, so no issues with pow2 either and the game resolution never changes.

Share on other sites
Might be a bug in the drivers. Every once and a while, you get a video card driver that causes problem with a particular API in your game (depending on how you use it).

Create an account

Register a new account

• Forum Statistics

• Total Topics
627776
• Total Posts
2979021

• 11
• 10
• 10
• 23
• 9