MRPT  2.0.0
COpenGLVertexArrayObject.cpp
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 
10 #include "opengl-precomp.h" // Precompiled header
11 
12 #include <mrpt/core/exceptions.h>
14 #include <mrpt/opengl/opengl_api.h>
15 #include <thread>
16 
17 using namespace mrpt::opengl;
18 
20 {
21  m_impl = std::make_shared<RAII_Impl>();
22 }
23 
25 {
26  // Free resources:
27  destroy();
28 }
29 
31 {
32  destroy();
33 #if MRPT_HAS_OPENGL_GLUT
34  GLuint buffer;
35  glGenVertexArrays(1, &buffer);
36  this->buffer_id = buffer;
37  this->created_from = std::this_thread::get_id();
38  created = true;
39 #endif
40 }
41 
43 {
44  if (!created) return;
45 #if MRPT_HAS_OPENGL_GLUT
46 
47  if (created_from == std::this_thread::get_id())
48  {
49  release();
50  glDeleteVertexArrays(1, &buffer_id);
51  }
52 #endif
53  buffer_id = 0;
54  created = false;
55 }
56 
58 {
59 #if MRPT_HAS_OPENGL_GLUT
60  ASSERT_(created);
61  glBindVertexArray(buffer_id);
62 #endif
63 }
64 
66 {
67 #if MRPT_HAS_OPENGL_GLUT
68  if (!created) return;
69  if (created_from != std::this_thread::get_id()) return;
70 
71  glBindVertexArray(0);
72 #endif
73 }
void destroy()
Automatically called upon destructor, no need for the user to call it in normal situations.
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:120
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13



Page generated by Doxygen 1.8.14 for MRPT 2.0.0 Git: b38439d21 Tue Mar 31 19:58:06 2020 +0200 at miƩ abr 1 00:50:30 CEST 2020