Jump to content
  • Advertisement
Sign in to follow this  

StretchRect results in blury display

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

Hi. I try to rewrite our CBM emulator project (VICE) to use DirectX 9. This is how it works: 1. A Device9 is created and attached to the emulators window using D3DFMT_X8R8G8B8 backfuffer format. 2. CreateOffscreenPlainSurface is used to create a Surface also using D3DFMT_X8R8G8B8 format. 3. The emulators render routine draws to the offscreen surface which is directly accessed via LockRect and pRect pointer. 4. The offscreen surface is copied/transfered to the backfuffer using the device StretchRect method. 5. The Device uses Present method to show the display. All this works quite well, means I can see the emulator window but: The display is extremely blurry! E.g. the emulators renderer emulates PAL TV scan lines which should result in every second line being dark (almost black). The StretchRect (or any other part of the Presentation process?) seems to blur/filter/antialias the offscreen Surface even if both surfaces have exactly the same size. So the scanlines aren't visible. I tried several filter parameters in StretchRect and I also tried to modify my GPU driver parameters with no success. So the question is: How can I force DirectX to do a plain copy from offscreen surface to backbuffer or at least reduce filtering/avaraging?

Share this post

Link to post
Share on other sites
If your offscreen and backbuffer sizes are different, StretchRect will do a linear interpolation blend between pixels... which will be quite blurry.

If your backbuffer size is different from your actual window client rect size, it will be StretchRect'd there too. I've heard that while this is a linear interpolation on XP, on Vista it uses a POINT filter.

Look on wikipedia for high quality ways to scaling older generation graphics to today's resolutions.

Share this post

Link to post
Share on other sites
Thanks for your answer but size of offscreen surface and backbuffer are exactly the same and even the windows client size is if I don't resize it.

I also have disabled any antialiasing in the driver settings but still get a blurry display.

[...some more time of debugging...]

Now I just came to the conclusion that resizing my Backbuffer to "doublesize" fails (which is the mode that usually makes scanlines visible) and the backbuffer is only half of the size it should be.

Fact is that Creating a new offscreen surface with double size is successful but calling the IDirect3DDevice9::Reset fails. Here's my resizing code:

ddresult = IDirect3DDevice9_CreateOffscreenPlainSurface(d3ddev, width, height, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &d3dsurface, NULL);
ddresult = IDirect3DDevice9_GetSwapChain(d3ddev, 0, &d3dsc);
ddresult = IDirect3DSwapChain9_GetPresentParameters(d3dsc, &d3dpp);
ddresult = IDirect3DSwapChain9_Release(d3dsc);

d3dpp.BackBufferWidth = width;
d3dpp.BackBufferHeight = height;

ddresult = IDirect3DDevice9_Reset(d3ddev, &d3dpp);

Any idea why this last call returns D3DERR_INVALIDCALL?

Any help is welcome.

Seems that I just forgot to release the old offscreen surface.

ddresult = IDirect3DSurface9_Release(d3dsurface);

[Edited by - Rubi on January 26, 2009 4:23:08 PM]

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!