IDirect3DDevice9 and multiple windows etc.

Ok, so you said we could ask anything here... :-)

We currently have an app running with thousand of users online, and the client uses DirectX7 2D.
Have been test-converting it to DirectX9 3D. Runs very well in test, but before advancing in modifying all the code, I have some questions, which are code design questions... here goes...

What do we have now: we have one window with the app running.

What do we want to have: multiple windows, showing different graphics from the same graphics-base.
So when I create a texture for use with a sprite (for now), then the texture seems to be bound to the device and the device seems to be bound to a window. So if I want to have 5 windows (different size), then does that mean that it has to have 5 devices and 5 sets of textures What I want, is to load all the textures, just once, and then use them across windows (scaling the textures among things)... how do to that
Next thing I want, is to display one texture into another... for example, I build a texture from other textures...
How to do that

Hope to get a reply soon! :-)

thanx in advance
Soren





Answer this question

IDirect3DDevice9 and multiple windows etc.

  • Baji Prasad

    maybe I can use: 'CreateAdditionalSwapChain' with different sizes, and then 'Present' with 'hDestWindowOverride' set ...
    Will that create independent swapchains, that can be used for multiple windows If yes: when I use sprite->Draw, then it drawes to the device's default swapchain... how can I draw to other swapchains, and build several views with different sizes

  • GeorgeBH

    I guess the following answers my question: :-)

    // Tell the Direct3D device to render to the second swap chain’s back buffer
    LPDIRECT3DSURFACE9 pBackBuffer = NULL;
    g_swapChain_1->GetBackBuffer( 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer );
    g_pd3dDevice->SetRenderTarget( 0, pBackBuffer );

    last question is still: how can I render one texture into another...



  • Lanex

    The proper way to display into multiple independent windows on the same screen all originating from the same device is to create additional swap chains. Each swap chain is attached to one of these windows, and you render to each swap chain independently (but using resources that are shared between all other views). You don't really need the hwndDestOverride parameter BTW.

  • cis001

    Your rendering shceme is ok. Regarding performance, nothing is for free right So the less the changes the better. In particular, for a single frame I'd only set a swap chain once as a render-target and do all of the rendering on it before moving to another swap-chain. The performance hit might not be that high depending on how your application is setup.

  • El Bruno

    ok... thanx...

  • wxin

    So far so good...

    new question: if I have say 5 windows... then I could render to #1, then 2, then 3, then 4 and then 5 and then call Present... but if I would render like #1, #2, #3, #1, #2, #5, #2 sort of randomly, then I use setrendertarget several times extra... does that cost performance If yes, then small/medium/big

    and... this this the 100% correct way :

    beginscene
    setrendertarget #0
    draw to #0
    setrendertarget #1
    draw to #1
    setrendertarget #2
    draw to #2
    endscene
    present #0
    present #1
    present #2
    Loop

    thanx again
    sincerely,
    Soren



  • IDirect3DDevice9 and multiple windows etc.