MRPT  2.0.5
COpenGLVertexArrayObject.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <memory>
12 #include <thread>
13 
14 namespace mrpt::opengl
15 {
16 /** A wrapper for an OpenGL vertex array object (VAO).
17  * Refer to docs for glGenVertexArrays().
18  *
19  * \ingroup mrpt_opengl_grp
20  */
22 {
23  public:
25  ~COpenGLVertexArrayObject() = default;
26 
27  /** Actually create the buffer, destroying any previously existing buffer.
28  */
29  void create() { m_impl->create(); }
30 
31  /** Calls create() only if the buffer has not been created yet. */
32  void createOnce()
33  {
34  if (!isCreated()) create();
35  }
36  bool isCreated() const { return m_impl->created; }
37 
38  /** Automatically called upon destructor, no need for the user to call it in
39  * normal situations. */
40  void destroy() { m_impl->destroy(); }
41 
42  void bind() { m_impl->bind(); }
43  void release() { m_impl->bind(); }
44 
45  unsigned int bufferId() const { return m_impl->buffer_id; }
46 
47  private:
48  struct RAII_Impl
49  {
50  RAII_Impl() = default;
51  ~RAII_Impl();
52 
53  void create();
54  void destroy();
55  void bind();
56  void release();
57  void allocate(const void* data, int byteCount);
58 
59  bool created = false;
60  unsigned int buffer_id = 0;
61  std::thread::id created_from;
62  };
64 };
65 
66 } // namespace mrpt::opengl
A wrapper for an OpenGL vertex array object (VAO).
void destroy()
Automatically called upon destructor, no need for the user to call it in normal situations.
void allocate(const void *data, int byteCount)
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13
void createOnce()
Calls create() only if the buffer has not been created yet.
void create()
Actually create the buffer, destroying any previously existing buffer.
static struct FontData data
Definition: gltext.cpp:144



Page generated by Doxygen 1.8.14 for MRPT 2.0.5 Git: b26ce1112 Mon Jul 6 09:39:08 2020 +0200 at lun jul 6 09:45:13 CEST 2020