Sign in to follow this  

Blurry SwapChain

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

Hey guys. So I'm having a slight problem with my swap chains. They get blurry. I think i know why too, it's just how to fix it. What i have is 3 extra swap chains with the default device swapchain rendering into a control. Basically its a 4 panel split control where you can resize each panel via the horizontal and vertical divider. Now, when i resize it so that default swap chain gets smaller, the other ones get bigger and blurred. If I do the opposite, it looks fine, no blurring. I'm almost certain it's something with the back buffer. Everything else looks to be working correctly. So either I'm doing something wrong with the back buffer, or I'm missing something... Here's my rendering code... //DXSwapChain is a custom class for a swap chain. Just holds different //properties in case i want to render a particular swap chain differently. //DXSwapChain.DXswapchains[index] is where i store all my swap chains. It's a static variable. for (int index = 0; index < DXSwapChain.DXChainCount; ++index) { using (pBackBuffer = DXSwapChain.DXswapchains[index].Chain.GetBackBuffer(0, BackBufferType.Mono)) { DXdevice.SetRenderTarget(0, pBackBuffer); DXdevice.Clear(ClearFlags.Target, DXSwapChain.DXswapchains[index].BackColor, 1.0f, 0); DXdevice.RenderState.FillMode = FillMode.Solid; DXdevice.RenderState.CullMode = DXSwapChain.DXswapchains[index].CullMode; DXdevice.RenderState.Lighting = DXSwapChain.DXswapchains[index].Lighting; DXdevice.RenderState.DepthBias = DXSwapChain.DXswapchains[index].DepthBias; DXdevice.BeginScene(); //Sets up FOV and LookAt D3DSetupMatricies(DXSwapChain.DXswapchains[index].Window); DXdevice.SetStreamSource(0, DXvb, 0); DXdevice.Indices = DXib; DXdevice.VertexFormat = CustomVertex.PositionColored.Format; DXdevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 8, 0, 12); DXdevice.EndScene(); pBackBuffer = null; DXSwapChain.DXswapchains[index].Chain.Present(DXSwapChain.DXswapchains[index].Window); } } Thanks.

Share this post


Link to post
Share on other sites
Are you resetting/resizing your swap chains when your splitter control changes size?

From your description you get much the same results if you resize a regular window+implicit swapchain application. You have to handle the resize event - it doesn't automagically do it for you [smile]

hth
Jack

Share this post


Link to post
Share on other sites
Well, upon resize I call DXSwapChain.ResetChains(). That basically goes through my array and disposes all the swapchains, including the default one. Then I recreate all of them. Once that is done the chains are rendered. As for resizing, thats done when I render each view show in the code above.

I call this function mid way through which basically takes the Control reference the swapchain will be rendered into and then figures out the Projection and View:

D3DSetupMatricies(DXSwapChain.DXswapchains[index].Window) {

DXdevice.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, ((float)Window.Width) / Window.Height, 1.0f, 1000.0f);
DXdevice.Transform.View = Matrix.LookAtLH(new Vector3(0f, 0f, -40f), new Vector3(0f, 0f, 1f), new Vector3(0f, 1f, 0f));

}

I think if that wasn't working the actual dimensions of the cube that im rendering would in fact be different from the default device swap chain, but it remains the same size. It's just the resolution that changes. I'm guessing I'm not resetting something properly. Still looking though. :P

Share this post


Link to post
Share on other sites
Ok, i finally figured it out. Upon resize, once you dispose of all the swap chains, you need to reset presentParameters.BackBufferWidth and presentParameters.BackBufferHeight to the Width and Height of the control you're rendering into. Then you can recreate all the swap chains. That fixes the distortion (blurriness, jagged edges).

Share this post


Link to post
Share on other sites

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