0023418: Crash on the object displaying when running DRAW on remote station. OpenGL...
[occt.git] / src / OpenGl / OpenGl_PrimitiveArray.hxx
index 7336404..4d4a4fd 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef OpenGl_PrimitiveArray_Header
 #define OpenGl_PrimitiveArray_Header
 
-#include <OpenGl_GlCore11.hxx>
+#include <OpenGl_VertexBuffer.hxx>
 
 #include <InterfaceGraphic_telem.hxx>
 #include <Aspect_InteriorStyle.hxx>
@@ -29,7 +29,6 @@
 #include <OpenGl_Element.hxx>
 
 struct OPENGL_SURF_PROP;
-class Handle(OpenGl_Context);
 
 class OpenGl_PrimitiveArray : public OpenGl_Element
 {
@@ -45,21 +44,24 @@ public:
   //! Default constructor
   OpenGl_PrimitiveArray (CALL_DEF_PARRAY* thePArray);
 
-  //! Destructor
-  virtual ~OpenGl_PrimitiveArray();
-
   //! Render primitives to the window
-  virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
+  virtual void Render  (const Handle(OpenGl_Workspace)& theWorkspace) const;
+
+  virtual void Release (const Handle(OpenGl_Context)&   theContext);
 
   CALL_DEF_PARRAY* PArray() const { return myPArray; }
 
 private:
 
+  Standard_Boolean toDrawVbo() const
+  {
+    return !myVbos[VBOVertices].IsNull();
+  }
+
   //! VBO initialization procedures
   Standard_Boolean BuildVBO (const Handle(OpenGl_Workspace)& theWorkspace) const;
   void clearMemoryOwn() const;
-  void clearMemoryGL (const Handle(OpenGl_Context)& theGlContext) const;
-  Standard_Boolean checkSizeForGraphicMemory (const Handle(OpenGl_Context)& theGlContext) const;
+  void clearMemoryGL (const Handle(OpenGl_Context)& theGlCtx) const;
 
   //! Main procedure to draw array
   void DrawArray (Tint theLightingModel,
@@ -97,8 +99,25 @@ private:
 
 protected:
 
-  mutable CALL_DEF_PARRAY* myPArray;
-  GLint                    myDrawMode;
+  //! Destructor
+  virtual ~OpenGl_PrimitiveArray();
+
+protected:
+
+  typedef enum
+  {
+    VBOEdges,
+    VBOVertices,
+    VBOVcolours,
+    VBOVnormals,
+    VBOVtexels,
+    VBOMaxType
+  } VBODataType;
+
+  mutable CALL_DEF_PARRAY*            myPArray;
+  mutable Handle(OpenGl_VertexBuffer) myVbos[VBOMaxType];
+  GLint                               myDrawMode;
+  mutable Standard_Boolean            myIsVboInit;
 
 public: