Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFont()
{
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
- TCollection_AsciiString aSrcVert =
- EOL"void main()"
- EOL"{"
- EOL" gl_Position = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix * occVertex;"
- EOL"}";
-
- TCollection_AsciiString aSrcFrag =
- EOL"float getAlpha(void) { return texture2D(occActiveSampler, gl_PointCoord).a; }"
- EOL"void main()"
- EOL"{"
- EOL" vec4 aColor = occColor;"
- EOL" aColor.a *= getAlpha();"
- EOL" if (aColor.a <= 0.285) discard;"
- EOL" gl_FragColor = aColor;"
- EOL"}";
+ TCollection_AsciiString aSrcVert = TCollection_AsciiString()
+ + THE_VARY_TexCoord
+ + EOL"void main()"
+ EOL"{"
+ EOL" TexCoord = occTexCoord.st;"
+ EOL" gl_Position = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix * occVertex;"
+ EOL"}";
+
+ TCollection_AsciiString aSrcFrag = TCollection_AsciiString() +
+ + THE_VARY_TexCoord
+ + EOL"float getAlpha(void) { return texture2D(occActiveSampler, TexCoord.st).a; }"
+ EOL"void main()"
+ EOL"{"
+ EOL" vec4 aColor = occColor;"
+ EOL" aColor.a *= getAlpha();"
+ EOL" if (aColor.a <= 0.285) discard;"
+ EOL" gl_FragColor = aColor;"
+ EOL"}";
aProgramSrc->AttachShader (Graphic3d_ShaderObject::CreateFromSource (Graphic3d_TOS_VERTEX, aSrcVert));
aProgramSrc->AttachShader (Graphic3d_ShaderObject::CreateFromSource (Graphic3d_TOS_FRAGMENT, aSrcFrag));
const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture();
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
+ // Bind custom shader program or generate default version
if (aCtx->IsGlGreaterEqual (2, 0))
{
- const Handle(OpenGl_ShaderProgram)& aProgram = aTextAspect->ShaderProgramRes (aCtx);
- aCtx->BindProgram (aProgram);
- if (!aProgram.IsNull())
- {
- aProgram->ApplyVariables (aCtx);
-
- const OpenGl_MaterialState* aMaterialState = aCtx->ShaderManager()->MaterialState (aProgram);
-
- if (aMaterialState == NULL || aMaterialState->Aspect() != aTextAspect)
- aCtx->ShaderManager()->UpdateMaterialStateTo (aProgram, aTextAspect);
-
- aCtx->ShaderManager()->PushState (aProgram);
- }
+ aCtx->ShaderManager()->BindProgram (
+ aTextAspect, aTextAspect->ShaderProgramRes (aCtx));
}
// use highlight color or colors from aspect
const OpenGl_AspectText& theTextAspect,
const OpenGl_Vec3 theDVec) const
{
- // setup matrix
-#if !defined(GL_ES_VERSION_2_0)
-
OpenGl_Mat4d aModViewMat;
if (myIs2d)
theCtx->WorldViewState.SetCurrent<Standard_Real> (aModViewMat);
theCtx->ApplyWorldViewMatrix();
-#endif
+
+ if (!theCtx->ActiveProgram().IsNull())
+ {
+ // Upload updated state to shader program
+ theCtx->ShaderManager()->PushState (theCtx->ActiveProgram());
+ }
}
// =======================================================================
glDrawArrays (GL_TRIANGLES, 0, GLsizei(aVerts->GetElemsNb()));
- aVerts->UnbindAttribute (theCtx, Graphic3d_TOA_UV);
+ aTCrds->UnbindAttribute (theCtx, Graphic3d_TOA_UV);
aVerts->UnbindAttribute (theCtx, Graphic3d_TOA_POS);
}
glBindTexture (GL_TEXTURE_2D, 0);
theCtx->WorldViewState.Push();
-#if !defined(GL_ES_VERSION_2_0)
myModelMatrix.Convert (theCtx->WorldViewState.Current() * theCtx->ModelWorldState.Current());
if (!myIs2d)
}
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);
}
case Aspect_TODT_DEKALE:
{
- theCtx->core11->glColor3fv (theColorSubs.rgb);
+ theCtx->SetColor4fv (*(const OpenGl_Vec4* )theColorSubs.rgb);
setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (+1.0f, +1.0f, 0.00001f));
drawText (thePrintCtx, theCtx, theTextAspect);
setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (-1.0f, -1.0f, 0.00001f));
}
// main draw call
- theCtx->core11->glColor3fv (theColorText.rgb);
+ theCtx->SetColor4fv (*(const OpenGl_Vec4* )theColorText.rgb);
setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.0f));
drawText (thePrintCtx, theCtx, theTextAspect);