Sign in to follow this  

Why are my images stretched? d3d 9

This topic is 4357 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 set the screen size to be 640, 480, however the images come out elongated. The background image is 640 * 480 but it is stretched. I am using a 2d draw method. This is the original http://img.photobucket.com/albums/v308/death_entry/screen.jpg Tihs is from a screenshot of how it comes out http://img.photobucket.com/albums/v308/death_entry/screen2.jpg

Share this post


Link to post
Share on other sites
When you load textures that aren't the power of 2, they will get stretched by Direct3D. It's always best to keep your textures to a power of 2 to avoid having to do other processing to get the correct resolution for your textures.

This screenshot shows the difference between the 2 textures (power of 2 and non-power of 2).


You can see a slight problem in quality of the non-power of 2 texture on the right hand side versus the texture on the left hand side. This might increase the more your texture is out of range.
Power of 2 compliant sizes are...
16 x 16, 32 x 32, 64 x 64, 128 x 128, 256 x 256 etc...
You can mix and match then as you see fit such as
16x256 and so forth.


I hope this helps.
Take care.

Share this post


Link to post
Share on other sites
I might be wrong, but don't bad texture sizes result in squashed, not elongated, textures?

For example, a 499x512 texture is loaded by DirectX onto a 512x512 area. The extra 13 pixels in width is filled with alpha pixels, right? That means horizontal texture co-ordinates of 0.0 to 1.0 would be squashing all 512 pixels across into the space you expected to hold 499 pixels.

Texture elongation would happen because you've told DirectX to completely fill a particular area/surface you've given it, instead of telling it to display the texture as is. In D3D I would just suggest checking the size and texture co-ordinates of the quad you're rendering the texture to.. but since you're using a 2D draw method I can only say check the documentation for the function that draws the texture. Check to see if that function is meant to fill the entire area regardless of texture size. I haven't used any DirectDraw functions, so I'm afraid I can't help with which function that is exactly.

Share this post


Link to post
Share on other sites
Try loading the image into an offscreen surface and then copy the surface to the backbuffer. Images in surfaces, unlike textures, don't have size restrictions.

Share this post


Link to post
Share on other sites
my backbuffer is set to be 640 * 480. the image im using is also 640*480 (so I shouldn't have an issue with the power of 2 thing) so how is it being stretched to greater then the backbuffer? The image is meant to be a background and to fill the whole area, but it's being stretched over it :S


Quote:

mdlOptions.sprite.Draw2D(background, backRotation, 0, backRectangle.Location, Color.White)

background = TextureLoader.FromFile(mdlOptions.DDevice, Application.StartupPath & "/Images/Backgrounds/nightandmountains.png")




Quote:

Module mdlOptions
Public Const ScreenWidth As Integer = 640
Public Const ScreenHeight As Integer = 480
Public device As device = Nothing
Public sprite As sprite

Public ReadOnly Property DDevice() As device
Get
Return device
End Get
End Property


Public Sub InitializeGraphics(ByVal form As Form)
' Set our presentation parameters
Dim presentParams As New PresentParameters

presentParams.SwapEffect = SwapEffect.Discard

' Start up full screen
Dim current As Format = Manager.Adapters(0).CurrentDisplayMode.Format

If Manager.CheckDeviceType(0, DeviceType.Hardware, current, current, False) Then
' Perfect, this is valid
presentParams.Windowed = True
presentParams.BackBufferFormat = current
presentParams.BackBufferWidth = ScreenWidth
presentParams.BackBufferHeight = ScreenHeight
Else
presentParams.Windowed = True
End If
' Create our device
device = New device(0, DeviceType.Hardware, form, CreateFlags.SoftwareVertexProcessing, presentParams)



End Sub 'InitializeGraphics

Share this post


Link to post
Share on other sites

This topic is 4357 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this