aGlContext->SetColor4fv (theWorkspace->EdgeColor().a() >= 0.1f
? theWorkspace->EdgeColor()
: theWorkspace->View()->BackgroundColor());
- aGlContext->SetTypeOfLine (anAspect->Aspect()->EdgeLineType());
+ aGlContext->SetLineStipple(anAspect->Aspect()->LinePattern());
aGlContext->SetLineWidth (anAspect->Aspect()->EdgeWidth());
if (!myVboIndices.IsNull())
void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const
{
const OpenGl_Aspects* anAspectMarker = theWorkspace->Aspects();
- const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
+ const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
const GLenum aDrawMode = !aCtx->ActiveProgram().IsNull()
&& aCtx->ActiveProgram()->HasTessellationStage()
? GL_PATCHES
: myDrawMode;
-
- const Handle(OpenGl_TextureSet)& aSpriteNormRes = anAspectMarker->SpriteRes (aCtx);
- const OpenGl_PointSprite* aSpriteNorm = !aSpriteNormRes.IsNull() ? dynamic_cast<const OpenGl_PointSprite*> (aSpriteNormRes->First().get()) : NULL;
- if (aSpriteNorm != NULL
- && !aSpriteNorm->IsDisplayList())
+ if (anAspectMarker->HasPointSprite (aCtx))
{
// Textured markers will be drawn with the point sprites
aCtx->SetPointSize (anAspectMarker->MarkerSize());
}
#if !defined(GL_ES_VERSION_2_0)
// Textured markers will be drawn with the glBitmap
- else if (anAspectMarker->Aspect()->MarkerType() != Aspect_TOM_POINT
- && aSpriteNorm != NULL)
+ else if (anAspectMarker->Aspect()->MarkerType() != Aspect_TOM_POINT)
{
+ const Handle(OpenGl_PointSprite)& aSpriteNorm = anAspectMarker->SpriteRes (aCtx, false);
+ if (aSpriteNorm.IsNull())
+ {
+ return;
+ }
+
/**if (!isHilight && (myPArray->vcolours != NULL))
{
for (Standard_Integer anIter = 0; anIter < myAttribs->NbElements; anIter++)
}
}
+// =======================================================================
+// function : EstimatedDataSize
+// purpose :
+// =======================================================================
+Standard_Size OpenGl_PrimitiveArray::EstimatedDataSize() const
+{
+ Standard_Size aSize = 0;
+ if (!myVboAttribs.IsNull())
+ {
+ aSize += myVboAttribs->EstimatedDataSize();
+ }
+ if (!myVboIndices.IsNull())
+ {
+ aSize += myVboIndices->EstimatedDataSize();
+ }
+ return aSize;
+}
+
+// =======================================================================
+// function : UpdateDrawStats
+// purpose :
+// =======================================================================
+void OpenGl_PrimitiveArray::UpdateDrawStats (Graphic3d_FrameStatsDataTmp& theStats,
+ bool theIsDetailed) const
+{
+ ++theStats[Graphic3d_FrameStatsCounter_NbElemsNotCulled];
+ if (myIsFillType)
+ {
+ ++theStats[Graphic3d_FrameStatsCounter_NbElemsFillNotCulled];
+ }
+ else if (myDrawMode == GL_POINTS)
+ {
+ ++theStats[Graphic3d_FrameStatsCounter_NbElemsPointNotCulled];
+ }
+ else
+ {
+ ++theStats[Graphic3d_FrameStatsCounter_NbElemsLineNotCulled];
+ }
+
+ if (!theIsDetailed
+ || myVboAttribs.IsNull()
+ || !myVboAttribs->IsValid())
+ {
+ return;
+ }
+
+ const Standard_Integer aNbIndices = !myVboIndices.IsNull() ? myVboIndices->GetElemsNb() : myVboAttribs->GetElemsNb();
+ const Standard_Integer aNbBounds = !myBounds.IsNull() ? myBounds->NbBounds : 1;
+ switch (myDrawMode)
+ {
+ case GL_POINTS:
+ {
+ theStats[Graphic3d_FrameStatsCounter_NbPointsNotCulled] += aNbIndices;
+ break;
+ }
+ case GL_LINES:
+ {
+ theStats[Graphic3d_FrameStatsCounter_NbLinesNotCulled] += aNbIndices / 2;
+ break;
+ }
+ case GL_LINE_STRIP:
+ {
+ theStats[Graphic3d_FrameStatsCounter_NbLinesNotCulled] += aNbIndices - aNbBounds;
+ break;
+ }
+ case GL_LINES_ADJACENCY:
+ {
+ theStats[Graphic3d_FrameStatsCounter_NbLinesNotCulled] += aNbIndices / 4;
+ break;
+ }
+ case GL_LINE_STRIP_ADJACENCY:
+ {
+ theStats[Graphic3d_FrameStatsCounter_NbLinesNotCulled] += aNbIndices - 4 * aNbBounds;
+ break;
+ }
+ case GL_TRIANGLES:
+ {
+ theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices / 3;
+ break;
+ }
+ case GL_TRIANGLE_STRIP:
+ case GL_TRIANGLE_FAN:
+ {
+ theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices - 2 * aNbBounds;
+ break;
+ }
+ case GL_TRIANGLES_ADJACENCY:
+ {
+ theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices / 6;
+ break;
+ }
+ case GL_TRIANGLE_STRIP_ADJACENCY:
+ {
+ theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices - 4 * aNbBounds;
+ break;
+ }
+ #if !defined(GL_ES_VERSION_2_0)
+ case GL_QUADS:
+ {
+ theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices / 2;
+ break;
+ }
+ case GL_QUAD_STRIP:
+ {
+ theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += (aNbIndices / 2 - aNbBounds) * 2;
+ break;
+ }
+ #endif
+ }
+}
+
// =======================================================================
// function : Render
// purpose :
return;
}
- const OpenGl_Aspects* anAspectFace = theWorkspace->ApplyAspects();
+ const OpenGl_Aspects* anAspectFace = theWorkspace->Aspects();
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
- Handle(OpenGl_TextureSet) aTextureBack;
- bool toDrawArray = true;
+ bool toDrawArray = true, toSetLinePolygMode = false;
int toDrawInteriorEdges = 0; // 0 - no edges, 1 - glsl edges, 2 - polygonMode
if (myIsFillType)
{
}
else
{
- aCtx->SetPolygonMode (GL_LINE);
+ toSetLinePolygMode = true;
}
}
}
return;
}
}
-
- // Temporarily disable environment mapping
- aTextureBack = aCtx->BindTextures (Handle(OpenGl_TextureSet)());
}
// create VBOs on first render call
if (!myIsVboInit)
{
// compatibility - keep data to draw markers using display lists
- Standard_Boolean toKeepData = Standard_False;
- if (myDrawMode == GL_POINTS)
- {
- const Handle(OpenGl_TextureSet)& aSpriteNormRes = anAspectFace->SpriteRes (aCtx);
- const OpenGl_PointSprite* aSpriteNorm = !aSpriteNormRes.IsNull() ? dynamic_cast<const OpenGl_PointSprite*> (aSpriteNormRes->First().get()) : NULL;
- toKeepData = aSpriteNorm != NULL
- && aSpriteNorm->IsDisplayList();
- }
+ Standard_Boolean toKeepData = myDrawMode == GL_POINTS
+ && anAspectFace->IsDisplayListSprite (aCtx);
#if defined (GL_ES_VERSION_2_0)
processIndices (aCtx);
#endif
}
Graphic3d_TypeOfShadingModel aShadingModel = Graphic3d_TOSM_UNLIT;
+ anAspectFace = theWorkspace->ApplyAspects (false); // do not bind textures before binding the program
+ const Handle(OpenGl_TextureSet)& aTextureSet = theWorkspace->TextureSet();
+ const bool toEnableEnvMap = !aTextureSet.IsNull()
+ && aTextureSet == theWorkspace->EnvironmentTexture();
if (toDrawArray)
{
const bool hasColorAttrib = !myVboAttribs.IsNull()
case GL_POINTS:
{
aShadingModel = aCtx->ShaderManager()->ChooseMarkerShadingModel (anAspectFace->ShadingModel(), hasVertNorm);
- const Handle(OpenGl_TextureSet)& aSpriteNormRes = anAspectFace->SpriteRes (aCtx);
- const OpenGl_PointSprite* aSpriteNorm = !aSpriteNormRes.IsNull() ? dynamic_cast<const OpenGl_PointSprite*> (aSpriteNormRes->First().get()) : NULL;
- if (aSpriteNorm != NULL
- && !aSpriteNorm->IsDisplayList())
- {
- const Handle(OpenGl_TextureSet)& aSprite = toHilight && anAspectFace->SpriteHighlightRes (aCtx)->First()->IsValid()
- ? anAspectFace->SpriteHighlightRes (aCtx)
- : aSpriteNormRes;
- aCtx->BindTextures (aSprite);
- aCtx->ShaderManager()->BindMarkerProgram (aSprite, aShadingModel, Graphic3d_AlphaMode_Opaque, hasVertColor, anAspectFace->ShaderProgramRes (aCtx));
- }
- else
- {
- aCtx->ShaderManager()->BindMarkerProgram (Handle(OpenGl_TextureSet)(), aShadingModel, Graphic3d_AlphaMode_Opaque, hasVertColor, anAspectFace->ShaderProgramRes (aCtx));
- }
+ aCtx->ShaderManager()->BindMarkerProgram (aTextureSet,
+ aShadingModel, Graphic3d_AlphaMode_Opaque,
+ hasVertColor, anAspectFace->ShaderProgramRes (aCtx));
break;
}
case GL_LINES:
case GL_LINE_STRIP:
{
aShadingModel = aCtx->ShaderManager()->ChooseLineShadingModel (anAspectFace->ShadingModel(), hasVertNorm);
- aCtx->ShaderManager()->BindLineProgram (NULL,
+ aCtx->ShaderManager()->BindLineProgram (Handle(OpenGl_TextureSet)(),
anAspectFace->Aspect()->LineType(),
aShadingModel,
Graphic3d_AlphaMode_Opaque,
default:
{
aShadingModel = aCtx->ShaderManager()->ChooseFaceShadingModel (anAspectFace->ShadingModel(), hasVertNorm);
- const Handle(OpenGl_TextureSet)& aTextures = aCtx->ActiveTextures();
- const Standard_Boolean toEnableEnvMap = (!aTextures.IsNull() && (aTextures == theWorkspace->EnvironmentTexture()));
- aCtx->ShaderManager()->BindFaceProgram (aTextures,
+ aCtx->ShaderManager()->BindFaceProgram (aTextureSet,
aShadingModel,
aCtx->ShaderManager()->MaterialState().HasAlphaCutoff() ? Graphic3d_AlphaMode_Mask : Graphic3d_AlphaMode_Opaque,
toDrawInteriorEdges == 1 ? anAspectFace->Aspect()->InteriorStyle() : Aspect_IS_SOLID,
{
aCtx->ShaderManager()->PushInteriorState (aCtx->ActiveProgram(), anAspectFace->Aspect());
}
+ #if !defined (GL_ES_VERSION_2_0)
+ else if (toSetLinePolygMode)
+ {
+ aCtx->SetPolygonMode (GL_LINE);
+ }
+ #else
+ (void )toSetLinePolygMode;
+ #endif
break;
}
}
- #if !defined(GL_ES_VERSION_2_0)
- // manage FFP lighting
- if (aCtx->ActiveProgram().IsNull()
- && aCtx->core11 != NULL)
+ // bind textures after GLSL program to set mock textures to slots used by program
+ aCtx->BindTextures (aTextureSet, aCtx->ActiveProgram());
+ if (!aTextureSet.IsNull()
+ && !aTextureSet->IsEmpty()
+ && myDrawMode != GL_POINTS) // transformation is not supported within point sprites
{
- if (aShadingModel == Graphic3d_TOSM_UNLIT)
+ if (const Handle(OpenGl_Texture)& aFirstTexture = aTextureSet->First())
{
- glDisable (GL_LIGHTING);
- }
- else
- {
- glEnable (GL_LIGHTING);
+ aCtx->SetTextureMatrix (aFirstTexture->Sampler()->Parameters());
}
}
- #endif
-
- if (!aCtx->ActiveTextures().IsNull()
- && !aCtx->ActiveTextures()->IsEmpty()
- && !aCtx->ActiveTextures()->First().IsNull()
- && myDrawMode != GL_POINTS) // transformation is not supported within point sprites
- {
- aCtx->SetTextureMatrix (aCtx->ActiveTextures()->First()->Sampler()->Parameters());
- }
aCtx->SetSampleAlphaToCoverage (aCtx->ShaderManager()->MaterialState().HasAlphaCutoff());
const Graphic3d_Vec4* aFaceColors = !myBounds.IsNull() && !toHilight && anAspectFace->Aspect()->InteriorStyle() != Aspect_IS_HIDDENLINE
if (myDrawMode == GL_LINES
|| myDrawMode == GL_LINE_STRIP)
{
- aCtx->SetTypeOfLine (anAspectFace->Aspect()->LineType());
+ aCtx->SetLineStipple(anAspectFace->Aspect()->LinePattern());
aCtx->SetLineWidth (anAspectFace->Aspect()->LineWidth());
}
drawArray (theWorkspace, aFaceColors, hasColorAttrib);
- aCtx->BindTextures (aTextureBack);
return;
}
const Handle(Graphic3d_BoundBuffer)& theBounds)
{
// Release old graphic resources
- Release (theContext.operator->());
+ Release (theContext.get());
myIndices = theIndices;
myAttribs = theAttribs;
setDrawMode (theType);
}
+
+// =======================================================================
+// function : DumpJson
+// purpose :
+// =======================================================================
+void OpenGl_PrimitiveArray::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
+{
+ OCCT_DUMP_CLASS_BEGIN (theOStream, OpenGl_PrimitiveArray)
+
+ OCCT_DUMP_BASE_CLASS (theOStream, theDepth, OpenGl_Element)
+
+ OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myVboIndices.get())
+ OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myVboAttribs.get())
+
+ OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myIndices.get())
+ OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myAttribs.get())
+ OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myBounds.get())
+
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDrawMode)
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsFillType)
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsVboInit)
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myUID)
+}