1 #ifndef _DISPLAYDX__H_ 2 #define _DISPLAYDX__H_ 3 4 #ifdef WIN32 5 6 #include <d3d9.h> 7 #include <d3dx9.h> 8 9 #include "DisplayOutput.h" 10 11 namespace DisplayOutput 12 { 13 14 #define MAX_DISPLAYS 9 15 #define NO_ADAPTER 0xffffffff 16 #define NO_MONITOR 0xffffffff 17 18 // Structure for holding information about a monitor. 19 struct MonitorInfo 20 { 21 TCHAR strDeviceName[ 128 ]; 22 TCHAR strMonitorName[ 128 ]; 23 HMONITOR hMonitor; 24 RECT rcScreen; 25 DWORD iAdapter; // Which D3DAdapterInfo corresponds to this monitor 26 HWND hWnd; 27 28 // Error message state 29 FLOAT xError; 30 FLOAT yError; 31 FLOAT widthError; 32 FLOAT heightError; 33 FLOAT xVelError; 34 FLOAT yVelError; 35 }; 36 37 38 /* 39 CDisplayDX. 40 Windows DirectX output. 41 */ 42 class CDisplayDX : public CDisplayOutput 43 { 44 bool m_BlankUnused; 45 bool m_Shader20; 46 D3DPRESENT_PARAMETERS m_PresentationParams; 47 IDirect3DDevice9 *m_pDevice; 48 49 HWND m_WindowHandle; 50 uint32 m_DesiredScreenID; 51 52 IDirect3D9 *m_pDirect3DInstance; 53 54 void EnumMonitors(); 55 HWND createwindow( uint32 _w, uint32 _h, const bool _bFullscreen ); 56 MonitorInfo m_Monitors[ MAX_DISPLAYS ]; 57 DWORD m_dwNumMonitors; 58 59 // Only valid when running as a screensaver. 60 bool m_bScreensaver; 61 bool m_bPreview; 62 63 bool m_bFullscreenSwitch; 64 bool m_bStartedFullscreen; 65 66 bool InitDX9(); 67 68 public: 69 CDisplayDX(bool _blank, IDirect3D9 *_pIDirect3D9); 70 virtual ~CDisplayDX(); 71 GetNumMonitors()72 virtual DWORD GetNumMonitors() { return m_dwNumMonitors; } 73 void BlankUnusedMonitors(WNDCLASS &wnd, HWND hWnd, HINSTANCE hInstance); 74 75 static LRESULT CALLBACK wndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); 76 Description()77 static char *Description() { return "Windows DirectX display"; }; 78 virtual HWND Initialize( const uint32 _width, const uint32 _height, const bool _bFullscreen ); 79 80 UINT GetAdapterOrdinal(); WindowHandle(void)81 HWND WindowHandle( void ) { return m_WindowHandle; }; Device()82 IDirect3DDevice9 *Device() { return m_pDevice; }; PresentParameters()83 D3DPRESENT_PARAMETERS PresentParameters() { return m_PresentationParams; }; 84 SetScreen(const uint32 _screen)85 void SetScreen( const uint32 _screen ) { m_DesiredScreenID = _screen; }; 86 87 // This is used when running as a screensaver, where the hwnd might already be provided. 88 virtual bool Initialize( HWND _hWnd, bool _bPreview ); 89 90 // 91 virtual void Title( const std::string &_title ); 92 virtual void Update(); 93 HasShaders()94 virtual bool HasShaders() { return m_Shader20; }; 95 void SwapBuffers(); 96 }; 97 98 MakeSmartPointers( CDisplayDX ); 99 100 }; 101 102 #endif 103 104 #endif 105