Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2011-07-13 |
2 | // Created by: Sergey ZERCHANINOV | |
973c2be1 | 3 | // Copyright (c) 2011-2014 OPEN CASCADE SAS |
b311480e | 4 | // |
973c2be1 | 5 | // This file is part of Open CASCADE Technology software library. |
b311480e | 6 | // |
d5f74e42 | 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 | |
973c2be1 | 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. | |
b311480e | 12 | // |
973c2be1 | 13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. | |
b311480e | 15 | |
2166f0fa SK |
16 | #ifndef OpenGl_PrimitiveArray_Header |
17 | #define OpenGl_PrimitiveArray_Header | |
18 | ||
5e27df78 | 19 | #include <OpenGl_VertexBuffer.hxx> |
2166f0fa | 20 | |
bf75be98 | 21 | #include <InterfaceGraphic_Graphic3d.hxx> |
2166f0fa | 22 | #include <Aspect_InteriorStyle.hxx> |
a577aaab | 23 | #include <Aspect_TypeOfMarker.hxx> |
2166f0fa SK |
24 | |
25 | #include <OpenGl_Element.hxx> | |
26 | ||
27 | struct OPENGL_SURF_PROP; | |
28 | ||
29 | class OpenGl_PrimitiveArray : public OpenGl_Element | |
30 | { | |
31 | public: | |
1d03e66d | 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 | |
35 | enum | |
36 | { | |
37 | DRAW_MODE_NONE = -1 | |
38 | }; | |
2166f0fa SK |
39 | |
40 | //! Default constructor | |
41 | OpenGl_PrimitiveArray (CALL_DEF_PARRAY* thePArray); | |
42 | ||
2166f0fa | 43 | //! Render primitives to the window |
5e27df78 | 44 | virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; |
45 | ||
46 | virtual void Release (const Handle(OpenGl_Context)& theContext); | |
2166f0fa SK |
47 | |
48 | CALL_DEF_PARRAY* PArray() const { return myPArray; } | |
49 | ||
50 | private: | |
51 | ||
5e27df78 | 52 | Standard_Boolean toDrawVbo() const |
53 | { | |
54 | return !myVbos[VBOVertices].IsNull(); | |
55 | } | |
56 | ||
2166f0fa SK |
57 | //! VBO initialization procedures |
58 | Standard_Boolean BuildVBO (const Handle(OpenGl_Workspace)& theWorkspace) const; | |
59 | void clearMemoryOwn() const; | |
5e27df78 | 60 | void clearMemoryGL (const Handle(OpenGl_Context)& theGlCtx) const; |
2166f0fa SK |
61 | |
62 | //! Main procedure to draw array | |
63 | void DrawArray (Tint theLightingModel, | |
64 | const Aspect_InteriorStyle theInteriorStyle, | |
65 | Tint theEdgeFlag, | |
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; | |
71 | ||
72 | //! Auxiliary procedures | |
73 | void DrawEdges (const TEL_COLOUR* theEdgeColour, | |
74 | const Handle(OpenGl_Workspace)& theWorkspace) const; | |
75 | ||
a577aaab | 76 | void DrawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const; |
77 | ||
2166f0fa SK |
78 | protected: |
79 | ||
5e27df78 | 80 | //! Destructor |
81 | virtual ~OpenGl_PrimitiveArray(); | |
82 | ||
83 | protected: | |
84 | ||
85 | typedef enum | |
86 | { | |
87 | VBOEdges, | |
88 | VBOVertices, | |
89 | VBOVcolours, | |
90 | VBOVnormals, | |
91 | VBOVtexels, | |
92 | VBOMaxType | |
93 | } VBODataType; | |
94 | ||
95 | mutable CALL_DEF_PARRAY* myPArray; | |
96 | mutable Handle(OpenGl_VertexBuffer) myVbos[VBOMaxType]; | |
97 | GLint myDrawMode; | |
98 | mutable Standard_Boolean myIsVboInit; | |
2166f0fa SK |
99 | |
100 | public: | |
101 | ||
1c35b92f | 102 | DEFINE_STANDARD_ALLOC |
2166f0fa SK |
103 | |
104 | }; | |
105 | ||
106 | #endif //OpenGl_PrimitiveArray_Header |