From 50620d9829d40191a4a9ade9ab38f50a12ba38d0 Mon Sep 17 00:00:00 2001 From: asl Date: Wed, 29 Aug 2018 13:56:58 +0300 Subject: [PATCH] implementation via glBufferSubData --- src/OpenGl/OpenGl_PrimitiveArray.cxx | 37 +++++++++------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/src/OpenGl/OpenGl_PrimitiveArray.cxx b/src/OpenGl/OpenGl_PrimitiveArray.cxx index ba74da67c6..6f20b77c40 100644 --- a/src/OpenGl/OpenGl_PrimitiveArray.cxx +++ b/src/OpenGl/OpenGl_PrimitiveArray.cxx @@ -361,33 +361,23 @@ Standard_Boolean OpenGl_PrimitiveArray::buildVBO (const Handle(OpenGl_Context)& Standard_Boolean OpenGl_PrimitiveArray::updateVBO(const Handle(OpenGl_Context)& theCtx) const { - int aStride = myAttribs->IsInterleaved() ? myAttribs->Stride : myAttribs->AttributeOffset(myAttribs->NbAttributes) / myAttribs->NbElements; - int aSize = myAttribs->AttributeOffset(myAttribs->NbAttributes); - myVboAttribs->init(theCtx, aStride, myAttribs->NbElements, myAttribs->Data(), GL_UNSIGNED_BYTE, aStride); - - /*GLint a, b, c; - theCtx->core15fwd->glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &a); - theCtx->core15fwd->glGetIntegerv(GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &b); - theCtx->core15fwd->glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &c); - - myVboAttribs->BindAllAttributes(theCtx); - - printf("array buffer: %i\n", (int)a); - printf("vertex attrib: %i\n", (int)b); - printf("element array: %i\n", (int)c); - printf("my buffer: %i\n", (int)myVboAttribs->BufferId()); - theCtx->core15fwd->glBufferData(myVboAttribs->GetTarget(), aSize, myAttribs->Data(), GL_STATIC_DRAW); + //int aStride = myAttribs->IsInterleaved() ? myAttribs->Stride : myAttribs->AttributeOffset(myAttribs->NbAttributes) / myAttribs->NbElements; + //int aSize = myAttribs->AttributeOffset(myAttribs->NbAttributes); + //myVboAttribs->init(theCtx, aStride, myAttribs->NbElements, myAttribs->Data(), GL_UNSIGNED_BYTE, aStride); - myVboAttribs->UnbindAllAttributes(theCtx); + //myVboAttribs->Bind(theCtx); + //theCtx->core15fwd->glBufferData(myVboAttribs->GetTarget(), aSize, myAttribs->Data(), GL_STATIC_DRAW); + //myVboAttribs->Unbind(theCtx); - /*const std::vector& ranges = myAttribs->InvalidatedRanges(); + myVboAttribs->Bind(theCtx); + const std::vector& ranges = myAttribs->InvalidatedRanges(); for (size_t i = 0, n = ranges.size(); i < n; i++) { Graphic3d_Range aRange = ranges[i]; theCtx->core15fwd->glBufferSubData(myVboAttribs->GetTarget(), aRange.Start, aRange.Length, myAttribs->Data() + aRange.Start); - }*/ - //myVboAttribs->Unbind(theCtx); + } + myVboAttribs->Unbind(theCtx); myAttribs->Validate(); return Standard_True; @@ -777,8 +767,8 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace myIsVboInit = Standard_True; } - //if (!myAttribs.IsNull() && myAttribs->IsMutable() && myAttribs->InvalidatedRanges().size() > 0) - // updateVBO(aCtx); + if (!myAttribs.IsNull() && myAttribs->IsMutable() && myAttribs->InvalidatedRanges().size() > 0) + updateVBO(aCtx); // Temporarily disable environment mapping Handle(OpenGl_TextureSet) aTextureBack; @@ -901,9 +891,6 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace const Graphic3d_Vec4* aFaceColors = !myBounds.IsNull() && !toHilight && anAspectFace->Aspect()->InteriorStyle() != Aspect_IS_HIDDENLINE ? myBounds->Colors : NULL; - if (!myAttribs.IsNull() && myAttribs->IsMutable() && myAttribs->InvalidatedRanges().size() > 0) - updateVBO(aCtx); - drawArray (theWorkspace, aFaceColors, hasColorAttrib); } -- 2.39.5