1 // Created on: 2011-07-13
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef OpenGl_PrimitiveArray_Header
17 #define OpenGl_PrimitiveArray_Header
19 #include <OpenGl_VertexBuffer.hxx>
21 #include <InterfaceGraphic_Graphic3d.hxx>
22 #include <Aspect_InteriorStyle.hxx>
23 #include <Aspect_TypeOfMarker.hxx>
25 #include <OpenGl_Element.hxx>
27 struct OPENGL_SURF_PROP;
29 class OpenGl_PrimitiveArray : public OpenGl_Element
32 // OpenGL does not provie a constant for "none" draw mode.
33 // So we define our own one that does not conflict with GL constants
34 // and untilizes common GL invalid value
40 //! Default constructor
41 OpenGl_PrimitiveArray (CALL_DEF_PARRAY* thePArray);
43 //! Render primitives to the window
44 virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
46 virtual void Release (const Handle(OpenGl_Context)& theContext);
48 CALL_DEF_PARRAY* PArray() const { return myPArray; }
52 Standard_Boolean toDrawVbo() const
54 return !myVbos[VBOVertices].IsNull();
57 //! VBO initialization procedures
58 Standard_Boolean BuildVBO (const Handle(OpenGl_Workspace)& theWorkspace) const;
59 void clearMemoryOwn() const;
60 void clearMemoryGL (const Handle(OpenGl_Context)& theGlCtx) const;
62 //! Main procedure to draw array
63 void DrawArray (Tint theLightingModel,
64 const Aspect_InteriorStyle theInteriorStyle,
66 const TEL_COLOUR* theInteriorColour,
67 const TEL_COLOUR* theLineColour,
68 const TEL_COLOUR* theEdgeColour,
69 const OPENGL_SURF_PROP* theFaceProp,
70 const Handle(OpenGl_Workspace)& theWorkspace) const;
72 //! Auxiliary procedures
73 void DrawEdges (const TEL_COLOUR* theEdgeColour,
74 const Handle(OpenGl_Workspace)& theWorkspace) const;
76 void DrawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const;
81 virtual ~OpenGl_PrimitiveArray();
95 mutable CALL_DEF_PARRAY* myPArray;
96 mutable Handle(OpenGl_VertexBuffer) myVbos[VBOMaxType];
98 mutable Standard_Boolean myIsVboInit;
102 DEFINE_STANDARD_ALLOC
106 #endif //OpenGl_PrimitiveArray_Header