Jump to content
  • Advertisement
Sign in to follow this  
_Flecko

Resizing the view

This topic is 4811 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 working on a program that has a resizable DirectX display. It's 2D and uses an orthographic projection. Every time the window is resized, I change the projection to reflect the window's new dimensions. When this happens I start getting blurry images, and texels not mapping perfectly to pixels (I am aware of the whole 0.5 offset thing and my code handles it). I'm not trying to just scale up the image in the window, I want to actually view a larger or smaller amount of space. Besides changing my projection, what do I have to do for this to work?

Share this post


Link to post
Share on other sites
Advertisement
As well as changing the projection matrix you should Reset() the device with the changed window client dimensions in the D3DPRESENT_PARAMETERS structure. You can see an example of this in the sample framework that the SDK samples use.


When you resize the window, the backbuffer that D3D is rendering to doesn't get resized, it stays at what it was when you created the device.

In windowed mode, Present performs a blit from the back buffer surface to the area of the primary desktop surface occupied by your window; if the size of the back buffer differs from the size of the window, then hardware accelerated scaling takes place - it's here that blurriness and other scaling problems occur.

As an example, imagine your back buffer is 100x100, and the client area of your window 100x100, so when you call Present(), there is a 1:1 mapping between the back buffer and the window. Now imagine you resize the window so that its client area is 150x150, the back buffer is still 100x100 (resizing the window does just that and only that - it doesn't change the size of the back buffer for you) - blitting from 100x100 to 150x150 is a 1:1.5 relationship - and as you know, you can't really have .5 of a pixel, so depending on how the hardware performs the stretch blit, you'll get blurriness or missing pixels.


The solution is to use Reset() to set a new back buffer size.

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!