0025063: Visualization - 2D objects are not displayed at some camera positions
[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
2166f0fa
SK
30class OpenGl_PrimitiveArray : public OpenGl_Element
31{
32public:
871fa103 33 // OpenGL does not provide a constant for "none" draw mode.
1d03e66d 34 // So we define our own one that does not conflict with GL constants
871fa103 35 // and utilizes common GL invalid value
1d03e66d 36 enum
37 {
38 DRAW_MODE_NONE = -1
39 };
2166f0fa
SK
40
41 //! Default constructor
871fa103 42 OpenGl_PrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
43 const Handle(Graphic3d_IndexBuffer)& theIndices,
44 const Handle(Graphic3d_Buffer)& theAttribs,
45 const Handle(Graphic3d_BoundBuffer)& theBounds);
2166f0fa 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 51
871fa103 52 //! @return primitive type (GL_LINES, GL_TRIANGLES and others)
53 GLint DrawMode() const { return myDrawMode; }
2166f0fa 54
871fa103 55 //! @return indices array
56 const Handle(Graphic3d_IndexBuffer)& Indices() const { return myIndices; }
2166f0fa 57
871fa103 58 //! @return attributes array
59 const Handle(Graphic3d_Buffer)& Attributes() const { return myAttribs; }
60
61 //! @return bounds array
62 const Handle(Graphic3d_BoundBuffer)& Bounds() const { return myBounds; }
63
64private:
5e27df78 65
2166f0fa
SK
66 //! VBO initialization procedures
67 Standard_Boolean BuildVBO (const Handle(OpenGl_Workspace)& theWorkspace) const;
5e27df78 68 void clearMemoryGL (const Handle(OpenGl_Context)& theGlCtx) const;
2166f0fa
SK
69
70 //! Main procedure to draw array
71 void DrawArray (Tint theLightingModel,
72 const Aspect_InteriorStyle theInteriorStyle,
73 Tint theEdgeFlag,
74 const TEL_COLOUR* theInteriorColour,
75 const TEL_COLOUR* theLineColour,
76 const TEL_COLOUR* theEdgeColour,
2166f0fa
SK
77 const Handle(OpenGl_Workspace)& theWorkspace) const;
78
79 //! Auxiliary procedures
80 void DrawEdges (const TEL_COLOUR* theEdgeColour,
81 const Handle(OpenGl_Workspace)& theWorkspace) const;
82
a577aaab 83 void DrawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const;
84
2166f0fa
SK
85protected:
86
5e27df78 87 //! Destructor
88 virtual ~OpenGl_PrimitiveArray();
89
90protected:
91
871fa103 92 mutable Handle(OpenGl_IndexBuffer) myVboIndices;
93 mutable Handle(OpenGl_VertexBuffer) myVboAttribs;
94
95 mutable Handle(Graphic3d_IndexBuffer) myIndices;
96 mutable Handle(Graphic3d_Buffer) myAttribs;
97 mutable Handle(Graphic3d_BoundBuffer) myBounds;
98 GLint myDrawMode;
99 mutable Standard_Boolean myIsVboInit;
2166f0fa
SK
100
101public:
102
1c35b92f 103 DEFINE_STANDARD_ALLOC
2166f0fa
SK
104
105};
106
107#endif //OpenGl_PrimitiveArray_Header