0024888: Refactoring of OCCT CMake meta-project
[occt.git] / src / OpenGl / OpenGl_PrimitiveArray.hxx
CommitLineData
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
871fa103 19#include <OpenGl_IndexBuffer.hxx>
2166f0fa 20
bf75be98 21#include <InterfaceGraphic_Graphic3d.hxx>
2166f0fa 22#include <Aspect_InteriorStyle.hxx>
a577aaab 23#include <Aspect_TypeOfMarker.hxx>
871fa103 24#include <Graphic3d_TypeOfPrimitiveArray.hxx>
25#include <Graphic3d_IndexBuffer.hxx>
26#include <Graphic3d_BoundBuffer.hxx>
2166f0fa
SK
27
28#include <OpenGl_Element.hxx>
29
8d3f219f 30class OpenGl_GraphicDriver;
31
2166f0fa
SK
32class OpenGl_PrimitiveArray : public OpenGl_Element
33{
34public:
871fa103 35 // OpenGL does not provide a constant for "none" draw mode.
1d03e66d 36 // So we define our own one that does not conflict with GL constants
871fa103 37 // and utilizes common GL invalid value
1d03e66d 38 enum
39 {
40 DRAW_MODE_NONE = -1
41 };
2166f0fa
SK
42
43 //! Default constructor
8d3f219f 44 OpenGl_PrimitiveArray (const OpenGl_GraphicDriver* theDriver,
45 const Graphic3d_TypeOfPrimitiveArray theType,
871fa103 46 const Handle(Graphic3d_IndexBuffer)& theIndices,
47 const Handle(Graphic3d_Buffer)& theAttribs,
48 const Handle(Graphic3d_BoundBuffer)& theBounds);
2166f0fa 49
2166f0fa 50 //! Render primitives to the window
5e27df78 51 virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
52
10b9c7df 53 virtual void Release (OpenGl_Context* theContext);
2166f0fa 54
871fa103 55 //! @return primitive type (GL_LINES, GL_TRIANGLES and others)
56 GLint DrawMode() const { return myDrawMode; }
2166f0fa 57
871fa103 58 //! @return indices array
59 const Handle(Graphic3d_IndexBuffer)& Indices() const { return myIndices; }
2166f0fa 60
871fa103 61 //! @return attributes array
62 const Handle(Graphic3d_Buffer)& Attributes() const { return myAttribs; }
63
64 //! @return bounds array
65 const Handle(Graphic3d_BoundBuffer)& Bounds() const { return myBounds; }
66
8d3f219f 67 //! Returns unique ID of primitive array.
68 const Standard_Size GetUID() const { return myUID; }
69
871fa103 70private:
5e27df78 71
2166f0fa
SK
72 //! VBO initialization procedures
73 Standard_Boolean BuildVBO (const Handle(OpenGl_Workspace)& theWorkspace) const;
5e27df78 74 void clearMemoryGL (const Handle(OpenGl_Context)& theGlCtx) const;
2166f0fa
SK
75
76 //! Main procedure to draw array
77 void DrawArray (Tint theLightingModel,
78 const Aspect_InteriorStyle theInteriorStyle,
79 Tint theEdgeFlag,
80 const TEL_COLOUR* theInteriorColour,
81 const TEL_COLOUR* theLineColour,
82 const TEL_COLOUR* theEdgeColour,
2166f0fa
SK
83 const Handle(OpenGl_Workspace)& theWorkspace) const;
84
85 //! Auxiliary procedures
86 void DrawEdges (const TEL_COLOUR* theEdgeColour,
87 const Handle(OpenGl_Workspace)& theWorkspace) const;
88
a577aaab 89 void DrawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const;
90
2166f0fa
SK
91protected:
92
5e27df78 93 //! Destructor
94 virtual ~OpenGl_PrimitiveArray();
95
96protected:
97
871fa103 98 mutable Handle(OpenGl_IndexBuffer) myVboIndices;
99 mutable Handle(OpenGl_VertexBuffer) myVboAttribs;
100
101 mutable Handle(Graphic3d_IndexBuffer) myIndices;
102 mutable Handle(Graphic3d_Buffer) myAttribs;
103 mutable Handle(Graphic3d_BoundBuffer) myBounds;
104 GLint myDrawMode;
105 mutable Standard_Boolean myIsVboInit;
2166f0fa 106
8d3f219f 107 Standard_Size myUID; //!< Unique ID of primitive array.
108
2166f0fa
SK
109public:
110
1c35b92f 111 DEFINE_STANDARD_ALLOC
2166f0fa
SK
112
113};
114
115#endif //OpenGl_PrimitiveArray_Header