0030239: Visualization, Graphic3d_ArrayOfPrimitives - pass Graphic3d_ArrayFlags bitma...
[occt.git] / src / OpenGl / OpenGl_VertexBufferCompat.hxx
CommitLineData
7d3e64ef 1// Created by: Kirill GAVRILOV
2// Copyright (c) 2014 OPEN CASCADE SAS
3//
4// This file is part of Open CASCADE Technology software library.
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
11//
12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
14
15#ifndef _OpenGl_VertexBufferCompat_HeaderFile
16#define _OpenGl_VertexBufferCompat_HeaderFile
17
18#include <OpenGl_VertexBuffer.hxx>
19
20//! Compatibility layer for old OpenGL without VBO.
21//! Make sure to pass pointer from GetDataOffset() instead of NULL.
22//! Method GetDataOffset() returns pointer to real data in this class
23//! (while base class OpenGl_VertexBuffer always return NULL).
24//!
25//! Methods Bind()/Unbind() do nothing (do not affect OpenGL state)
26//! and ::GetTarget() is never used.
27//! For this reason there is no analog for OpenGl_IndexBuffer.
28//! Just pass GetDataOffset() to glDrawElements() directly as last argument.
29//!
30//! Class overrides methods init() and subData() to copy data into own memory buffer.
31//! Extra method initLink() might be used to pass existing buffer through handle without copying the data.
32//!
33//! Method Create() creates dummy identifier for this object which should NOT be passed to OpenGL functions.
34class OpenGl_VertexBufferCompat : public OpenGl_VertexBuffer
35{
36
37public:
38
39 //! Create uninitialized VBO.
40 Standard_EXPORT OpenGl_VertexBufferCompat();
41
42 //! Destroy object.
43 Standard_EXPORT virtual ~OpenGl_VertexBufferCompat();
44
45 //! Creates VBO name (id) if not yet generated.
46 //! Data should be initialized by another method.
79104795 47 Standard_EXPORT bool Create (const Handle(OpenGl_Context)& theGlCtx) Standard_OVERRIDE;
7d3e64ef 48
49 //! Destroy object - will release memory if any.
50 Standard_EXPORT virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE;
51
52 //! Bind this VBO.
53 Standard_EXPORT virtual void Bind (const Handle(OpenGl_Context)& theGlCtx) const Standard_OVERRIDE;
54
55 //! Unbind this VBO.
56 Standard_EXPORT virtual void Unbind (const Handle(OpenGl_Context)& theGlCtx) const Standard_OVERRIDE;
57
58public: //! @name advanced methods
59
60 //! Initialize buffer with existing data.
61 //! Data will NOT be copied by this method!
62 Standard_EXPORT bool initLink (const Handle(NCollection_Buffer)& theData,
63 const GLuint theComponentsNb,
64 const GLsizei theElemsNb,
65 const GLenum theDataType);
66
67 //! Initialize buffer with new data (data will be copied).
68 Standard_EXPORT virtual bool init (const Handle(OpenGl_Context)& theGlCtx,
69 const GLuint theComponentsNb,
70 const GLsizei theElemsNb,
71 const void* theData,
72 const GLenum theDataType,
73 const GLsizei theStride) Standard_OVERRIDE;
74
75 //! Update part of the buffer with new data.
76 Standard_EXPORT virtual bool subData (const Handle(OpenGl_Context)& theGlCtx,
77 const GLsizei theElemFrom,
78 const GLsizei theElemsNb,
79 const void* theData,
80 const GLenum theDataType) Standard_OVERRIDE;
81
82protected:
83
84 Handle(NCollection_Buffer) myData; //!< buffer data
85
86public:
87
92efcf78 88 DEFINE_STANDARD_RTTIEXT(OpenGl_VertexBufferCompat,OpenGl_VertexBuffer) // Type definition
7d3e64ef 89
90};
91
92DEFINE_STANDARD_HANDLE(OpenGl_VertexBufferCompat, OpenGl_VertexBuffer)
93
94#endif // _OpenGl_VertexBufferCompat_HeaderFile