1 // Created on: 2011-07-13
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2013 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <OpenGl_AspectText.hxx>
17 #include <OpenGl_GlCore11.hxx>
18 #include <OpenGl_GraphicDriver.hxx>
19 #include <OpenGl_ShaderManager.hxx>
20 #include <OpenGl_ShaderProgram.hxx>
21 #include <OpenGl_ShaderStates.hxx>
22 #include <OpenGl_Text.hxx>
23 #include <OpenGl_Workspace.hxx>
24 #include <OpenGl_View.hxx>
26 #include <Font_FontMgr.hxx>
27 #include <Graphic3d_TransformUtils.hxx>
28 #include <TCollection_HAsciiString.hxx>
36 static const GLdouble THE_IDENTITY_MATRIX[16] =
45 static char const* TheFamily[] = {"Helvetica", "Courier", "Times"};
46 static char const* TheItalic[] = {"Oblique", "Oblique", "Italic"};
47 static char const* TheBase[] = {"", "", "-Roman"};
49 //! Convert font name used for rendering to some "good" font names
50 //! that produce good vector text.
51 static void getGL2PSFontName (const char* theSrcFont,
54 if (strstr (theSrcFont, "Symbol"))
56 sprintf (thePsFont, "%s", "Symbol");
59 else if (strstr (theSrcFont, "ZapfDingbats"))
61 sprintf (thePsFont, "%s", "WingDings");
67 bool isItalic = false;
68 if (strstr (theSrcFont, "Courier"))
72 else if (strstr (theSrcFont, "Times"))
77 if (strstr (theSrcFont, "Bold"))
81 if (strstr (theSrcFont, "Italic")
82 || strstr (theSrcFont, "Oblique"))
91 sprintf (thePsFont, "%s-Bold%s", TheFamily[aFontId], TheItalic[aFontId]);
95 sprintf (thePsFont, "%s-Bold", TheFamily[aFontId]);
100 sprintf (thePsFont, "%s-%s", TheFamily[aFontId], TheItalic[aFontId]);
104 sprintf (thePsFont, "%s%s", TheFamily[aFontId], TheBase[aFontId]);
108 static void exportText (const NCollection_String& theText,
109 const Standard_Boolean theIs2d,
110 const OpenGl_AspectText& theAspect,
111 const Standard_Integer theHeight)
115 getGL2PSFontName (theAspect.FontName().ToCString(), aPsFont);
117 #if !defined(GL_ES_VERSION_2_0)
120 glRasterPos2f (0.0f, 0.0f);
124 glRasterPos3f (0.0f, 0.0f, 0.0f);
128 glBitmap (1, 1, 0, 0, 0, 0, &aZero);
131 // Standard GL2PS's alignment isn't used, because it doesn't work correctly
132 // for all formats, therefore alignment is calculated manually relative
133 // to the bottom-left corner, which corresponds to the GL2PS_TEXT_BL value
134 gl2psTextOpt (theText.ToCString(), aPsFont, (GLshort)theHeight, GL2PS_TEXT_BL, theAspect.Angle());
140 // =======================================================================
141 // function : OpenGl_Text
143 // =======================================================================
144 OpenGl_Text::OpenGl_Text()
148 myScaleHeight (1.0f),
149 myPoint (0.0f, 0.0f, 0.0f),
153 myParams.Height = 10;
154 myParams.HAlign = Graphic3d_HTA_LEFT;
155 myParams.VAlign = Graphic3d_VTA_BOTTOM;
158 // =======================================================================
159 // function : OpenGl_Text
161 // =======================================================================
162 OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
163 const OpenGl_Vec3& thePoint,
164 const OpenGl_TextParam& theParams)
168 myScaleHeight (1.0f),
169 myExportHeight (1.0f),
170 myParams (theParams),
179 // =======================================================================
180 // function : OpenGl_Text
182 // =======================================================================
183 OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
184 const gp_Ax2& theOrientation,
185 const OpenGl_TextParam& theParams)
190 myExportHeight (1.0),
191 myParams (theParams),
194 myOrientation (theOrientation),
197 const gp_Pnt& aPoint = theOrientation.Location();
198 myPoint = OpenGl_Vec3 (static_cast<Standard_ShortReal> (aPoint.X()),
199 static_cast<Standard_ShortReal> (aPoint.Y()),
200 static_cast<Standard_ShortReal> (aPoint.Z()));
203 // =======================================================================
204 // function : SetPosition
206 // =======================================================================
207 void OpenGl_Text::SetPosition (const OpenGl_Vec3& thePoint)
212 // =======================================================================
213 // function : SetFontSize
215 // =======================================================================
216 void OpenGl_Text::SetFontSize (const Handle(OpenGl_Context)& theCtx,
217 const Standard_Integer theFontSize)
219 if (myParams.Height != theFontSize)
221 Release (theCtx.operator->());
223 myParams.Height = theFontSize;
226 // =======================================================================
229 // =======================================================================
230 void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
231 const Standard_Utf8Char* theText,
232 const OpenGl_Vec3& thePoint)
234 releaseVbos (theCtx.operator->());
237 myString.FromUnicode (theText);
240 // =======================================================================
243 // =======================================================================
244 void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
245 const Standard_Utf8Char* theText,
246 const OpenGl_Vec3& thePoint,
247 const OpenGl_TextParam& theParams)
249 if (myParams.Height != theParams.Height)
251 Release (theCtx.operator->());
255 releaseVbos (theCtx.operator->());
258 myParams = theParams;
260 myString.FromUnicode (theText);
263 // =======================================================================
266 // =======================================================================
267 void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
268 const TCollection_ExtendedString& theText,
269 const OpenGl_Vec2& thePoint,
270 const OpenGl_TextParam& theParams)
272 if (myParams.Height != theParams.Height)
274 Release (theCtx.operator->());
278 releaseVbos (theCtx.operator->());
281 myParams = theParams;
282 myPoint.xy() = thePoint;
284 myString.FromUnicode ((Standard_Utf16Char* )theText.ToExtString());
287 // =======================================================================
288 // function : ~OpenGl_Text
290 // =======================================================================
291 OpenGl_Text::~OpenGl_Text()
296 // =======================================================================
297 // function : releaseVbos
299 // =======================================================================
300 void OpenGl_Text::releaseVbos (OpenGl_Context* theCtx)
302 for (Standard_Integer anIter = 0; anIter < myVertsVbo.Length(); ++anIter)
304 Handle(OpenGl_VertexBuffer)& aVerts = myVertsVbo.ChangeValue (anIter);
305 Handle(OpenGl_VertexBuffer)& aTCrds = myTCrdsVbo.ChangeValue (anIter);
309 theCtx->DelayedRelease (aVerts);
310 theCtx->DelayedRelease (aTCrds);
320 // =======================================================================
321 // function : Release
323 // =======================================================================
324 void OpenGl_Text::Release (OpenGl_Context* theCtx)
326 releaseVbos (theCtx);
327 if (!myFont.IsNull())
329 Handle(OpenGl_Context) aCtx = theCtx;
330 const TCollection_AsciiString aKey = myFont->ResourceKey();
333 aCtx->ReleaseResource (aKey, Standard_True);
337 // =======================================================================
338 // function : StringSize
340 // =======================================================================
341 void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
342 const NCollection_String& theText,
343 const OpenGl_AspectText& theTextAspect,
344 const OpenGl_TextParam& theParams,
345 Standard_ShortReal& theWidth,
346 Standard_ShortReal& theAscent,
347 Standard_ShortReal& theDescent)
352 const TCollection_AsciiString aFontKey = FontKey (theTextAspect, theParams.Height);
353 Handle(OpenGl_Font) aFont = FindFont (theCtx, theTextAspect, theParams.Height, aFontKey);
354 if (aFont.IsNull() || !aFont->IsValid())
359 theAscent = aFont->Ascender();
360 theDescent = aFont->Descender();
362 GLfloat aWidth = 0.0f;
363 for (NCollection_Utf8Iter anIter = theText.Iterator(); *anIter != 0;)
365 const Standard_Utf32Char aCharThis = *anIter;
366 const Standard_Utf32Char aCharNext = *++anIter;
368 if (aCharThis == '\x0D' // CR (carriage return)
369 || aCharThis == '\a' // BEL (alarm)
370 || aCharThis == '\f' // FF (form feed) NP (new page)
371 || aCharThis == '\b' // BS (backspace)
372 || aCharThis == '\v') // VT (vertical tab)
374 continue; // skip unsupported carriage control codes
376 else if (aCharThis == '\x0A') // LF (line feed, new line)
378 theWidth = Max (theWidth, aWidth);
382 else if (aCharThis == ' ')
384 aWidth += aFont->AdvanceX (aCharThis, aCharNext);
387 else if (aCharThis == '\t')
389 aWidth += aFont->AdvanceX (' ', aCharNext) * 8.0f;
393 aWidth += aFont->AdvanceX (aCharThis, aCharNext);
395 theWidth = Max (theWidth, aWidth);
397 Handle(OpenGl_Context) aCtx = theCtx;
399 aCtx->ReleaseResource (aFontKey, Standard_True);
402 // =======================================================================
405 // =======================================================================
406 void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
408 const OpenGl_AspectText* aTextAspect = theWorkspace->AspectText (Standard_True);
409 const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture();
410 const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
412 // Bind custom shader program or generate default version
413 if (aCtx->core20fwd != NULL)
415 aCtx->ShaderManager()->BindProgram (
416 aTextAspect, aTextAspect->ShaderProgramRes (aCtx));
419 myOrientationMatrix = theWorkspace->ActiveView()->Camera()->OrientationMatrix();
420 myProjMatrix.Convert (aCtx->ProjectionState.Current());
422 // use highlight color or colors from aspect
423 if (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT)
425 render (theWorkspace->PrinterContext(),
428 *theWorkspace->HighlightColor,
429 *theWorkspace->HighlightColor);
433 render (theWorkspace->PrinterContext(),
436 aTextAspect->Color(),
437 aTextAspect->SubtitleColor());
440 aCtx->BindProgram (NULL);
443 if (!aPrevTexture.IsNull())
445 theWorkspace->EnableTexture (aPrevTexture);
448 // restore Z buffer settings
449 if (theWorkspace->UseZBuffer())
451 glEnable (GL_DEPTH_TEST);
455 // =======================================================================
458 // =======================================================================
459 void OpenGl_Text::Render (const Handle(OpenGl_PrinterContext)& thePrintCtx,
460 const Handle(OpenGl_Context)& theCtx,
461 const OpenGl_AspectText& theTextAspect) const
463 render (thePrintCtx, theCtx, theTextAspect, theTextAspect.Color(), theTextAspect.SubtitleColor());
466 // =======================================================================
467 // function : setupMatrix
469 // =======================================================================
470 void OpenGl_Text::setupMatrix (const Handle(OpenGl_PrinterContext)& thePrintCtx,
471 const Handle(OpenGl_Context)& theCtx,
472 const OpenGl_AspectText& theTextAspect,
473 const OpenGl_Vec3 theDVec) const
475 OpenGl_Mat4d aModViewMat;
476 OpenGl_Mat4d aProjectMat;
480 aProjectMat = myProjMatrix * myOrientationMatrix;
484 aProjectMat = myProjMatrix;
489 Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, myPoint.x() + theDVec.x(), myPoint.y() + theDVec.y(), 0.f);
490 Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, 1.f, -1.f, 1.f);
491 Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Angle(), 0.f, 0.f, 1.f);
495 // align coordinates to the nearest integer
496 // to avoid extra interpolation issues
497 GLdouble anObjX, anObjY, anObjZ;
498 Graphic3d_TransformUtils::UnProject<Standard_Real> (std::floor (myWinX + theDVec.x()),
499 std::floor (myWinY + theDVec.y()),
500 myWinZ + theDVec.z(),
501 OpenGl_Mat4d::Map (THE_IDENTITY_MATRIX),
502 OpenGl_Mat4d::Map (aProjectMat),
510 const gp_Dir& aVectorDir = myOrientation.XDirection();
511 const gp_Dir& aVectorUp = myOrientation.Direction();
512 const gp_Dir& aVectorRight = myOrientation.YDirection();
514 aModViewMat.SetColumn (3, OpenGl_Vec3d (anObjX, anObjY, anObjZ));
515 aModViewMat.SetColumn (2, OpenGl_Vec3d (aVectorUp.X(), aVectorUp.Y(), aVectorUp.Z()));
516 aModViewMat.SetColumn (1, OpenGl_Vec3d (aVectorRight.X(), aVectorRight.Y(), aVectorRight.Z()));
517 aModViewMat.SetColumn (0, OpenGl_Vec3d (aVectorDir.X(), aVectorDir.Y(), aVectorDir.Z()));
521 Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
522 Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Angle(), 0.0, 0.0, 1.0);
525 if (!theTextAspect.IsZoomable())
528 // if the context has assigned printer context, use it's parameters
529 if (!thePrintCtx.IsNull())
531 // get printing scaling in x and y dimensions
532 GLfloat aTextScalex = 1.0f, aTextScaley = 1.0f;
533 thePrintCtx->GetScale (aTextScalex, aTextScaley);
535 // text should be scaled in all directions with same
536 // factor to save its proportions, so use height (y) scaling
537 // as it is better for keeping text/3d graphics proportions
538 Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, aTextScaley, aTextScaley, aTextScaley);
541 Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, myScaleHeight, myScaleHeight, myScaleHeight);
545 theCtx->WorldViewState.SetCurrent<Standard_Real> (aModViewMat);
546 theCtx->ApplyWorldViewMatrix();
550 theCtx->ProjectionState.SetCurrent<Standard_Real> (aProjectMat);
551 theCtx->ApplyProjectionMatrix();
554 if (!theCtx->ActiveProgram().IsNull())
556 // Upload updated state to shader program
557 theCtx->ShaderManager()->PushState (theCtx->ActiveProgram());
561 // =======================================================================
562 // function : drawText
564 // =======================================================================
566 void OpenGl_Text::drawText (const Handle(OpenGl_PrinterContext)& ,
567 const Handle(OpenGl_Context)& theCtx,
569 const OpenGl_AspectText& theTextAspect) const
571 const OpenGl_AspectText& ) const
575 if (theCtx->IsFeedback())
577 // position of the text and alignment is calculated by transformation matrix
578 exportText (myString, myIs2d, theTextAspect, (Standard_Integer )myExportHeight);
583 if (myVertsVbo.Length() != myTextures.Length()
584 || myTextures.IsEmpty())
589 for (Standard_Integer anIter = 0; anIter < myTextures.Length(); ++anIter)
591 const GLuint aTexId = myTextures.Value (anIter);
592 glBindTexture (GL_TEXTURE_2D, aTexId);
594 const Handle(OpenGl_VertexBuffer)& aVerts = myVertsVbo.Value (anIter);
595 const Handle(OpenGl_VertexBuffer)& aTCrds = myTCrdsVbo.Value (anIter);
596 aVerts->BindAttribute (theCtx, Graphic3d_TOA_POS);
597 aTCrds->BindAttribute (theCtx, Graphic3d_TOA_UV);
599 glDrawArrays (GL_TRIANGLES, 0, GLsizei(aVerts->GetElemsNb()));
601 aTCrds->UnbindAttribute (theCtx, Graphic3d_TOA_UV);
602 aVerts->UnbindAttribute (theCtx, Graphic3d_TOA_POS);
604 glBindTexture (GL_TEXTURE_2D, 0);
607 // =======================================================================
608 // function : FontKey
610 // =======================================================================
611 TCollection_AsciiString OpenGl_Text::FontKey (const OpenGl_AspectText& theAspect,
612 const Standard_Integer theHeight)
614 const Font_FontAspect anAspect = (theAspect.FontAspect() != Font_FA_Undefined) ? theAspect.FontAspect() : Font_FA_Regular;
615 return theAspect.FontName()
616 + TCollection_AsciiString(":") + Standard_Integer(anAspect)
617 + TCollection_AsciiString(":") + theHeight;
620 // =======================================================================
621 // function : FindFont
623 // =======================================================================
624 Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
625 const OpenGl_AspectText& theAspect,
626 const Standard_Integer theHeight,
627 const TCollection_AsciiString theKey)
629 Handle(OpenGl_Font) aFont;
632 return aFont; // invalid parameters
635 if (!theCtx->GetResource (theKey, aFont))
637 Handle(Font_FontMgr) aFontMgr = Font_FontMgr::GetInstance();
638 const Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (theAspect.FontName());
639 const Font_FontAspect anAspect = (theAspect.FontAspect() != Font_FA_Undefined) ? theAspect.FontAspect() : Font_FA_Regular;
640 Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (aFontName, anAspect, theHeight);
641 Handle(Font_FTFont) aFontFt;
642 if (!aRequestedFont.IsNull())
644 aFontFt = new Font_FTFont (NULL);
646 if (aFontFt->Init (aRequestedFont->FontPath()->ToCString(), theHeight))
648 aFont = new OpenGl_Font (aFontFt, theKey);
649 if (!aFont->Init (theCtx))
651 TCollection_ExtendedString aMsg;
653 aMsg += theAspect.FontName();
654 aMsg += "' - initialization of GL resources has failed!";
655 theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_ERROR_ARB, 0, GL_DEBUG_SEVERITY_HIGH_ARB, aMsg);
657 aFont->Release (theCtx.operator->());
658 aFont = new OpenGl_Font (aFontFt, theKey);
663 TCollection_ExtendedString aMsg;
665 aMsg += theAspect.FontName();
666 aMsg += "' is broken or has incompatible format! File path: ";
667 aMsg += aRequestedFont->FontPath()->ToCString();
668 theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_ERROR_ARB, 0, GL_DEBUG_SEVERITY_HIGH_ARB, aMsg);
670 aFont = new OpenGl_Font (aFontFt, theKey);
675 TCollection_ExtendedString aMsg;
677 aMsg += theAspect.FontName();
678 aMsg += "' is not found in the system!";
679 theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_ERROR_ARB, 0, GL_DEBUG_SEVERITY_HIGH_ARB, aMsg);
680 aFont = new OpenGl_Font (aFontFt, theKey);
683 theCtx->ShareResource (theKey, aFont);
688 // =======================================================================
691 // =======================================================================
692 void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx,
693 const Handle(OpenGl_Context)& theCtx,
694 const OpenGl_AspectText& theTextAspect,
695 const TEL_COLOUR& theColorText,
696 const TEL_COLOUR& theColorSubs) const
698 if (myString.IsEmpty())
703 const TCollection_AsciiString aFontKey = FontKey (theTextAspect, myParams.Height);
705 && !myFont->ResourceKey().IsEqual (aFontKey))
708 const_cast<OpenGl_Text* > (this)->Release (theCtx.operator->());
713 myFont = FindFont (theCtx, theTextAspect, myParams.Height, aFontKey);
715 if (!myFont->WasInitialized())
720 if (myTextures.IsEmpty())
722 Font_TextFormatter aFormatter;
723 aFormatter.SetupAlignment (myParams.HAlign, myParams.VAlign);
726 aFormatter.Append (myString, *myFont->FTFont());
729 OpenGl_TextBuilder aBuilder;
730 aBuilder.Perform (aFormatter,
732 *myFont.operator->(),
737 aFormatter.BndBox (myBndBox);
740 if (myTextures.IsEmpty())
745 myExportHeight = 1.0f;
746 myScaleHeight = 1.0f;
748 theCtx->WorldViewState.Push();
750 myModelMatrix.Convert (theCtx->WorldViewState.Current() * theCtx->ModelWorldState.Current());
754 glGetIntegerv (GL_VIEWPORT, myViewport);
756 Graphic3d_TransformUtils::Project<Standard_Real> (myPoint.x(),
766 // compute scale factor for constant text height
768 Graphic3d_TransformUtils::UnProject<Standard_Real> (myWinX,
771 OpenGl_Mat4d::Map (THE_IDENTITY_MATRIX),
779 const GLdouble h = (GLdouble )myFont->FTFont()->PointSize();
780 Graphic3d_TransformUtils::UnProject<Standard_Real> (myWinX,
783 OpenGl_Mat4d::Map (THE_IDENTITY_MATRIX),
790 myScaleHeight = (y2 - y1) / h;
791 if (theTextAspect.IsZoomable())
793 myExportHeight = (float )h;
796 myExportHeight = (float )myFont->FTFont()->PointSize() / myExportHeight;
798 #if !defined(GL_ES_VERSION_2_0)
799 if (theCtx->core11 != NULL)
801 glDisable (GL_LIGHTING);
807 || theTextAspect.StyleType() == Aspect_TOST_ANNOTATION)
809 glDisable (GL_DEPTH_TEST);
812 if (theCtx->core15fwd != NULL)
814 theCtx->core15fwd->glActiveTexture (GL_TEXTURE0);
816 #if !defined(GL_ES_VERSION_2_0)
817 // activate texture unit
818 GLint aTexEnvParam = GL_REPLACE;
819 if (theCtx->core11 != NULL)
822 glAlphaFunc (GL_GEQUAL, 0.285f);
823 glEnable (GL_ALPHA_TEST);
825 glDisable (GL_TEXTURE_1D);
826 glEnable (GL_TEXTURE_2D);
827 glGetTexEnviv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &aTexEnvParam);
828 if (aTexEnvParam != GL_REPLACE)
830 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
837 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
840 switch (theTextAspect.DisplayType())
842 case Aspect_TODT_BLEND:
844 #if !defined(GL_ES_VERSION_2_0)
845 glEnable (GL_COLOR_LOGIC_OP);
850 case Aspect_TODT_SUBTITLE:
852 #if !defined(GL_ES_VERSION_2_0)
853 if (theCtx->core11 != NULL)
855 theCtx->core11->glColor3fv (theColorSubs.rgb);
856 setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.00001f));
858 glBindTexture (GL_TEXTURE_2D, 0);
860 glVertex2f (myBndBox.Left, myBndBox.Top);
861 glVertex2f (myBndBox.Right, myBndBox.Top);
862 glVertex2f (myBndBox.Right, myBndBox.Bottom);
863 glVertex2f (myBndBox.Left, myBndBox.Bottom);
869 case Aspect_TODT_DEKALE:
871 theCtx->SetColor4fv (*(const OpenGl_Vec4* )theColorSubs.rgb);
872 setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (+1.0f, +1.0f, 0.00001f));
873 drawText (thePrintCtx, theCtx, theTextAspect);
874 setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (-1.0f, -1.0f, 0.00001f));
875 drawText (thePrintCtx, theCtx, theTextAspect);
876 setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (-1.0f, +1.0f, 0.00001f));
877 drawText (thePrintCtx, theCtx, theTextAspect);
878 setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (+1.0f, -1.0f, 0.00001f));
879 drawText (thePrintCtx, theCtx, theTextAspect);
882 case Aspect_TODT_DIMENSION:
883 case Aspect_TODT_NORMAL:
890 theCtx->SetColor4fv (*(const OpenGl_Vec4* )theColorText.rgb);
891 setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.0f));
892 drawText (thePrintCtx, theCtx, theTextAspect);
896 theCtx->ProjectionState.SetCurrent<Standard_Real> (myProjMatrix);
897 theCtx->ApplyProjectionMatrix();
900 #if !defined(GL_ES_VERSION_2_0)
901 if (theCtx->core11 != NULL)
903 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, aTexEnvParam);
907 if (theTextAspect.DisplayType() == Aspect_TODT_DIMENSION)
909 setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.00001f));
911 glDisable (GL_BLEND);
914 glDisable (GL_DEPTH_TEST);
916 #if !defined(GL_ES_VERSION_2_0)
917 if (theCtx->core11 != NULL)
919 glDisable (GL_TEXTURE_2D);
920 glDisable (GL_ALPHA_TEST);
923 glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
925 glClear (GL_STENCIL_BUFFER_BIT);
926 glEnable (GL_STENCIL_TEST);
927 glStencilFunc (GL_ALWAYS, 1, 0xFF);
928 glStencilOp (GL_KEEP, GL_KEEP, GL_REPLACE);
930 #if !defined(GL_ES_VERSION_2_0)
931 if (theCtx->core11 != NULL)
934 glVertex2f (myBndBox.Left, myBndBox.Top);
935 glVertex2f (myBndBox.Right, myBndBox.Top);
936 glVertex2f (myBndBox.Right, myBndBox.Bottom);
937 glVertex2f (myBndBox.Left, myBndBox.Bottom);
942 glStencilFunc (GL_ALWAYS, 0, 0xFF);
944 glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
947 // reset OpenGL state
948 glDisable (GL_BLEND);
949 glDisable (GL_STENCIL_TEST);
950 #if !defined(GL_ES_VERSION_2_0)
951 if (theCtx->core11 != NULL)
953 glDisable (GL_ALPHA_TEST);
955 glDisable (GL_COLOR_LOGIC_OP);
958 // model view matrix was modified
959 theCtx->WorldViewState.Pop();
960 theCtx->ApplyModelViewMatrix();