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_Utils.hxx>
24 #include <OpenGl_Workspace.hxx>
26 #include <Font_FontMgr.hxx>
27 #include <TCollection_HAsciiString.hxx>
35 static const GLdouble THE_IDENTITY_MATRIX[16] =
44 static char const* TheFamily[] = {"Helvetica", "Courier", "Times"};
45 static char const* TheItalic[] = {"Oblique", "Oblique", "Italic"};
46 static char const* TheBase[] = {"", "", "-Roman"};
48 //! Convert font name used for rendering to some "good" font names
49 //! that produce good vector text.
50 static void getGL2PSFontName (const char* theSrcFont,
53 if (strstr (theSrcFont, "Symbol"))
55 sprintf (thePsFont, "%s", "Symbol");
58 else if (strstr (theSrcFont, "ZapfDingbats"))
60 sprintf (thePsFont, "%s", "WingDings");
66 bool isItalic = false;
67 if (strstr (theSrcFont, "Courier"))
71 else if (strstr (theSrcFont, "Times"))
76 if (strstr (theSrcFont, "Bold"))
80 if (strstr (theSrcFont, "Italic")
81 || strstr (theSrcFont, "Oblique"))
90 sprintf (thePsFont, "%s-Bold%s", TheFamily[aFontId], TheItalic[aFontId]);
94 sprintf (thePsFont, "%s-Bold", TheFamily[aFontId]);
99 sprintf (thePsFont, "%s-%s", TheFamily[aFontId], TheItalic[aFontId]);
103 sprintf (thePsFont, "%s%s", TheFamily[aFontId], TheBase[aFontId]);
107 static void exportText (const NCollection_String& theText,
108 const Standard_Boolean theIs2d,
109 const OpenGl_AspectText& theAspect,
110 const Standard_Integer theHeight)
114 getGL2PSFontName (theAspect.FontName().ToCString(), aPsFont);
116 #if !defined(GL_ES_VERSION_2_0)
119 glRasterPos2f (0.0f, 0.0f);
123 glRasterPos3f (0.0f, 0.0f, 0.0f);
127 glBitmap (1, 1, 0, 0, 0, 0, &aZero);
130 // Standard GL2PS's alignment isn't used, because it doesn't work correctly
131 // for all formats, therefore alignment is calculated manually relative
132 // to the bottom-left corner, which corresponds to the GL2PS_TEXT_BL value
133 gl2psTextOpt (theText.ToCString(), aPsFont, (GLshort)theHeight, GL2PS_TEXT_BL, theAspect.Angle());
139 // =======================================================================
140 // function : OpenGl_Text
142 // =======================================================================
143 OpenGl_Text::OpenGl_Text()
147 myScaleHeight (1.0f),
148 myPoint (0.0f, 0.0f, 0.0f),
151 myParams.Height = 10;
152 myParams.HAlign = Graphic3d_HTA_LEFT;
153 myParams.VAlign = Graphic3d_VTA_BOTTOM;
156 // =======================================================================
157 // function : OpenGl_Text
159 // =======================================================================
160 OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
161 const OpenGl_Vec3& thePoint,
162 const OpenGl_TextParam& theParams)
166 myScaleHeight (1.0f),
167 myExportHeight (1.0f),
168 myParams (theParams),
176 // =======================================================================
177 // function : SetPosition
179 // =======================================================================
180 void OpenGl_Text::SetPosition (const OpenGl_Vec3& thePoint)
185 // =======================================================================
186 // function : SetFontSize
188 // =======================================================================
189 void OpenGl_Text::SetFontSize (const Handle(OpenGl_Context)& theCtx,
190 const Standard_Integer theFontSize)
192 if (myParams.Height != theFontSize)
194 Release (theCtx.operator->());
196 myParams.Height = theFontSize;
199 // =======================================================================
202 // =======================================================================
203 void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
204 const Standard_Utf8Char* theText,
205 const OpenGl_Vec3& thePoint)
207 releaseVbos (theCtx.operator->());
210 myString.FromUnicode (theText);
213 // =======================================================================
216 // =======================================================================
217 void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
218 const Standard_Utf8Char* theText,
219 const OpenGl_Vec3& thePoint,
220 const OpenGl_TextParam& theParams)
222 if (myParams.Height != theParams.Height)
224 Release (theCtx.operator->());
228 releaseVbos (theCtx.operator->());
231 myParams = theParams;
233 myString.FromUnicode (theText);
236 // =======================================================================
239 // =======================================================================
240 void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
241 const TCollection_ExtendedString& theText,
242 const OpenGl_Vec2& thePoint,
243 const OpenGl_TextParam& theParams)
245 if (myParams.Height != theParams.Height)
247 Release (theCtx.operator->());
251 releaseVbos (theCtx.operator->());
254 myParams = theParams;
255 myPoint.xy() = thePoint;
257 myString.FromUnicode ((Standard_Utf16Char* )theText.ToExtString());
260 // =======================================================================
261 // function : ~OpenGl_Text
263 // =======================================================================
264 OpenGl_Text::~OpenGl_Text()
269 // =======================================================================
270 // function : releaseVbos
272 // =======================================================================
273 void OpenGl_Text::releaseVbos (OpenGl_Context* theCtx)
275 for (Standard_Integer anIter = 0; anIter < myVertsVbo.Length(); ++anIter)
277 Handle(OpenGl_VertexBuffer)& aVerts = myVertsVbo.ChangeValue (anIter);
278 Handle(OpenGl_VertexBuffer)& aTCrds = myTCrdsVbo.ChangeValue (anIter);
282 theCtx->DelayedRelease (aVerts);
283 theCtx->DelayedRelease (aTCrds);
293 // =======================================================================
294 // function : Release
296 // =======================================================================
297 void OpenGl_Text::Release (OpenGl_Context* theCtx)
299 releaseVbos (theCtx);
300 if (!myFont.IsNull())
302 Handle(OpenGl_Context) aCtx = theCtx;
303 const TCollection_AsciiString aKey = myFont->ResourceKey();
306 aCtx->ReleaseResource (aKey, Standard_True);
310 // =======================================================================
311 // function : StringSize
313 // =======================================================================
314 void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
315 const NCollection_String& theText,
316 const OpenGl_AspectText& theTextAspect,
317 const OpenGl_TextParam& theParams,
318 Standard_ShortReal& theWidth,
319 Standard_ShortReal& theAscent,
320 Standard_ShortReal& theDescent)
325 const TCollection_AsciiString aFontKey = FontKey (theTextAspect, theParams.Height);
326 Handle(OpenGl_Font) aFont = FindFont (theCtx, theTextAspect, theParams.Height, aFontKey);
327 if (aFont.IsNull() || !aFont->IsValid())
332 theAscent = aFont->Ascender();
333 theDescent = aFont->Descender();
335 GLfloat aWidth = 0.0f;
336 for (NCollection_Utf8Iter anIter = theText.Iterator(); *anIter != 0;)
338 const Standard_Utf32Char aCharThis = *anIter;
339 const Standard_Utf32Char aCharNext = *++anIter;
341 if (aCharThis == '\x0D' // CR (carriage return)
342 || aCharThis == '\a' // BEL (alarm)
343 || aCharThis == '\f' // FF (form feed) NP (new page)
344 || aCharThis == '\b' // BS (backspace)
345 || aCharThis == '\v') // VT (vertical tab)
347 continue; // skip unsupported carriage control codes
349 else if (aCharThis == '\x0A') // LF (line feed, new line)
351 theWidth = Max (theWidth, aWidth);
355 else if (aCharThis == ' ')
357 aWidth += aFont->AdvanceX (aCharThis, aCharNext);
360 else if (aCharThis == '\t')
362 aWidth += aFont->AdvanceX (' ', aCharNext) * 8.0f;
366 aWidth += aFont->AdvanceX (aCharThis, aCharNext);
368 theWidth = Max (theWidth, aWidth);
370 Handle(OpenGl_Context) aCtx = theCtx;
372 aCtx->ReleaseResource (aFontKey, Standard_True);
375 // =======================================================================
378 // =======================================================================
379 void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
381 const OpenGl_AspectText* aTextAspect = theWorkspace->AspectText (Standard_True);
382 const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture();
383 const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
385 if (aCtx->IsGlGreaterEqual (2, 0))
387 const Handle(OpenGl_ShaderProgram)& aProgram = aTextAspect->ShaderProgramRes (aCtx);
388 aCtx->BindProgram (aProgram);
389 if (!aProgram.IsNull())
391 aProgram->ApplyVariables (aCtx);
393 const OpenGl_MaterialState* aMaterialState = aCtx->ShaderManager()->MaterialState (aProgram);
395 if (aMaterialState == NULL || aMaterialState->Aspect() != aTextAspect)
396 aCtx->ShaderManager()->UpdateMaterialStateTo (aProgram, aTextAspect);
398 aCtx->ShaderManager()->PushState (aProgram);
402 // use highlight color or colors from aspect
403 if (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT)
405 render (theWorkspace->PrinterContext(),
408 *theWorkspace->HighlightColor,
409 *theWorkspace->HighlightColor);
413 render (theWorkspace->PrinterContext(),
416 aTextAspect->Color(),
417 aTextAspect->SubtitleColor());
421 if (!aPrevTexture.IsNull())
423 theWorkspace->EnableTexture (aPrevTexture);
427 // =======================================================================
430 // =======================================================================
431 void OpenGl_Text::Render (const Handle(OpenGl_PrinterContext)& thePrintCtx,
432 const Handle(OpenGl_Context)& theCtx,
433 const OpenGl_AspectText& theTextAspect) const
435 render (thePrintCtx, theCtx, theTextAspect, theTextAspect.Color(), theTextAspect.SubtitleColor());
438 // =======================================================================
439 // function : setupMatrix
441 // =======================================================================
442 void OpenGl_Text::setupMatrix (const Handle(OpenGl_PrinterContext)& thePrintCtx,
443 const Handle(OpenGl_Context)& theCtx,
444 const OpenGl_AspectText& theTextAspect,
445 const OpenGl_Vec3 theDVec) const
448 #if !defined(GL_ES_VERSION_2_0)
450 OpenGl_Mat4d aModViewMat;
454 OpenGl_Utils::Translate<GLdouble> (aModViewMat, myPoint.x() + theDVec.x(), myPoint.y() + theDVec.y(), 0.f);
455 OpenGl_Utils::Scale<GLdouble> (aModViewMat, 1.f, -1.f, 1.f);
456 OpenGl_Utils::Rotate<GLdouble> (aModViewMat, theTextAspect.Angle(), 0.f, 0.f, 1.f);
460 // align coordinates to the nearest integer
461 // to avoid extra interpolation issues
462 GLdouble anObjX, anObjY, anObjZ;
463 OpenGl_Utils::UnProject<Standard_Real> (std::floor (myWinX + theDVec.x()),
464 std::floor (myWinY + theDVec.y()),
465 myWinZ + theDVec.z(),
466 OpenGl_Mat4d::Map (THE_IDENTITY_MATRIX),
467 OpenGl_Mat4d::Map (myProjMatrix),
473 OpenGl_Utils::Translate<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
474 OpenGl_Utils::Rotate<GLdouble> (aModViewMat, theTextAspect.Angle(), 0.0, 0.0, 1.0);
476 if (!theTextAspect.IsZoomable())
479 // if the context has assigned printer context, use it's parameters
480 if (!thePrintCtx.IsNull())
482 // get printing scaling in x and y dimensions
483 GLfloat aTextScalex = 1.0f, aTextScaley = 1.0f;
484 thePrintCtx->GetScale (aTextScalex, aTextScaley);
486 // text should be scaled in all directions with same
487 // factor to save its proportions, so use height (y) scaling
488 // as it is better for keeping text/3d graphics proportions
489 OpenGl_Utils::Scale<GLdouble> (aModViewMat, aTextScaley, aTextScaley, aTextScaley);
492 OpenGl_Utils::Scale<GLdouble> (aModViewMat, myScaleHeight, myScaleHeight, myScaleHeight);
496 theCtx->WorldViewState.SetCurrent<Standard_Real> (aModViewMat);
497 theCtx->ApplyWorldViewMatrix();
501 // =======================================================================
502 // function : drawText
504 // =======================================================================
506 void OpenGl_Text::drawText (const Handle(OpenGl_PrinterContext)& ,
507 const Handle(OpenGl_Context)& theCtx,
509 const OpenGl_AspectText& theTextAspect) const
511 const OpenGl_AspectText& ) const
515 if (theCtx->IsFeedback())
517 // position of the text and alignment is calculated by transformation matrix
518 exportText (myString, myIs2d, theTextAspect, (Standard_Integer )myExportHeight);
523 if (myVertsVbo.Length() != myTextures.Length()
524 || myTextures.IsEmpty())
529 for (Standard_Integer anIter = 0; anIter < myTextures.Length(); ++anIter)
531 const GLuint aTexId = myTextures.Value (anIter);
532 glBindTexture (GL_TEXTURE_2D, aTexId);
534 const Handle(OpenGl_VertexBuffer)& aVerts = myVertsVbo.Value (anIter);
535 const Handle(OpenGl_VertexBuffer)& aTCrds = myTCrdsVbo.Value (anIter);
536 aVerts->BindAttribute (theCtx, Graphic3d_TOA_POS);
537 aTCrds->BindAttribute (theCtx, Graphic3d_TOA_UV);
539 glDrawArrays (GL_TRIANGLES, 0, GLsizei(aVerts->GetElemsNb()));
541 aVerts->UnbindAttribute (theCtx, Graphic3d_TOA_UV);
542 aVerts->UnbindAttribute (theCtx, Graphic3d_TOA_POS);
544 glBindTexture (GL_TEXTURE_2D, 0);
547 // =======================================================================
548 // function : FontKey
550 // =======================================================================
551 TCollection_AsciiString OpenGl_Text::FontKey (const OpenGl_AspectText& theAspect,
552 const Standard_Integer theHeight)
554 const Font_FontAspect anAspect = (theAspect.FontAspect() != Font_FA_Undefined) ? theAspect.FontAspect() : Font_FA_Regular;
555 return theAspect.FontName()
556 + TCollection_AsciiString(":") + Standard_Integer(anAspect)
557 + TCollection_AsciiString(":") + theHeight;
560 // =======================================================================
561 // function : FindFont
563 // =======================================================================
564 Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
565 const OpenGl_AspectText& theAspect,
566 const Standard_Integer theHeight,
567 const TCollection_AsciiString theKey)
569 Handle(OpenGl_Font) aFont;
572 return aFont; // invalid parameters
575 if (!theCtx->GetResource (theKey, aFont))
577 Handle(Font_FontMgr) aFontMgr = Font_FontMgr::GetInstance();
578 const Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (theAspect.FontName());
579 const Font_FontAspect anAspect = (theAspect.FontAspect() != Font_FA_Undefined) ? theAspect.FontAspect() : Font_FA_Regular;
580 Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (aFontName, anAspect, theHeight);
581 if (aRequestedFont.IsNull())
586 Handle(Font_FTFont) aFontFt = new Font_FTFont (NULL);
587 if (!aFontFt->Init (aRequestedFont->FontPath()->ToCString(), theHeight))
592 Handle(OpenGl_Context) aCtx = theCtx;
593 #if !defined(GL_ES_VERSION_2_0)
594 glPushAttrib (GL_TEXTURE_BIT);
596 aFont = new OpenGl_Font (aFontFt, theKey);
597 if (!aFont->Init (aCtx))
600 //return aFont; // out of resources?
602 #if !defined(GL_ES_VERSION_2_0)
603 glPopAttrib(); // texture bit
606 aCtx->ShareResource (theKey, aFont);
611 // =======================================================================
614 // =======================================================================
615 void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx,
616 const Handle(OpenGl_Context)& theCtx,
617 const OpenGl_AspectText& theTextAspect,
618 const TEL_COLOUR& theColorText,
619 const TEL_COLOUR& theColorSubs) const
621 if (myString.IsEmpty())
626 const TCollection_AsciiString aFontKey = FontKey (theTextAspect, myParams.Height);
628 && !myFont->ResourceKey().IsEqual (aFontKey))
631 const_cast<OpenGl_Text* > (this)->Release (theCtx.operator->());
636 myFont = FindFont (theCtx, theTextAspect, myParams.Height, aFontKey);
643 if (myTextures.IsEmpty())
645 OpenGl_TextFormatter aFormatter;
646 aFormatter.SetupAlignment (myParams.HAlign, myParams.VAlign);
648 aFormatter.Append (theCtx, myString, *myFont.operator->());
651 aFormatter.Result (theCtx, myTextures, myVertsVbo, myTCrdsVbo);
652 aFormatter.BndBox (myBndBox);
655 if (myTextures.IsEmpty())
660 myExportHeight = 1.0f;
661 myScaleHeight = 1.0f;
663 theCtx->WorldViewState.Push();
665 #if !defined(GL_ES_VERSION_2_0)
666 myModelMatrix.Convert (theCtx->WorldViewState.Current() * theCtx->ModelWorldState.Current());
670 glGetIntegerv (GL_VIEWPORT, myViewport);
671 myProjMatrix.Convert (theCtx->ProjectionState.Current());
673 OpenGl_Utils::Project<Standard_Real> (myPoint.x(),
683 // compute scale factor for constant text height
685 OpenGl_Utils::UnProject<Standard_Real> (myWinX,
688 OpenGl_Mat4d::Map (THE_IDENTITY_MATRIX),
696 const GLdouble h = (GLdouble )myFont->FTFont()->PointSize();
697 OpenGl_Utils::UnProject<Standard_Real> (myWinX,
700 OpenGl_Mat4d::Map (THE_IDENTITY_MATRIX),
707 myScaleHeight = (y2 - y1) / h;
708 if (theTextAspect.IsZoomable())
710 myExportHeight = (float )h;
713 myExportHeight = (float )myFont->FTFont()->PointSize() / myExportHeight;
715 // push enabled flags to the stack
716 glPushAttrib (GL_ENABLE_BIT);
717 glDisable (GL_LIGHTING);
721 && theTextAspect.StyleType() != Aspect_TOST_ANNOTATION)
723 glEnable (GL_DEPTH_TEST);
727 glDisable (GL_DEPTH_TEST);
731 GLint aTexEnvParam = GL_REPLACE;
732 glGetTexEnviv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &aTexEnvParam);
733 if (aTexEnvParam != GL_REPLACE)
735 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
737 glAlphaFunc (GL_GEQUAL, 0.285f);
738 glEnable (GL_ALPHA_TEST);
742 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_ONE
744 // activate texture unit
745 glDisable (GL_TEXTURE_1D);
746 glEnable (GL_TEXTURE_2D);
747 if (theCtx->core15fwd != NULL)
749 theCtx->core15fwd->glActiveTexture (GL_TEXTURE0);
753 switch (theTextAspect.DisplayType())
755 case Aspect_TODT_BLEND:
757 glEnable (GL_COLOR_LOGIC_OP);
761 case Aspect_TODT_SUBTITLE:
763 theCtx->core11->glColor3fv (theColorSubs.rgb);
764 setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.00001f));
766 glBindTexture (GL_TEXTURE_2D, 0);
768 glVertex2f (myBndBox.Left, myBndBox.Top);
769 glVertex2f (myBndBox.Right, myBndBox.Top);
770 glVertex2f (myBndBox.Right, myBndBox.Bottom);
771 glVertex2f (myBndBox.Left, myBndBox.Bottom);
775 case Aspect_TODT_DEKALE:
777 theCtx->core11->glColor3fv (theColorSubs.rgb);
778 setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (+1.0f, +1.0f, 0.00001f));
779 drawText (thePrintCtx, theCtx, theTextAspect);
780 setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (-1.0f, -1.0f, 0.00001f));
781 drawText (thePrintCtx, theCtx, theTextAspect);
782 setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (-1.0f, +1.0f, 0.00001f));
783 drawText (thePrintCtx, theCtx, theTextAspect);
784 setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (+1.0f, -1.0f, 0.00001f));
785 drawText (thePrintCtx, theCtx, theTextAspect);
788 case Aspect_TODT_DIMENSION:
789 case Aspect_TODT_NORMAL:
796 theCtx->core11->glColor3fv (theColorText.rgb);
797 setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.0f));
798 drawText (thePrintCtx, theCtx, theTextAspect);
800 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, aTexEnvParam);
802 if (theTextAspect.DisplayType() == Aspect_TODT_DIMENSION)
804 setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.00001f));
806 glDisable (GL_BLEND);
807 glDisable (GL_TEXTURE_2D);
808 glDisable (GL_ALPHA_TEST);
811 glDisable (GL_DEPTH_TEST);
813 glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
815 glClear (GL_STENCIL_BUFFER_BIT);
816 glEnable (GL_STENCIL_TEST);
817 glStencilFunc (GL_ALWAYS, 1, 0xFF);
818 glStencilOp (GL_KEEP, GL_KEEP, GL_REPLACE);
821 glVertex2f (myBndBox.Left, myBndBox.Top);
822 glVertex2f (myBndBox.Right, myBndBox.Top);
823 glVertex2f (myBndBox.Right, myBndBox.Bottom);
824 glVertex2f (myBndBox.Left, myBndBox.Bottom);
827 glStencilFunc (GL_ALWAYS, 0, 0xFF);
828 // glPopAttrib() will reset state for us
829 //glDisable (GL_STENCIL_TEST);
830 //if (!myIs2d) glEnable (GL_DEPTH_TEST);
832 glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
835 // revert OpenGL state
836 glPopAttrib(); // enable bit
838 // model view matrix was modified
839 theCtx->WorldViewState.Pop();
840 theCtx->ApplyModelViewMatrix();