]> OCCT Git - occt-copy.git/commitdiff
implementation via glBufferSubData
authorasl <asl@opencascade.com>
Wed, 29 Aug 2018 10:56:58 +0000 (13:56 +0300)
committerasl <asl@opencascade.com>
Wed, 29 Aug 2018 10:58:02 +0000 (13:58 +0300)
src/OpenGl/OpenGl_PrimitiveArray.cxx

index ba74da67c69533bb145b722a7710561ce4bbb3a3..6f20b77c40605132f81dbd06cf60f510663698ee 100644 (file)
@@ -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<Graphic3d_Range>& ranges = myAttribs->InvalidatedRanges();
+  myVboAttribs->Bind(theCtx);
+  const std::vector<Graphic3d_Range>& 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);
   }