diff --git a/src/OpenGl/OpenGl_attri.cxx b/src/OpenGl/OpenGl_attri.cxx index 9739ba6e96..894df1d018 100755 --- a/src/OpenGl/OpenGl_attri.cxx +++ b/src/OpenGl/OpenGl_attri.cxx @@ -527,7 +527,7 @@ TsmPopAttri( void ) if( attri_tail->TransPers.mode != node->TransPers.mode || attri_tail->TransPers.pointX != node->TransPers.pointX || attri_tail->TransPers.pointY != node->TransPers.pointY || - attri_tail->TransPers.pointZ != node->TransPers.pointX ) + attri_tail->TransPers.pointZ != node->TransPers.pointZ ) { transform_persistence_begin( attri_tail->TransPers.mode, diff --git a/src/OpenGl/OpenGl_subrvis.cxx b/src/OpenGl/OpenGl_subrvis.cxx index 325a8ab9a0..8b3f96c979 100755 --- a/src/OpenGl/OpenGl_subrvis.cxx +++ b/src/OpenGl/OpenGl_subrvis.cxx @@ -120,6 +120,8 @@ from higher API */ #include #include #include +#include +#include /*----------------------------------------------------------------------*/ /* @@ -759,20 +761,39 @@ void call_subr_close_ws( CALL_DEF_VIEW * aview ) { CMN_KEY_DATA key; -#ifdef OCC1188 - tsm_bg_texture texture; - - TsmGetWSAttri( aview->WsId, WSBgTexture, &key ); - texture = (tsm_bg_texture)key.pdata; - - if( texture == 0 ) - return; - - if ( texture->texId != 0 ) - glDeleteTextures( 1,(GLuint *)&(texture->texId) ); -#endif + CMN_KEY_DATA textureKey; TsmGetWSAttri( aview->WsId, WSWindow, &key ); + +#ifdef OCC1188 + tsm_bg_texture texture; + WINDOW aWnd = (WINDOW) key.ldata; + + TsmGetWSAttri( aview->WsId, WSBgTexture, &textureKey ); + texture = (tsm_bg_texture)textureKey.pdata; + + if ( texture != 0 && texture->texId != 0 ) + { + OpenGl_ResourceCleaner* anCleaner = OpenGl_ResourceCleaner::GetInstance(); + + // Delete the texture with ResourceCleaner; if it is not possible + // do this directly with proper context selected + if ( !anCleaner->AddResource( TxglGetContext(aWnd), + new OpenGl_ResourceTexture(texture->texId) ) ) + { + GLCONTEXT cur_context = GET_GL_CONTEXT(); + GLDRAWABLE cur_drawable = GET_GLDEV_CONTEXT(); + + if ( TxglWinset( call_thedisplay, aWnd ) == TSuccess ) + glDeleteTextures( 1,(GLuint *)&(texture->texId) ); + + // activate the previous context for this thread + GL_MAKE_CURRENT( call_thedisplay, cur_drawable, cur_context ); + } + } + +#endif + #ifdef RIC120302 if( !aview->GContext ) #endif diff --git a/src/OpenGl/OpenGl_togl_redraw.cxx b/src/OpenGl/OpenGl_togl_redraw.cxx index 0b52495917..dfbbce6e0f 100755 --- a/src/OpenGl/OpenGl_togl_redraw.cxx +++ b/src/OpenGl/OpenGl_togl_redraw.cxx @@ -95,6 +95,7 @@ call_togl_redraw call_togl_redraw_layer2d (aview, anunderlayer); } call_func_redraw_all_structs_proc (aview->WsId); + call_subr_displayCB (aview, OCC_REDRAW_WINDOW | OCC_PRE_OVERLAY); if (anoverlayer->ptrLayer) { call_togl_redraw_layer2d (aview, anoverlayer); @@ -172,6 +173,7 @@ call_togl_redraw_area call_togl_redraw_layer2d (aview, anunderlayer); } call_func_redraw_all_structs_proc (aview->WsId); + call_subr_displayCB (aview, OCC_REDRAW_WINDOWAREA | OCC_PRE_OVERLAY); if (anoverlayer->ptrLayer) { call_togl_redraw_layer2d (aview, anoverlayer); diff --git a/src/OpenGl/OpenGl_txgl.cxx b/src/OpenGl/OpenGl_txgl.cxx index b94f44b714..6bcbff0927 100755 --- a/src/OpenGl/OpenGl_txgl.cxx +++ b/src/OpenGl/OpenGl_txgl.cxx @@ -302,7 +302,6 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ ( /* recover display lists from dead_ctx, then destroy it */ ctx = glXCreateContext( disp, vis, dead_ctx, GL_TRUE ); glXDestroyContext(dead_dpy, dead_ctx); - dead_ctx = 0; } else if (previous_ctx == 0) { ctx = glXCreateContext( disp, vis, NULL, GL_TRUE ); } else { @@ -311,9 +310,16 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ ( } previous_ctx = ctx; - if( !ctx) return TFailure; + if( ctx ) + OpenGl_ResourceCleaner::GetInstance()->AppendContext( ctx, true ); - OpenGl_ResourceCleaner::GetInstance()->AppendContext( ctx, true ); + // remove the dead_ctx for ResourceCleaner after appending shared ctx + if (dead_ctx) { + OpenGl_ResourceCleaner::GetInstance()->RemoveContext(dead_ctx); + dead_ctx = 0; + } + + if( !ctx) return TFailure; cmap = XCreateColormap( disp, par, vis->visual, AllocNone ); @@ -783,7 +789,6 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ ( /* FSXXX sync necessary if non-direct rendering */ glXWaitGL(); - OpenGl_ResourceCleaner::GetInstance()->RemoveContext( ctx ); _Txgl_Map.UnBind( win ); if (previous_ctx == ctx) { @@ -800,12 +805,14 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ ( * losing any shared display lists (fonts...) */ if (previous_ctx) { + OpenGl_ResourceCleaner::GetInstance()->RemoveContext(ctx); glXDestroyContext(disp, ctx); } else { dead_ctx = ctx; dead_dpy = disp; } } else { + OpenGl_ResourceCleaner::GetInstance()->RemoveContext(ctx); glXDestroyContext(disp, ctx); }