I have made a InterfaceImage image for a GUI, using the D3DX Sprite class. But I got some strange behaviors that doesn't seems to be explained in the MSDN.
TheImage.Draw2D(TheTexture, Rectangle.Empty, new Rectangle(Left, Top, Width, Height), new Point((int)(Left / ((float)Width / (float)TextureX)), (int)(Top / ((float)Height / (float)TextureY))), Color.Transparent);
TheTexture: a Texture object
TheImage: a Sprite object
Top, Left, Width, Height: screen coordinate of the sprite.
TextureX, TextureY: Size of the texture
This code works great on an Ati 7200. Old graphic card, but works fine. With any
combination of width and height. Today, I moved home, and wanted to test the code on my home computer (Nvidia Ti4200). Weird thing: When the (Width,Height) matches the texture size (in my case, the texture is 256*64, and the Width,Height is respectively set to 256,64), the sprite doesn't show! IfI put a size of 257*64, it works. 256*65, it works to. Only 256*64 hide the sprite.
This seems really weird to me.
The second strange thing is the scaling formula:
new Point((int)(Left / ((float)Width / (float)TextureX)), (int)(Top / ((float)Height / (float)TextureY)))
In the MSDN, the docs tell that the point is the position of the sprite. After some little research, i've found that it was the top left position (wasn't mentionned in the docs, but was easy to find out). Curiously, this position depends on the texture size (that's why I divide by the texture size).
Example:
Point(200,200) with a 200,200 texture at size 200,200: real screen position is 200,200.
Point(200,200) with a 100,100 texture at size 200,200: real screen position is 400,400.
Nothing was mentionned about this in the documentation of Sprite.Draw2D(). Does someone have a clue about this strange behavior
Specs:
DX9 SDK (april release) on windows 2000 SP4,
NVidia Ti4200 or Ati 7200

Sprite.Draw2D not working as intended?
DiegoV