1
votes

When I run my 3d scene, it only renders the first frame and then flips between it and a black screen, causing lots of flicker. I think it's my swap chain that's not set up correctly, but I don't really know.

Here's my code to set it up. It's pretty much copied from an Microsoft example.

DXGI_SWAP_CHAIN_DESC1 sd = {0};
sd.Width = 0;                           
sd.Height = 0;
sd.Format = DXGI_FORMAT_R8G8B8A8_UNORM; 
sd.Stereo = false; 
sd.SampleDesc.Count = 1;                
sd.SampleDesc.Quality = 0;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.BufferCount = 2;                     
sd.Scaling = DXGI_SCALING_NONE;
sd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
sd.Flags = 0;

CoreWindow^ window =  reinterpret_cast<CoreWindow^>(mSystem->GetIWindow());
hr = pIDXGIFactory->CreateSwapChainForCoreWindow(mD3DDevice,  reinterpret_cast<IUnknown*>(window), &sd, NULL, &mSwapChain);
EA_ASSERT(SUCCEEDED( hr ));

And the present code:

DXGI_PRESENT_PARAMETERS  presentParameters = {0};
HRESULT hr = mSwapChain->Present1(0, 0, &presentParameters);

Seems to me pretty straighforward, so I don't really get why it's not working.

The scene is running all the time. The update function gets run every frame.

Also, if I check the render in PIX, everything is fine. I get what I expect the render to be. It just doesn't appear on screen.

Any ideas? Thanks!

1

1 Answers

6
votes

Turns out I wasn't calling OMSetRenderTargets on my device context every frame. Now it works.