return isDone;
}
+// =======================================================================
+// function : SubData
+// purpose :
+// =======================================================================
+bool OpenGl_VertexBuffer::SubData (const Handle(OpenGl_Context)& theGlCtx,
+ const GLsizei theElemFrom,
+ const GLsizei theElemsNb,
+ const GLuint* theData)
+{
+ if (!IsValid() || myDataType != GL_UNSIGNED_INT
+ || theElemFrom < 0 || ((theElemFrom + theElemsNb) > myElemsNb))
+ {
+ return false;
+ }
+
+ Bind (theGlCtx);
+ theGlCtx->core15->glBufferSubData (GetTarget(),
+ GLintptr(theElemFrom) * GLintptr(myComponentsNb) * sizeof(GLuint), // offset in bytes
+ GLsizeiptr(theElemsNb) * GLsizeiptr(myComponentsNb) * sizeof(GLuint), // size in bytes
+ theData);
+ bool isDone = (glGetError() == GL_NO_ERROR); // GL_OUT_OF_MEMORY
+ Unbind (theGlCtx);
+ return isDone;
+}
+
// =======================================================================
// function : Init
// purpose :
return isDone;
}
+// =======================================================================
+// function : SubData
+// purpose :
+// =======================================================================
+bool OpenGl_VertexBuffer::SubData (const Handle(OpenGl_Context)& theGlCtx,
+ const GLsizei theElemFrom,
+ const GLsizei theElemsNb,
+ const GLubyte* theData)
+{
+ if (!IsValid() || myDataType != GL_UNSIGNED_BYTE
+ || theElemFrom < 0 || ((theElemFrom + theElemsNb) > myElemsNb))
+ {
+ return false;
+ }
+
+ Bind (theGlCtx);
+ theGlCtx->core15->glBufferSubData (GetTarget(),
+ GLintptr(theElemFrom) * GLintptr(myComponentsNb) * sizeof(GLubyte), // offset in bytes
+ GLsizeiptr(theElemsNb) * GLsizeiptr(myComponentsNb) * sizeof(GLubyte), // size in bytes
+ theData);
+ bool isDone = (glGetError() == GL_NO_ERROR); // GL_OUT_OF_MEMORY
+ Unbind (theGlCtx);
+ return isDone;
+}
+
// =======================================================================
// function : BindVertexAttrib
// purpose :
//! Function replaces portion of data within this VBO using glBufferSubData().
//! The VBO should be initialized before call.
//! @param theElemFrom - element id from which replace buffer data (>=0);
- //! @param theElemsNb - elements count (theElemFrom + theElemsNb < GetElemsNb());
+ //! @param theElemsNb - elements count (theElemFrom + theElemsNb <= GetElemsNb());
//! @param theData - pointer to GLfloat data.
Standard_EXPORT bool SubData (const Handle(OpenGl_Context)& theGlCtx,
const GLsizei theElemFrom,
const GLsizei theElemsNb,
const GLfloat* theData);
+ //! Notice that VBO will be unbound after this call.
+ //! Function replaces portion of data within this VBO using glBufferSubData().
+ //! The VBO should be initialized before call.
+ //! @param theElemFrom element id from which replace buffer data (>=0);
+ //! @param theElemsNb elements count (theElemFrom + theElemsNb <= GetElemsNb());
+ //! @param theData pointer to GLuint data.
+ Standard_EXPORT bool SubData (const Handle(OpenGl_Context)& theGlCtx,
+ const GLsizei theElemFrom,
+ const GLsizei theElemsNb,
+ const GLuint* theData);
+
+ //! Notice that VBO will be unbound after this call.
+ //! Function replaces portion of data within this VBO using glBufferSubData().
+ //! The VBO should be initialized before call.
+ //! @param theElemFrom element id from which replace buffer data (>=0);
+ //! @param theElemsNb elements count (theElemFrom + theElemsNb <= GetElemsNb());
+ //! @param theData pointer to GLubyte data.
+ Standard_EXPORT bool SubData (const Handle(OpenGl_Context)& theGlCtx,
+ const GLsizei theElemFrom,
+ const GLsizei theElemsNb,
+ const GLubyte* theData);
+
//! Bind this VBO to active GLSL program.
Standard_EXPORT void BindVertexAttrib (const Handle(OpenGl_Context)& theGlCtx,
const GLuint theAttribLoc) const;