shamuse Posted June 19, 2008 Posted June 19, 2008 Hey, So I've recently begun working with directx in vb.net but Ive run in to a small problem. I can only render sprites that have power of 2 dimensions. I am aware that the texture of the sprite has to be based off an image with power of 2 dimensions, but Im fairly sure that there must be a way to render the spirte itself in something other than power of 2 dimensions using sprite.draw2d. It would be great if any of you could help me. Thanks!:) Quote
Nate Bross Posted June 19, 2008 Posted June 19, 2008 I have never tried, I didn't even know that you couldn't. I'm curious why you need to though? Whats the reason for it? Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
shamuse Posted June 19, 2008 Author Posted June 19, 2008 well, maybe I'm missing something, but if I can only render sprites with power of 2 dimensions there's only a certain amount of sprite sizes I can pick from. So I cant get exact sprite sizes. Quote
Nate Bross Posted June 19, 2008 Posted June 19, 2008 You should be able to Scale the sprites using floating point values to get them exactly the size you want. Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
shamuse Posted June 19, 2008 Author Posted June 19, 2008 I'm still a little confused. As far as I can tell the only parameters you can plug in to either textureloader.fromfile or sprite.draw2D are integers. Also, I should have mentioned this earlier, but if I try to scale it by plugginig in numbers that are not powers of 2 in the parameters for length and width in the textureloader.fromfile function it automatically rounds up to the length/width to the next power of two. Quote
Administrators PlausiblyDamp Posted June 20, 2008 Administrators Posted June 20, 2008 The sprite.Draw2D method has overloads that allow you to specify the size it will be rendered - you do not need to scale the texture yourself. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Nate Bross Posted June 20, 2008 Posted June 20, 2008 Yes, PD is correct: something roughly like this should work for you. sprite.Begin(SpriteFlags.None); sprite.Draw2D(texture, Rectangle.Empty, Rectangle.Empty, new Point(5.0f, 5.0f), Color.White); sprite.End(); Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.