Jump to content
  • Advertisement
Raph

2D Trying to figure out smooth window resize with Direct2D

Recommended Posts

I really, really would like to have smooth, artifact-free resize of an app that renders its content using Direct2D. (In point of fact, the app is an editor, but I'm using "game-like" techniques to render the UI, and a solution to this problem would be useful for games).

I've been playing with this for a while, and am frustrated that I have a couple of "almost" solutions, but nothing that works robustly. I wrote up my explorations (with links to code) on my blog. The code happens to be in Rust, but I'm calling WinAPI pretty directly, so a working recipe would be easy enough to adapt to or from C++.

I'm feeling stuck enough on this that I'm offering a $2500 bounty for a proper solution. I'd love to be able to make forward progress, and don't want to spend a lot more time on it myself.

I'm not 100% it's even possible on Windows, though I see glimmers of hope.

Share this post


Link to post
Share on other sites
Advertisement
Posted (edited)

Replying to my own question. I think I've figured out a reasonable hybrid solution: use a swapchain with flip swap effect in the steady state, but fall back to a hwnd render target when the window is resizing. I've implemented this and collected reports from users with a wide range of configurations: https://github.com/google/xi-win/issues/19

I suspect this might be the best that can be done, but of course am open to improvements.

Thanks to Jesse (SoldierOfLight) for discussion which helped me understand what's going on.

Edited by Raph
shout-out to SoldierOfLight

Share this post


Link to post
Share on other sites

For what it's worth, prior to Win10 14393 (1607), I think that attempting to switch from a FLIP swapchain to blt or GDI will not work. On those OSes, once a flip swapchain is bound, GDI content in the client region is ignored. Not 100% sure whether it was 1607, might've been the release before or after.

Share this post


Link to post
Share on other sites

SoldierOfLight: does it matter that I'm creating the swapchain for composition rather than binding it directly to the window? In any case, if it does turn out to be a problem, it'll be easy enough to version-check and fall back to a different strategy.

Share this post


Link to post
Share on other sites

That's an excellent question. In that case, I think you're okay. I believe that using DComp to layer on top of a window is different than binding the swapchain directly to the window. I'm not positive though, my experience with DComp is pretty minimal.

Share this post


Link to post
Share on other sites

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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!