examples/Qt/ISFEditor/ISFEditor_app/Spout/SpoutGLDXinterop.cpp
// this function initializes and prepares Direct3D

this function initializes and prepares Direct3D
this function initializes and prepares Direct3D
bool spoutGLDXinterop::OpenDirectX9(HWND hWnd)
{
	HWND fgWnd = NULL;
	char fgwndName[MAX_PATH];
	if(m_pD3D != NULL) {
		return true;
	}
	if(!m_pD3D) {
		m_pD3D = spoutdx.CreateDX9object(); 
	}
	if(m_pD3D == NULL) {
		return false;
	}
	if(!m_pDevice) {
		m_pDevice = spoutdx.CreateDX9device(m_pD3D, hWnd); 
	}
	if(m_pDevice == NULL) {
		return false;
	}
	fgWnd = GetForegroundWindow();
	if(fgWnd) {
		if(SendMessageTimeoutA(fgWnd, WM_GETTEXT, MAX_PATH, (LPARAM)fgwndName, SMTO_ABORTIFHUNG, 128, NULL) != 0) {
			PathStripPathA(fgwndName);
			if(fgwndName[0]) {
				if(strstr(fgwndName, "Resolume") != NULL 
				&& strstr(fgwndName, "magic") == NULL) { 
					InvalidateRect(fgWnd, NULL, FALSE); 
			        RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASENOW | RDW_INTERNALPAINT);
				}
			}
		}
	}
	return true;
}
bool spoutGLDXinterop :: OpenDirectX9 ( HWND hWnd ) { HWND fgWnd = NULL ; char fgwndName [ MAX_PATH ] ; if ( m_pD3D != NULL ) { return true ; } if ( ! m_pD3D ) { m_pD3D = spoutdx . CreateDX9object ( ) ; } if ( m_pD3D == NULL ) { return false ; } if ( ! m_pDevice ) { m_pDevice = spoutdx . CreateDX9device ( m_pD3D , hWnd ) ; } if ( m_pDevice == NULL ) { return false ; } fgWnd = GetForegroundWindow ( ) ; if ( fgWnd ) { if ( SendMessageTimeoutA ( fgWnd , WM_GETTEXT , MAX_PATH , ( LPARAM ) fgwndName , SMTO_ABORTIFHUNG , 128 , NULL ) != 0 ) { PathStripPathA ( fgwndName ) ; if ( fgwndName [ 0 ] ) { if ( strstr ( fgwndName , " " ) != NULL && strstr ( fgwndName , " " ) == NULL ) { InvalidateRect ( fgWnd , NULL , FALSE ) ; RedrawWindow ( hWnd , NULL , NULL , RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASENOW | RDW_INTERNALPAINT ) ; } } } } return true ; }
this function initializes and prepares Direct3D
this function initializes and prepares Direct3D
// Already initialized ?
 // Create a IDirect3D9Ex object if not already created
 // Create a DX9 device
 // Problem for FFGL plugins - might be a problem for other FFGL hosts or applications.
 // DirectX 9 device initialization creates black areas and the host window has to be redrawn.
 // But this causes a crash for a sender in Magic when the render window size is changed.
 // Not a problem for DirectX 11.
 // Not needed in Isadora.
 // Needed for Resolume.
 // For now, limit this to Resolume only.
 // SMTO_ABORTIFHUNG : The function returns without waiting for the time-out
 // period to elapse if the receiving thread appears to not respond or "hangs."
 // Returns the full path - get just the window name
 // Is resolume in the window title ?
 // Make sure it is not a user named magic project.
 // DirectX device initialization needs the window to be redrawn (creates black areas)
 // 03.05.15 - user observation that UpDateWindow does not work and Resolume GUI is still corrupted
 // 28.08.15 - user observation of a crash with Windows 10 
 // try RedrawWindow again (with InvalidateRect as well) - confirmed working with Win 7 32bit
 // https://msdn.microsoft.com/en-us/library/windows/desktop/dd145213%28v=vs.85%29.aspx
 // The WM_PAINT message is generated by the system and should not be sent by an application.					
 // SendMessage(fgWnd, WM_PAINT, NULL, NULL ); // causes problems
 // make sure
