Jump to content
  • Advertisement
Sign in to follow this  
PERECil

[.net] Curious behavior for Sprite.Draw2D...

This topic is 4850 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have made a InterfaceImage class 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 texture doesn't show! 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). 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?

Share this post


Link to post
Share on other sites
Advertisement
Are the textures mix sizes? What I mean is sizes that aren't square, ie.. 256x32, 128x256. I had issues with the sprite commands using textures with odd sizes. I had to convert all my textures to squares, ie 256x256, 128x128....

Slyprid

Share this post


Link to post
Share on other sites
Yep the textures aren't square sized one. I like to use weird values (even non power of two ;)). I tough those limitations have been abolished in the most recent version of Direct3D. It seems that it's not the case. I'll try with squared textures.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!