Jump to content
  • Advertisement
Sign in to follow this  
NVergunst

How to Scale Texture C#?

This topic is 3791 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

When I was using the Draw2D() function there was a source and destination rectangle and everything. Now that i am using the regular Draw() function, there is no such option. So with some googling I found that I need a matrix, and I can rotate, scale, and translate with a matrix. I have set a matrix and applied a "Sprite.Transform = myScalingMatrix" and it works perfectly as it scales the entire sprite. Now my problem is I have a bunch of textures, and these need to be scaled independantly as well. How do I scale Texture A and leave Texture B alone when they are drawn to the same sprite? I have a feeling I need to break them into seperate sprites. What is the potential overhead for having a sprite for each texture I need to draw? Will this send my RAM usage through the roof? How do I get around this? And I am not able to scale them before hand. Any help is appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Ok, I have made my image classes each have their own sprite, and it works just fine. I am calling .Begin() and .End() quite a bit which I am sure are costing me lots of CPU cycles, so if someone knows a better way let me know.

Now I think I may have come up with a reason as to why scaling throws the position off so much. When you apply a Matrix.Scale() to a sprite, does it resize it to a power of 2 or something? My images are not powers of 2, and when I do not scale them, they draw at the correct location. When I scale them, they draw incorrectly.

Usually off by some amount in both the x and y direction. Or at least in a 2D world that is what it looks like. It supposed to be at [x,y] and it draws at [x+a, y+b] where a and b seem to be random and only happens if scaled.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!