Jump to content
  • Advertisement
Sign in to follow this  
kamilzubair

Why D3DXCreateTextureFromFileEx produces ugly image ?

This topic is 3817 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 noticed that when I create texture using D3DXCreateTextureFromFileEx the end result is always jagged/blurred even if I use no filter and render that texture in transformed vertices. I tried using different filter combination and the results are still ugly. The only way I can get the good quality image is by using LoadImage and manually copy the bitmap bits to texture, but this mean I can only use bmp file. Is there a way to make D3DXCreateTextureFromFileEX produce good result ?

Share this post


Link to post
Share on other sites
Advertisement
What size is your source image? D3DX's default behaviour is to resize it to the nearest 2N dimension for optimal performance on the GPU. Sometimes this can blur/distort your image.

There's a flag that can override this behaviour provided your device supports NPOT textures (most do). Look in the SDK documentation for details - I can't remember the exact flag name off the top of my head.

hth
Jack

Share this post


Link to post
Share on other sites
Instead of directly creating the surface with D3DXCreateTextureFromFileEX(), you may have better luck with creating the texture with D3DXCreateTexture(), calling GetSurfaceLevel() and then calling D3DXLoadSurfaceFromFile().

Share this post


Link to post
Share on other sites
I have found the solution. The problem is not with the texture but with the vertex buffer. I set the coordinate for the quad in (0, 0) to (ScreenWidth, ScreenHeight) but the right coordinate is (-1, -1) to (ScreenWidth, ScreenHeight).

It's kinda embarassing because it explicitly detailed in "Directly Mapping Texels to Pixels" in DirectX SDK manual but I only get the meaning today :)

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!