1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

Merging OCC22105, OCC22354, OCC22150 , OCC22199 , OCC22391 and OCC22108

This commit is contained in:
bugmaster 2011-04-28 16:35:16 +00:00 committed by bugmaster
parent c3d894867d
commit d4c2114a1d
4 changed files with 63 additions and 15 deletions

View File

@ -55,6 +55,8 @@ static unsigned long vRand = 1L;
#include <OpenGl_tgl_funcs.hxx>
#include <OpenGl_LightBox.hxx>
#include <OpenGl_TextureBox.hxx>
#include <OpenGl_ResourceCleaner.hxx>
#include <OpenGl_ResourceVBO.hxx>
#include <InterfaceGraphic_PrimitiveArray.hxx>
#include <OpenGl_Memory.hxx>
#include <Standard.hxx>
@ -232,6 +234,10 @@ static void BuildVBO( CALL_DEF_PARRAY* p )
if( p->flagBufferVBO == VBO_OK )
clearRAMMemory(p);
//specify context for VBO resource
p->contextId = (Standard_Address)GET_GL_CONTEXT();
}
/*----------------------------------------------------------------------*/
@ -769,6 +775,21 @@ draw_array( call_def_parray p, Tint hflag,
static TStatus
ParrayDelete( TSM_ELEM_DATA data, Tint n, cmn_key *k )
{
call_def_parray p = (call_def_parray)data.pdata;
if( p->VBOEnabled == VBO_OK ) {
OpenGl_ResourceCleaner* resCleaner = OpenGl_ResourceCleaner::GetInstance();
if( p->bufferVBO[VBOEdges] )
resCleaner->AddResource( (GLCONTEXT)p->contextId, new OpenGl_ResourceVBO(p->bufferVBO[VBOEdges]) );
if( p->bufferVBO[VBOVertices] )
resCleaner->AddResource( (GLCONTEXT)p->contextId, new OpenGl_ResourceVBO(p->bufferVBO[VBOVertices]) );
if( p->bufferVBO[VBOVcolours] )
resCleaner->AddResource( (GLCONTEXT)p->contextId, new OpenGl_ResourceVBO(p->bufferVBO[VBOVcolours]) );
if( p->bufferVBO[VBOVnormals] )
resCleaner->AddResource( (GLCONTEXT)p->contextId, new OpenGl_ResourceVBO(p->bufferVBO[VBOVnormals]) );
if( p->bufferVBO[VBOVtexels] )
resCleaner->AddResource( (GLCONTEXT)p->contextId, new OpenGl_ResourceVBO(p->bufferVBO[VBOVtexels]) );
}
return TSuccess;
}

View File

@ -300,12 +300,6 @@ void OpenGl_TextRender::RenderText ( char* str, GLuint base, int is2d, GLfloat x
TsmGetAttri( 1, &keyZoom );
zoom = keyZoom.data.ldata;
CMN_KEY keyfontName;
keyfontName.id = TelTextFont;//This flag responding about TextFontName
TsmGetAttri( 1, &keyfontName );
char *fontName = new char[strlen((char*)keyfontName.data.pdata) + 1];
strcpy(fontName,(char*)keyfontName.data.pdata);
OpenGl_TextRender* textRender = OpenGl_TextRender::instance();
int vh = 2 ;
int vv = 2 ;
@ -402,10 +396,17 @@ void OpenGl_TextRender::RenderText ( char* str, GLuint base, int is2d, GLfloat x
if ( renderMode == GL_FEEDBACK )
{
#ifdef HAVE_GL2PS
CMN_KEY keyfontName;
keyfontName.id = TelTextFont;//This flag responding about TextFontName
TsmGetAttri( 1, &keyfontName );
char *fontName = new char[strlen((char*)keyfontName.data.pdata) + 1];
strcpy(fontName,(char*)keyfontName.data.pdata);
export_h = (GLdouble)fnt->FaceSize() / export_h;
int aligment = alignmentforgl2ps( vh, vv );
glPopMatrix();
ExportText( str, fontName, export_h, angle, aligment, x, y, z, is2d!=0 );
delete [] fontName;
#endif
}
else
@ -414,7 +415,6 @@ void OpenGl_TextRender::RenderText ( char* str, GLuint base, int is2d, GLfloat x
glPopMatrix();
}
glPopAttrib();
delete [] fontName;
return;
}

View File

@ -59,6 +59,7 @@ GLboolean g_fBitmap;
#include <OpenGl_tgl_funcs.hxx>
#include <OpenGl_tgl_subrvis.hxx>
#include <OpenGl_FrameBuffer.hxx>
#include <OpenGl_ResourceCleaner.hxx>
#include <InterfaceGraphic_Graphic3d.hxx>
#include <InterfaceGraphic_Visual3d.hxx>
@ -86,9 +87,9 @@ call_togl_redraw
aFrameBuffer->BindBuffer();
swap = 0; // no need to swap buffers
}
OpenGl_ResourceCleaner::GetInstance()->Cleanup();
call_func_redraw_all_structs_begin (aview->WsId);
call_togl_setplane( aview ); /* apl - OCC22108: update clipping planes */
call_togl_setplane( aview );
if (anunderlayer->ptrLayer)
{
call_togl_redraw_layer2d (aview, anunderlayer);
@ -163,8 +164,9 @@ call_togl_redraw_area
glScissor ((GLint )x,
(GLint )((int )aview->DefWindow.dy - (y + height)),
(GLsizei )width, (GLsizei )height);
OpenGl_ResourceCleaner::GetInstance()->Cleanup();
call_func_redraw_all_structs_begin (aview->WsId);
call_togl_setplane( aview ); /* apl - OCC22108: update clipping planes */
call_togl_setplane( aview );
if (anunderlayer->ptrLayer)
{
call_togl_redraw_layer2d (aview, anunderlayer);

View File

@ -83,6 +83,7 @@ Old code resulted in crashes on some ATI Radeon cards under Linux.
#include <stdio.h>
#include <OpenGl_Memory.hxx>
#include <OpenGl_ResourceCleaner.hxx>
#ifdef WNT
@ -312,6 +313,8 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
if( !ctx) return TFailure;
OpenGl_ResourceCleaner::GetInstance()->AppendContext( ctx, true );
cmap = XCreateColormap( disp, par, vis->visual, AllocNone );
color.red = (unsigned short) (bgcolr * 0xFFFF);
@ -451,12 +454,29 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
return 0;
}
if (previous_ctx == 0 )
{
previous_ctx = hte -> hGLRC;
} else
wglShareLists(previous_ctx, hte -> hGLRC);
Standard_Boolean isShared = Standard_True;
if (previous_ctx == 0 )
previous_ctx = hte -> hGLRC;
// if we already have some shared context
else
{
// try to share context with one from resource cleaner list
GLCONTEXT shareCtx = OpenGl_ResourceCleaner::GetInstance()->GetSharedContext();
if (shareCtx != 0)
isShared = (Standard_Boolean)wglShareLists(shareCtx, hte -> hGLRC);
else
{
isShared = (Standard_Boolean)wglShareLists(previous_ctx, hte -> hGLRC);
// add shared previous_ctx to a control list if it's not there
if (isShared)
OpenGl_ResourceCleaner::GetInstance()->AppendContext(previous_ctx, isShared);
}
}
// add the context to OpenGl_ResourceCleaner control list
OpenGl_ResourceCleaner::GetInstance()->AppendContext( hte -> hGLRC, isShared);
_Txgl_Map.Bind( (Tint)par, hte );
return par;
@ -763,6 +783,7 @@ __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) {
@ -811,12 +832,16 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
if ( --hte -> nUsed == 0 )
{
OpenGl_ResourceCleaner::GetInstance()->RemoveContext( hte -> hGLRC );
#ifdef OCC954
if ( wglGetCurrentContext() != NULL )
#endif
wglDeleteContext ( hte -> hGLRC );
ReleaseDC ( win, hte -> hDC );
_Txgl_Map.UnBind( (Tint ) win );
if( _Txgl_Map.Size() == 0 ) {
previous_ctx = 0;
}
delete hte;
}