examples/Qt/ISFEditor/ISFEditor_app/Spout/SpoutGLDXinterop.cpp
// this is the function that cleans up Direct3D and the gldx interop
// The exit flag is a fix - trouble is with wglDXUnregisterObjectNV
// which crashes on exit to the program but not if called
// while the program is running. Likely due to no GL context on exit

this is the function that cleans up Direct3D and the gldx interop
The exit flag is a fix - trouble is with wglDXUnregisterObjectNV
which crashes on exit to the program but not if called
while the program is running. Likely due to no GL context on exit
this is the function that cleans up Direct3D and the gldx interop The exit flag is a fix - trouble is with wglDXUnregisterObjectNV which crashes on exit to the program but not if called while the program is running . Likely due to no GL context on exit
void spoutGLDXinterop::CleanupInterop(bool bExit)
{
	HGLRC ctx = wglGetCurrentContext();
	if (ctx != NULL) {
		if (!bExit) {
			if (m_hInteropDevice != NULL && m_hInteropObject != NULL) {
				wglDXUnregisterObjectNV(m_hInteropDevice, m_hInteropObject);
				m_hInteropObject = NULL;
			}
		}
		if (m_hInteropDevice != NULL) {
			wglDXCloseDeviceNV(m_hInteropDevice);
			m_hInteropDevice = NULL;
		}
		if (m_fbo > 0) {
			glDeleteFramebuffersEXT(1, &m_fbo);
			m_fbo = 0;
		}
		if (m_pbo[0] > 0) {
			glDeleteBuffersEXT(2, m_pbo);
			m_pbo[0] = 0;
			m_pbo[1] = 0;
		}
		if (m_glTexture > 0) {
			glDeleteTextures(1, &m_glTexture);
			m_glTexture = 0;
		}
		if (m_TexID > 0) {
			glDeleteTextures(1, &m_TexID);
			m_TexID = 0;
			m_TexWidth = 0;
			m_TexHeight = 0;
		}
	} 
	CleanupDirectX(bExit);
	spoutdx.CloseAccessMutex(m_hAccessMutex);
	m_hAccessMutex = NULL; 
	m_bInitialized = false;
}
void spoutGLDXinterop :: CleanupInterop ( bool bExit ) { HGLRC ctx = wglGetCurrentContext ( ) ; if ( ctx != NULL ) { if ( ! bExit ) { if ( m_hInteropDevice != NULL && m_hInteropObject != NULL ) { wglDXUnregisterObjectNV ( m_hInteropDevice , m_hInteropObject ) ; m_hInteropObject = NULL ; } } if ( m_hInteropDevice != NULL ) { wglDXCloseDeviceNV ( m_hInteropDevice ) ; m_hInteropDevice = NULL ; } if ( m_fbo > 0 ) { glDeleteFramebuffersEXT ( 1 , & m_fbo ) ; m_fbo = 0 ; } if ( m_pbo [ 0 ] > 0 ) { glDeleteBuffersEXT ( 2 , m_pbo ) ; m_pbo [ 0 ] = 0 ; m_pbo [ 1 ] = 0 ; } if ( m_glTexture > 0 ) { glDeleteTextures ( 1 , & m_glTexture ) ; m_glTexture = 0 ; } if ( m_TexID > 0 ) { glDeleteTextures ( 1 , & m_TexID ) ; m_TexID = 0 ; m_TexWidth = 0 ; m_TexHeight = 0 ; } } CleanupDirectX ( bExit ) ; spoutdx . CloseAccessMutex ( m_hAccessMutex ) ; m_hAccessMutex = NULL ; m_bInitialized = false ; }
this is the function that cleans up Direct3D and the gldx interop
The exit flag is a fix - trouble is with wglDXUnregisterObjectNV
which crashes on exit to the program but not if called
while the program is running.
this is the function that cleans up Direct3D and the gldx interop The exit flag is a fix - trouble is with wglDXUnregisterObjectNV which crashes on exit to the program but not if called while the program is running .
// Some of these things need an opengl context so check
 // Problem here on exit, but not on change of resolution while the program is running !?
 // Delete the fbo before the texture so that any texture attachment 
 // is released even though it should have been
 // endif there is an opengl context
 // Close general texture access mutex
 // Double check that the global handle is NULL
