MRPT  2.0.4
CRenderizableShaderTriangles.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 
10 #pragma once
11 
15 #include <mrpt/opengl/TTriangle.h>
16 
17 namespace mrpt::opengl
18 {
19 /** Renderizable generic renderer for objects using the triangles shader.
20  *
21  * \sa opengl::COpenGLScene
22  *
23  * \ingroup mrpt_opengl_grp
24  */
26 {
28 
29  public:
30  CRenderizableShaderTriangles() = default;
31  virtual ~CRenderizableShaderTriangles() override;
32 
33  virtual shader_list_t requiredShaders() const override
34  {
36  }
37  void render(const RenderContext& rc) const override;
38  void renderUpdateBuffers() const override;
39 
40  /** Must be implemented in derived classes to update the geometric entities
41  * to be drawn in "m_*_buffer" fields. */
42  virtual void onUpdateBuffers_Triangles() = 0;
43 
44  // See base docs
45  void freeOpenGLResources() override
46  {
48  m_vao.destroy();
49  }
50 
51  protected:
52  /** List of triangles \sa TTriangle */
53  mutable std::vector<mrpt::opengl::TTriangle> m_triangles;
54 
55  private:
58 };
59 
60 } // namespace mrpt::opengl
virtual shader_list_t requiredShaders() const override
Returns the ID of the OpenGL shader program required to render this class.
A wrapper for an OpenGL vertex array object (VAO).
void freeOpenGLResources() override
Free opengl buffers.
A wrapper for an OpenGL buffer object.
Definition: COpenGLBuffer.h:21
void destroy()
Automatically called upon destructor, no need for the user to call it in normal situations.
Definition: COpenGLBuffer.h:68
The base class of 3D objects that can be directly rendered through OpenGL.
Definition: CRenderizable.h:48
Renderizable generic renderer for objects using the triangles shader.
void destroy()
Automatically called upon destructor, no need for the user to call it in normal situations.
std::vector< shader_id_t > shader_list_t
A list of shader IDs.
Definition: Shader.h:26
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
virtual void onUpdateBuffers_Triangles()=0
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
static constexpr shader_id_t TRIANGLES
std::vector< mrpt::opengl::TTriangle > m_triangles
List of triangles.
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 7ea9b7e81 Mon May 25 11:43:10 2020 +0200 at lun may 25 11:45:15 CEST 2020