Handle(OpenGl_Context) aCtx = theCtx;
const TCollection_AsciiString aKey = myFont->ResourceKey();
myFont.Nullify();
- if (aCtx)
+ if (! aCtx.IsNull())
aCtx->ReleaseResource (aKey, Standard_True);
}
}
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
// Bind custom shader program or generate default version
- if (aCtx->IsGlGreaterEqual (2, 0))
+ if (aCtx->core20fwd != NULL)
{
aCtx->ShaderManager()->BindProgram (
aTextAspect, aTextAspect->ShaderProgramRes (aCtx));
aTextAspect->SubtitleColor());
}
+ aCtx->BindProgram (NULL);
+
// restore aspects
if (!aPrevTexture.IsNull())
{
theWorkspace->EnableTexture (aPrevTexture);
}
+
+ // restore Z buffer settings
+ if (theWorkspace->UseZBuffer())
+ {
+ glEnable (GL_DEPTH_TEST);
+ }
}
// =======================================================================
anObjZ);
OpenGl_Utils::Translate<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
- OpenGl_Utils::Rotate<GLdouble> (aModViewMat, theTextAspect.Angle(), 0.0, 0.0, 1.0);
-
+ OpenGl_Utils::Rotate<GLdouble> (aModViewMat, theTextAspect.Angle(), 0.0, 0.0, 1.0);
if (!theTextAspect.IsZoomable())
{
#ifdef _WIN32
const Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (theAspect.FontName());
const Font_FontAspect anAspect = (theAspect.FontAspect() != Font_FA_Undefined) ? theAspect.FontAspect() : Font_FA_Regular;
Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (aFontName, anAspect, theHeight);
- if (aRequestedFont.IsNull())
+ Handle(Font_FTFont) aFontFt;
+ if (!aRequestedFont.IsNull())
{
- return aFont;
- }
+ aFontFt = new Font_FTFont (NULL);
- Handle(Font_FTFont) aFontFt = new Font_FTFont (NULL);
- if (!aFontFt->Init (aRequestedFont->FontPath()->ToCString(), theHeight))
- {
- return aFont;
+ if (aFontFt->Init (aRequestedFont->FontPath()->ToCString(), theHeight))
+ {
+ aFont = new OpenGl_Font (aFontFt, theKey);
+ if (!aFont->Init (theCtx))
+ {
+ TCollection_ExtendedString aMsg;
+ aMsg += "Font '";
+ aMsg += theAspect.FontName();
+ aMsg += "' - initialization of GL resources has failed!";
+ theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_ERROR_ARB, 0, GL_DEBUG_SEVERITY_HIGH_ARB, aMsg);
+ aFontFt.Nullify();
+ aFont->Release (theCtx.operator->());
+ aFont = new OpenGl_Font (aFontFt, theKey);
+ }
+ }
+ else
+ {
+ TCollection_ExtendedString aMsg;
+ aMsg += "Font '";
+ aMsg += theAspect.FontName();
+ aMsg += "' is broken or has incompatible format! File path: ";
+ aMsg += aRequestedFont->FontPath()->ToCString();
+ theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_ERROR_ARB, 0, GL_DEBUG_SEVERITY_HIGH_ARB, aMsg);
+ aFontFt.Nullify();
+ aFont = new OpenGl_Font (aFontFt, theKey);
+ }
}
-
- Handle(OpenGl_Context) aCtx = theCtx;
- #if !defined(GL_ES_VERSION_2_0)
- glPushAttrib (GL_TEXTURE_BIT);
- #endif
- aFont = new OpenGl_Font (aFontFt, theKey);
- if (!aFont->Init (aCtx))
+ else
{
- //glPopAttrib();
- //return aFont; // out of resources?
+ TCollection_ExtendedString aMsg;
+ aMsg += "Font '";
+ aMsg += theAspect.FontName();
+ aMsg += "' is not found in the system!";
+ theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_ERROR_ARB, 0, GL_DEBUG_SEVERITY_HIGH_ARB, aMsg);
+ aFont = new OpenGl_Font (aFontFt, theKey);
}
- #if !defined(GL_ES_VERSION_2_0)
- glPopAttrib(); // texture bit
- #endif
- aCtx->ShareResource (theKey, aFont);
+ theCtx->ShareResource (theKey, aFont);
}
return aFont;
}
if (myFont.IsNull())
{
myFont = FindFont (theCtx, theTextAspect, myParams.Height, aFontKey);
- if (myFont.IsNull())
- {
- return;
- }
+ }
+ if (!myFont->WasInitialized())
+ {
+ return;
}
if (myTextures.IsEmpty())
{
- OpenGl_TextFormatter aFormatter;
+ Font_TextFormatter aFormatter;
aFormatter.SetupAlignment (myParams.HAlign, myParams.VAlign);
aFormatter.Reset();
- aFormatter.Append (theCtx, myString, *myFont.operator->());
+
+ aFormatter.Append (myString, *myFont->FTFont());
aFormatter.Format();
- aFormatter.Result (theCtx, myTextures, myVertsVbo, myTCrdsVbo);
+ OpenGl_TextBuilder aBuilder;
+ aBuilder.Perform (aFormatter,
+ theCtx,
+ *myFont.operator->(),
+ myTextures,
+ myVertsVbo,
+ myTCrdsVbo);
+
aFormatter.BndBox (myBndBox);
}
myExportHeight = (float )myFont->FTFont()->PointSize() / myExportHeight;
#if !defined(GL_ES_VERSION_2_0)
-
- // push enabled flags to the stack
- glPushAttrib (GL_ENABLE_BIT);
- glDisable (GL_LIGHTING);
-
- // setup depth test
- if (!myIs2d
- && theTextAspect.StyleType() != Aspect_TOST_ANNOTATION)
+ if (theCtx->core11 != NULL)
{
- glEnable (GL_DEPTH_TEST);
+ glDisable (GL_LIGHTING);
}
- else
+#endif
+
+ // setup depth test
+ if (myIs2d
+ || theTextAspect.StyleType() == Aspect_TOST_ANNOTATION)
{
glDisable (GL_DEPTH_TEST);
}
- // setup alpha test
+ if (theCtx->core15fwd != NULL)
+ {
+ theCtx->core15fwd->glActiveTexture (GL_TEXTURE0);
+ }
+#if !defined(GL_ES_VERSION_2_0)
+ // activate texture unit
GLint aTexEnvParam = GL_REPLACE;
- glGetTexEnviv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &aTexEnvParam);
- if (aTexEnvParam != GL_REPLACE)
+ if (theCtx->core11 != NULL)
{
- glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ // setup alpha test
+ glAlphaFunc (GL_GEQUAL, 0.285f);
+ glEnable (GL_ALPHA_TEST);
+
+ glDisable (GL_TEXTURE_1D);
+ glEnable (GL_TEXTURE_2D);
+ glGetTexEnviv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &aTexEnvParam);
+ if (aTexEnvParam != GL_REPLACE)
+ {
+ glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ }
}
- glAlphaFunc (GL_GEQUAL, 0.285f);
- glEnable (GL_ALPHA_TEST);
+#endif
// setup blending
glEnable (GL_BLEND);
- glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_ONE
-
- // activate texture unit
- glDisable (GL_TEXTURE_1D);
- glEnable (GL_TEXTURE_2D);
- if (theCtx->core15fwd != NULL)
- {
- theCtx->core15fwd->glActiveTexture (GL_TEXTURE0);
- }
+ glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// extra drawings
switch (theTextAspect.DisplayType())
{
case Aspect_TODT_BLEND:
{
+ #if !defined(GL_ES_VERSION_2_0)
glEnable (GL_COLOR_LOGIC_OP);
glLogicOp (GL_XOR);
+ #endif
break;
}
case Aspect_TODT_SUBTITLE:
{
- theCtx->core11->glColor3fv (theColorSubs.rgb);
- setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.00001f));
-
- glBindTexture (GL_TEXTURE_2D, 0);
- glBegin (GL_QUADS);
- glVertex2f (myBndBox.Left, myBndBox.Top);
- glVertex2f (myBndBox.Right, myBndBox.Top);
- glVertex2f (myBndBox.Right, myBndBox.Bottom);
- glVertex2f (myBndBox.Left, myBndBox.Bottom);
- glEnd();
+ #if !defined(GL_ES_VERSION_2_0)
+ if (theCtx->core11 != NULL)
+ {
+ theCtx->core11->glColor3fv (theColorSubs.rgb);
+ setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.00001f));
+
+ glBindTexture (GL_TEXTURE_2D, 0);
+ glBegin (GL_QUADS);
+ glVertex2f (myBndBox.Left, myBndBox.Top);
+ glVertex2f (myBndBox.Right, myBndBox.Top);
+ glVertex2f (myBndBox.Right, myBndBox.Bottom);
+ glVertex2f (myBndBox.Left, myBndBox.Bottom);
+ glEnd();
+ }
+ #endif
break;
}
case Aspect_TODT_DEKALE:
setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.0f));
drawText (thePrintCtx, theCtx, theTextAspect);
- glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, aTexEnvParam);
+#if !defined(GL_ES_VERSION_2_0)
+ if (theCtx->core11 != NULL)
+ {
+ glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, aTexEnvParam);
+ }
+#endif
if (theTextAspect.DisplayType() == Aspect_TODT_DIMENSION)
{
setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.00001f));
glDisable (GL_BLEND);
- glDisable (GL_TEXTURE_2D);
- glDisable (GL_ALPHA_TEST);
if (!myIs2d)
{
glDisable (GL_DEPTH_TEST);
}
+ #if !defined(GL_ES_VERSION_2_0)
+ if (theCtx->core11 != NULL)
+ {
+ glDisable (GL_TEXTURE_2D);
+ glDisable (GL_ALPHA_TEST);
+ }
+ #endif
glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glClear (GL_STENCIL_BUFFER_BIT);
glStencilFunc (GL_ALWAYS, 1, 0xFF);
glStencilOp (GL_KEEP, GL_KEEP, GL_REPLACE);
- glBegin (GL_QUADS);
- glVertex2f (myBndBox.Left, myBndBox.Top);
- glVertex2f (myBndBox.Right, myBndBox.Top);
- glVertex2f (myBndBox.Right, myBndBox.Bottom);
- glVertex2f (myBndBox.Left, myBndBox.Bottom);
- glEnd();
+ #if !defined(GL_ES_VERSION_2_0)
+ if (theCtx->core11 != NULL)
+ {
+ glBegin (GL_QUADS);
+ glVertex2f (myBndBox.Left, myBndBox.Top);
+ glVertex2f (myBndBox.Right, myBndBox.Top);
+ glVertex2f (myBndBox.Right, myBndBox.Bottom);
+ glVertex2f (myBndBox.Left, myBndBox.Bottom);
+ glEnd();
+ }
+ #endif
glStencilFunc (GL_ALWAYS, 0, 0xFF);
- // glPopAttrib() will reset state for us
- //glDisable (GL_STENCIL_TEST);
- //if (!myIs2d) glEnable (GL_DEPTH_TEST);
glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}
- // revert OpenGL state
- glPopAttrib(); // enable bit
+ // reset OpenGL state
+ glDisable (GL_BLEND);
+ glDisable (GL_STENCIL_TEST);
+#if !defined(GL_ES_VERSION_2_0)
+ if (theCtx->core11 != NULL)
+ {
+ glDisable (GL_ALPHA_TEST);
+ }
+ glDisable (GL_COLOR_LOGIC_OP);
+#endif
// model view matrix was modified
theCtx->WorldViewState.Pop();
theCtx->ApplyModelViewMatrix();
-#endif
}