typedef struct{ HMONITOR hMonitor; UINT uiDefaultAdapter; // initial default adapter for this monitor UINT uiCurrentAdapter; // current adapter for this monitor UINT uiAdapterCount; // number of adapters for this monitor D3DAdapterInfo** pAdapterList; // list of pointers to adapters for this monitor}D3DAdapterInfoList;class D3DAdapterEnum{public: D3DAdapterEnum(); ~D3DAdapterEnum(); void SetD3D( LPDIRECT3D8 pD3D ); HRESULT EnumerateHardware(); void ReleaseResources(); HRESULT ChooseDefaults( UINT uiMonitor ); UINT GetMonitorCount() const; UINT GetAdapterCount( UINT uiMonitor ) const; GFXADAPTERINFO GetAdapterInfo( UINT uiMonitor, UINT uiAdapter ) const; GFXMODEINFO GetAdapterMode( UINT uiMonitor, UINT uiAdapter, UINT uiMode ) const ; HRESULT SetAdapterForMonitor( UINT uiMonitor, UINT uiAdapter ); HRESULT SetModeForAdapter( UINT uiMonitor, UINT uiAdapter, UINT uiMode ); UINT GetCurrentAdapter( UINT uiMonitor ) const; D3DAdapterInfo* GetD3DAdapterInfo( UINT uiMonitor, UINT uiAdapter ) const;protected: bool EnumerateAdapter( UINT uiAdapterOrdinal, D3DAdapterInfo* info ); HRESULT CheckAdapterCaps( UINT uiAdapterOrdinal, D3DAdapterInfo* info ); HRESULT GetAdapterModes( UINT uiAdapterOrdinal, D3DAdapterInfo* info ); HRESULT CreateMonitorList(); HRESULT MakeAdapterListForMonitor( UINT uiMonitor );protected: LPDIRECT3D8 m_pD3D; UINT m_uiMonitorCount; D3DAdapterInfoList* m_pMonitorList; UINT m_uiAdapterCount; D3DAdapterInfo* m_pAdapterList;};
It goes like this:
Monitor Adapter Modes[] Adapter Modes[] Adapter Modes[]Monitor Adapter Modes[] Adapter Modes[]
1. You have physical monitors. In Windows each monitor has a unique HMONITOR.
2. Each monitor can have one or more adapters connected to it. An adapter is a physical graphics card in the system capable of output to the monitor.
3. Each adapter (graphics card) has a set of display modes it can handle
An example: A system with a single monitor, with a S3 ViRGE *AND* a 3Dfx Voodoo2 card connected to that. The system has one monitor with 2 adapters and each adapter has it''s own set of modes. The Voodoo2 can only 16bit modes wheras the ViRGE can do 32bit as well.
Monitor1 S3 ViRGE Array_of_16,24_and_32bit_modes[] 3Dfx Voodoo2 Array_of_16_bit_modes[]
Each adapter can have a Direct3D HAL device created for it.
The above is generally the way you should think about all adapters in the system.
Cards with multimonitor support (as Matrox DualHead, nVidia TwinView etc) or TVOut will show up in the system as *2* adapters, one for each monitor (or TV) they have connected.
You don''t need to change your approach for those because they appear as 2 separate cards, everything should be automatic.
The only thing to bear in mind is that although it''s the same chip handling both monitors, the display capabilities and output modes may be different for each monitor (a TV usually can''t support all the modes a monitor can for example).
Some more examples:
An AGP G400 DualHead card with 2 monitors connected.
Monitor1 Adapter=G400 display1 Modes[]Monitor2 Adapter=G400 display2 Modes[]
An AGP G400 DualHead card with 1 monitor connected.
Monitor1 Adapter=G400 Modes[]
An AGP G400 with 2 monitors and a PCI TNT with a 3rd.
Monitor1 Adapter=G400 display1 Modes[]Monitor2 Adapter=G400 display2 Modes[]Monitor3 Adapter=TNT Modes[]
An AGP G400 with 2 monitors + a Voodoo2 connected to the 1st
[It''s unlikely anyone would be that sick though!]
Monitor1 Adapter=G400 display1 Modes[] Adapter=Voodoo2 Modes[]Monitor2 Adapter=G400 display2 Modes[]
--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com