Skip to main content
GameDev.net gamedev.net
🔒 Locked

Multiple Render Windows

Started by WhyWontItWork Sep 7, 2003 at 1:03 PM 4 replies 650+ views
Original Post
WhyWontItWork
WhyWontItWork
Hey, I have been having some trouble getting multiple render windows to work. My engine can render to a single render window or viewport within that window with ease. However I am pulling my hair out trying to figure out why I will not work with multiple windows. I used this article as a reference: http://www.mvps.org/directx/articles/rendering_to_multiple_windows.htm Here is what my code does: -Creates a device with a backbuffer the size of the current desktop resolution and format. The focus window is the form on which my RenderSurface controls are contained. -Creates the appropriate swap chains for each RenderSurface with their device window''s set properly -Clear the zbuffer and frame buffer (to pure blue) -Render all my stuff -Call Present on each swap chain Now in theory that should work, but of course nothing ever works the first time you try. The problem is this: The RenderSurfaces only shows either full lime green or full pink (Which is pretty funny because when updated at 100+ fps it looks brown). There are no errors or warnings outputted to dbmon.exe nor are there any exceptions thrown (It is a C# application, basicly that means that all of the HRESULTS were success) What could be possible causes or courses of action to solving the problem? Thanks! -Brandon
WhyWontItWork
WhyWontItWork
*bump*

Nobody knows?

Does anyone have any simple source code that demonstraits multiple render targets to which I can compare my code?

Thanks
-Brandon
Namethatnobodyelsetook
Namethatnobodyelsetook
The alternating color effect is an effect of the D3D Debug runtime. If you present, the front and back buffers are swapped, and the back buffer is filled with this alternating color to indicate that you aren''t clearing and/or drawing over every pixel every frame. When using swapeffect discard, you are supposed to redraw everything.

The part you''re missing is probably drawing to each of the swap chains back buffers. The main device has a swap chain with a back buffer, and then each swap chain you make has it''s own back buffer too.

What you want to do is:

For each swap chain
{
Query swap chain''s back buffer
SetRenderTarget for this chain''s backbuffer and depth buffer
(note you cannot query the depth, so don''t use autodepthstencil)
SetViewport if you want subviewports in this swapchain.
Draw whatever you want on this surface
Present this surface
}

SpreeTree
SpreeTree
Sounds like you are either not setting up the correct back buffer to draw to (using swapChain->GetBackBuffer(..., pBackBuffer) and d3dDevice->SetRenderTarget(0,pBackBuffer)), or your Present on the wrong surface. It needs to be called on the swapChain you are rendering to, with (NULL, NULL, NULL, NULL).

Bare in mind that the way to set up the swap chains is slightly different between DX8 and DX9. The example you are looking at will not work if you copy and paste it in DX9.

FYO this was the tutorial I used to get swap chains working for DX9. There is another tutorial out there (which gives slightly more information) but i cant for the life of me remeber what the address is. has something to do with angels i think, but then i could just be talking bollocks :s
WhyWontItWork
WhyWontItWork
well holy poo...

I stared at my code for hours and compared it with that sample a billion times and I even stepped through it quite a few times. But I can not believe that I didn''t see that my call to SetRenderTarget didn''t ever run! I put a break point on it because you said I might be forgetting to do that. And to my great suprize the point was never hit!

Thank you so much. I feel very stupid now

-Brandon
pete_2004
pete_2004
Thank goodness for decent forum replies. : )
I had a similar problem until I read this thread. I thought of using SetRenderTarget too but the d3d9 api documentation states:

that the target you set has to be a color buffer.(this threw me off I was thinking this meant palettes)

and for DWORD RenderTargetIndex is says see remarks. The remarks didnt say what to set this too.

So thank you for posting such a great reply.( it may seem silly being happy over something so simple, but when api docs are wrong it generally creates a great deal of frustration. )

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.