Jump to content
  • Advertisement
Sign in to follow this  
Uphoreum

[.net] Stretched D3DX Sprite

This topic is 4389 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'm using the D3DX Sprite object to draw 2D textures to the screen. For some reason, the texture is stretched. The textures is 640*480, the size of the window. Here's the "Draw2D" code:
this.Sprite.Draw2D(this.MenuBackground, new Point(0, 0), 0.0f, new Point(0, 0), Color.White);
[/SOURCE]
The first parameter is the texture, the second is the "rotational center", next is the rotational degree, then the coordinate for drawing, and the overlay color. Any idea why this might cause the image to be stretched? Need more information?

Share this post


Link to post
Share on other sites
Advertisement
What kind of texture filtering do you have enabled and are you sure your card supports non-power of 2 textures? Try turning filtering off and see if that corrects it.

Share this post


Link to post
Share on other sites
Right now, only AlphaBlending is on, not that I'm using it.
As for powers of 2, I'll have to check. I'm so used to pure 2D pixel drawing that I forget about this sort of 3D related thing.

Share this post


Link to post
Share on other sites
Yep, power of 2 is the problem.

I didn't know about this restriction. What if I want an image to be of a size not ^2? Do I have to "build" it out of power of 2 sized images?

Share this post


Link to post
Share on other sites
Quote:
Original post by Uphoreum
I didn't know about this restriction. What if I want an image to be of a size not ^2? Do I have to "build" it out of power of 2 sized images?


I have a hard time believing your card doesn't support non-^2 textures unless it's really, really old. Anyway if you're sure, then what you can do is either build it out of smaller textures or just compensate for your cards strecting.

See right now it's being strected to 1024x512, if you turn filtering off it should just pad the extra space. Then use the draw overload that takes a rectangle and set it to (0,0,640,480). Depends on your card though, it might be best to just make a 1024x512 texture and add the 640x480 one to it.

Share this post


Link to post
Share on other sites
Well, the card is a GeForce 6600GT. It's still made, it's not really old. Could their be some sort of setting for the D3D Device that controls this?

Share this post


Link to post
Share on other sites
Can you post your code for setting up the device and the code for loading the texture?

Share this post


Link to post
Share on other sites
Yep,
Device:


//Setup Presentation Perameters
PresentParameters Parameters = new PresentParameters();

//One Back Buffer
Parameters.BackBufferCount = 1;

//Set Our Window As Device's Window
Parameters.DeviceWindow = Window;

//No V-Sync
Parameters.PresentationInterval = PresentInterval.Immediate;

//Discard Old frames
Parameters.SwapEffect = SwapEffect.Discard;

//Set As Windowed
Parameters.Windowed = true;

//Create The Device
Device Device = new Device(0, DeviceType.Hardware, Window, CreateFlags.SoftwareVertexProcessing, Parameters);



Texture:

this.MenuBackground = TextureLoader.FromFile(this.Device, "data/menu/menuBackground.bmp");


Share this post


Link to post
Share on other sites
Try this:

this.MenuBackground = TextureLoader.FromFile( this.Device, "data/menu/menuBackground.bmp", 0, 0, 1, Usage.SoftwareProcessing, Format.A8R8G8B8, Pool.Managed, Filter.None, Filter.None, 0 );

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!