- return false;
- }
-
- /// Bind position of the attribute
- /// \param theGlCtx OpenGl context
- virtual void BindPositionAttribute (const Handle(OpenGl_Context)& theGlCtx) const
- {
- if (!OpenGl_VertexBuffer::IsValid()) {
- return;
- }
-
- OpenGl_VertexBuffer::Bind (theGlCtx);
- GLint aNbComp;
- const GLubyte* anOffset = OpenGl_VertexBuffer::myOffset;
- for (Standard_Integer anAttribIter = 0; anAttribIter < NbAttributes; ++anAttribIter) {
- const Graphic3d_Attribute& anAttrib = Attribs[anAttribIter];
- const GLenum aDataType = toGlDataType (anAttrib.DataType, aNbComp);
- if (aDataType == GL_NONE) {
- continue;
- } else if (anAttrib.Id == Graphic3d_TOA_POS) {
- OpenGl_VertexBuffer::bindAttribute (theGlCtx, Graphic3d_TOA_POS, aNbComp, aDataType, Stride, anOffset);
- break;
- }
-
- anOffset += Graphic3d_Attribute::Stride (anAttrib.DataType);
- }
- }
-
- /// Bind all attributes
- /// \param theGlCtx OpenGl context
- virtual void BindAllAttributes (const Handle(OpenGl_Context)& theGlCtx) const
- {
- if (!OpenGl_VertexBuffer::IsValid())
- return;
-
- OpenGl_VertexBuffer::Bind (theGlCtx);
- GLint aNbComp;
- const GLubyte* anOffset = OpenGl_VertexBuffer::myOffset;
- for (Standard_Integer anAttribIter = 0; anAttribIter < NbAttributes; ++anAttribIter)
- {
- const Graphic3d_Attribute& anAttrib = Attribs[anAttribIter];
- const GLenum aDataType = toGlDataType (anAttrib.DataType, aNbComp);
- if (aDataType == GL_NONE)
- continue;
-
- OpenGl_VertexBuffer::bindAttribute (theGlCtx, anAttrib.Id, aNbComp, aDataType, Stride, anOffset);
- anOffset += Graphic3d_Attribute::Stride (anAttrib.DataType);
- }
- }
-
- /// Unbind all attributes
- /// \param theGlCtx OpenGl context
- virtual void UnbindAllAttributes (const Handle(OpenGl_Context)& theGlCtx) const
- {
- if (!OpenGl_VertexBuffer::IsValid())
- return;
- OpenGl_VertexBuffer::Unbind (theGlCtx);
-
- for (Standard_Integer anAttribIter = 0; anAttribIter < NbAttributes; ++anAttribIter) {
- const Graphic3d_Attribute& anAttrib = Attribs[anAttribIter];
- OpenGl_VertexBuffer::unbindAttribute (theGlCtx, anAttrib.Id);
- }
- }
-
-public:
-
- /// Array of attributes
- Graphic3d_Attribute Attribs[1];
-
- /// A flag
- Standard_Integer Stride;
-
- /// Number of attributes
- Standard_Integer NbAttributes;
-};
-
-//**************************************************************
-//! Redefinition of OpenGl_Element
-class SketcherPrs_Element: public OpenGl_Element
-{
-public:
- /// Constructor
- /// \param theObj a presentation
- SketcherPrs_Element(const Handle(SketcherPrs_SymbolPrs)& theObj) :
- OpenGl_Element(), myObj(theObj) {}
-
- /// Render the current presentation
- /// \param theWorkspace OpenGL workspace
- virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const
- {
- if (!myObj.IsNull())
- myObj->Render(theWorkspace);
- }
-
- /// Releases OpenGL resources
- /// \param theContext OpenGL context
- virtual void Release (OpenGl_Context* theContext)
- {
- if (!myObj.IsNull())
- myObj->Release(theContext);