Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2011-07-13 |
2 | // Created by: Sergey ZERCHANINOV | |
3 | // Copyright (c) 2011-2012 OPEN CASCADE SAS | |
4 | // | |
5 | // The content of this file is subject to the Open CASCADE Technology Public | |
6 | // License Version 6.5 (the "License"). You may not use the content of this file | |
7 | // except in compliance with the License. Please obtain a copy of the License | |
8 | // at http://www.opencascade.org and read it completely before using this file. | |
9 | // | |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its | |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. | |
12 | // | |
13 | // The Original Code and all software distributed under the License is | |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the | |
15 | // Initial Developer hereby disclaims all such warranties, including without | |
16 | // limitation, any warranties of merchantability, fitness for a particular | |
17 | // purpose or non-infringement. Please see the License for the specific terms | |
18 | // and conditions governing the rights and limitations under the License. | |
19 | ||
2166f0fa SK |
20 | #ifndef OpenGl_PrimitiveArray_Header |
21 | #define OpenGl_PrimitiveArray_Header | |
22 | ||
5e27df78 | 23 | #include <OpenGl_VertexBuffer.hxx> |
2166f0fa | 24 | |
bf75be98 | 25 | #include <InterfaceGraphic_Graphic3d.hxx> |
2166f0fa | 26 | #include <Aspect_InteriorStyle.hxx> |
a577aaab | 27 | #include <Aspect_TypeOfMarker.hxx> |
2166f0fa SK |
28 | |
29 | #include <OpenGl_Element.hxx> | |
30 | ||
31 | struct OPENGL_SURF_PROP; | |
32 | ||
33 | class OpenGl_PrimitiveArray : public OpenGl_Element | |
34 | { | |
35 | public: | |
1d03e66d | 36 | // OpenGL does not provie a constant for "none" draw mode. |
37 | // So we define our own one that does not conflict with GL constants | |
38 | // and untilizes common GL invalid value | |
39 | enum | |
40 | { | |
41 | DRAW_MODE_NONE = -1 | |
42 | }; | |
2166f0fa SK |
43 | |
44 | //! Default constructor | |
45 | OpenGl_PrimitiveArray (CALL_DEF_PARRAY* thePArray); | |
46 | ||
2166f0fa | 47 | //! Render primitives to the window |
5e27df78 | 48 | virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; |
49 | ||
50 | virtual void Release (const Handle(OpenGl_Context)& theContext); | |
2166f0fa SK |
51 | |
52 | CALL_DEF_PARRAY* PArray() const { return myPArray; } | |
53 | ||
54 | private: | |
55 | ||
5e27df78 | 56 | Standard_Boolean toDrawVbo() const |
57 | { | |
58 | return !myVbos[VBOVertices].IsNull(); | |
59 | } | |
60 | ||
2166f0fa SK |
61 | //! VBO initialization procedures |
62 | Standard_Boolean BuildVBO (const Handle(OpenGl_Workspace)& theWorkspace) const; | |
63 | void clearMemoryOwn() const; | |
5e27df78 | 64 | void clearMemoryGL (const Handle(OpenGl_Context)& theGlCtx) const; |
2166f0fa SK |
65 | |
66 | //! Main procedure to draw array | |
67 | void DrawArray (Tint theLightingModel, | |
68 | const Aspect_InteriorStyle theInteriorStyle, | |
69 | Tint theEdgeFlag, | |
70 | const TEL_COLOUR* theInteriorColour, | |
71 | const TEL_COLOUR* theLineColour, | |
72 | const TEL_COLOUR* theEdgeColour, | |
73 | const OPENGL_SURF_PROP* theFaceProp, | |
74 | const Handle(OpenGl_Workspace)& theWorkspace) const; | |
75 | ||
76 | //! Auxiliary procedures | |
77 | void DrawEdges (const TEL_COLOUR* theEdgeColour, | |
78 | const Handle(OpenGl_Workspace)& theWorkspace) const; | |
79 | ||
a577aaab | 80 | void DrawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const; |
81 | ||
2166f0fa SK |
82 | protected: |
83 | ||
5e27df78 | 84 | //! Destructor |
85 | virtual ~OpenGl_PrimitiveArray(); | |
86 | ||
87 | protected: | |
88 | ||
89 | typedef enum | |
90 | { | |
91 | VBOEdges, | |
92 | VBOVertices, | |
93 | VBOVcolours, | |
94 | VBOVnormals, | |
95 | VBOVtexels, | |
96 | VBOMaxType | |
97 | } VBODataType; | |
98 | ||
99 | mutable CALL_DEF_PARRAY* myPArray; | |
100 | mutable Handle(OpenGl_VertexBuffer) myVbos[VBOMaxType]; | |
101 | GLint myDrawMode; | |
102 | mutable Standard_Boolean myIsVboInit; | |
2166f0fa SK |
103 | |
104 | public: | |
105 | ||
1c35b92f | 106 | DEFINE_STANDARD_ALLOC |
2166f0fa SK |
107 | |
108 | }; | |
109 | ||
110 | #endif //OpenGl_PrimitiveArray_Header |