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

OCC22354 Bug in Overlay Text rendering

This commit is contained in:
APL 2011-04-28 15:56:08 +00:00 committed by bugmaster
parent 2de462d4eb
commit 256d432045
4 changed files with 29 additions and 18 deletions

View File

@ -310,7 +310,8 @@ int OpenGl_FontMgr::request_font( const Handle(TCollection_HAsciiString)& fontNa
return -1;
}
void OpenGl_FontMgr::render_text( const Standard_Integer id, const char* text)
void OpenGl_FontMgr::render_text( const Standard_Integer id, const char* text,
const Standard_Boolean is2d )
{
#ifdef TRACE
cout << "TKOpenGl::render_text\n"
@ -329,8 +330,13 @@ void OpenGl_FontMgr::render_text( const Standard_Integer id, const char* text)
if( !enableTexture )
glEnable(GL_TEXTURE_2D);
if( !enableDepthTest )
if ( !is2d ) {
if ( !enableDepthTest )
glEnable(GL_DEPTH_TEST);
}
else if ( enableDepthTest ) {
glDisable(GL_DEPTH_TEST);
}
GLint* param = new GLint;
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param);
@ -357,8 +363,8 @@ void OpenGl_FontMgr::render_text( const Standard_Integer id, const char* text)
}
void OpenGl_FontMgr::render_text( const char* text){
render_text( _CurrentFontId, text );
void OpenGl_FontMgr::render_text( const char* text, const Standard_Boolean is2d ){
render_text( _CurrentFontId, text, is2d );
}
@ -371,7 +377,6 @@ Standard_ShortReal OpenGl_FontMgr::computeWidth( const Standard_Integer id, cons
return 0.f;
OGLFont_Cache cache = _FontCache.Find( id );
GLenum err = glGetError();
Standard_ShortReal w = cache.Font->Advance( str );

View File

@ -28,10 +28,11 @@ public:
const Standard_Integer fontHeight );
void render_text( const Standard_Integer id,
const char* text );
const char* text,
const Standard_Boolean is2d = 0 );
//render text by last requested font
void render_text( const char* text );
void render_text( const char* text, const Standard_Boolean is2d = 0 );
//returns direct access to FTGL font
//Warning: don't change font pointer.

View File

@ -269,6 +269,8 @@ void OpenGl_TextRender::RenderText ( char* str, GLuint base, int is2d, GLfloat x
GLdouble xdis = 0., ydis = 0.;
GLint renderMode;
// FTFont changes texture state when it renders and computes size for the text
glPushAttrib(GL_TEXTURE_BIT);
StringSize(str, &widthFont, &ascentFont, &descentFont );
GLdouble identityMatrix[4][4] =
@ -298,6 +300,12 @@ 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 ;
@ -335,8 +343,10 @@ void OpenGl_TextRender::RenderText ( char* str, GLuint base, int is2d, GLfloat x
OpenGl_FontMgr* mgr = OpenGl_FontMgr::instance();
const FTFont* fnt = mgr->fontById( curFont );
if ( !fnt )
if ( !fnt ) {
glPopAttrib();
return;
}
float export_h = 1.;
@ -392,24 +402,19 @@ 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
{
mgr->render_text( curFont, str );
mgr->render_text( curFont, str, is2d );
glPopMatrix();
}
glPopAttrib();
delete [] fontName;
return;
}

View File

@ -336,7 +336,7 @@ call_togl_redraw_layer2d (
#endif
glPushAttrib (
GL_LIGHTING_BIT | GL_LINE_BIT | GL_POLYGON_BIT |
GL_DEPTH_BUFFER_BIT | GL_CURRENT_BIT);
GL_DEPTH_BUFFER_BIT | GL_CURRENT_BIT | GL_TEXTURE_BIT );
glDisable (GL_DEPTH_TEST);
glCallList (alayer->ptrLayer->listIndex);