Sign in to follow this  
DumpAlien

Direct3D 10 And Multiple Windows

Recommended Posts

Hello all! :) I am planning to add multiple Window support to a 3D Engine. Is it better to have one device and one swap chain per window? (Multiple devices) Or one device and multiple swap chains(one swap chain per window)? Is there any restrictions when I have multiple swap chains on one device? What u suggest? thank you!

Share this post


Link to post
Share on other sites
In most cases a single-device-multiple-swapchain approach is the preferred method. This allows you to share resources between windows (resources are allocated per-device) but with shared handles in WDDM you can have a single device with single swapchain per window and share resources between them... but you will find it a bit more restrictive than the former.

hth
Jack

Share this post


Link to post
Share on other sites
That is the way I'm doing it, one device and multiple swapchains. Lemme grab some code from my project.

RenderWindowDesc, struct - pass and array of this struct to the class constructor

struct RenderWindowDesc
{
//window related
HWND m_hWnd;
bool m_bWindowed;

//swapchain related
float m_fSwapchainWidth;
float m_fSwapchainHeight;
float m_fRefreshHz;
unsigned int m_nBufferCount;
float m_fClearRed;
float m_fClearGreen;
float m_fClearBlue;

//viewport related
float m_fViewportWidth;
float m_fViewportHeight;
float m_fViewportMinD;
float m_fViewportMaxD;
float m_fTopLeftX;
float m_fTopLeftY;
};


RenderWindow, struct - The actual stored data in my renderer class

struct RenderWindow
{
IDXGISwapChain* m_pd3dSwapChain;
ID3D10RenderTargetView* m_pd3dRenderTargetView;
D3D10_VIEWPORT m_d3dViewport;
ShtrColor* m_pClearColor;
ShtrMatrix4 m_matOrtho;
bool m_bIsRendering;
bool m_bIsWindowed;
};


Also, you should create the device with the
D3D10CreateDevice
function. Then create a IDXGI factory with the
CreateDXGIFactory
function. And then create the swapchains through the factory with the
CreateSwapChain
function.

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

Sign in to follow this