MRPT  2.0.1
CRenderizableShaderWireFrame.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 
16 namespace mrpt::opengl
17 {
18 /** Renderizable generic renderer for objects using the wireframe shader.
19  *
20  * \sa opengl::COpenGLScene
21  *
22  * \ingroup mrpt_opengl_grp
23  */
25 {
27 
28  public:
29  CRenderizableShaderWireFrame() = default;
31 
32  virtual shader_list_t requiredShaders() const override
33  {
35  }
36  void render(const RenderContext& rc) const override;
37  void renderUpdateBuffers() const override;
38 
39  /** Must be implemented in derived classes to update the geometric entities
40  * to be drawn in "m_*_buffer" fields. */
41  virtual void onUpdateBuffers_Wireframe() = 0;
42 
43  void setLineWidth(float w)
44  {
45  m_lineWidth = w;
47  }
48  float getLineWidth() const { return m_lineWidth; }
49  void enableAntiAliasing(bool enable = true)
50  {
51  m_antiAliasing = enable;
53  }
54  bool isAntiAliasingEnabled() const { return m_antiAliasing; }
55 
56  // See base docs
57  void freeOpenGLResources() override
58  {
61  m_vao.destroy();
62  }
63 
64  protected:
65  float m_lineWidth = 1.0f;
66  bool m_antiAliasing = false;
67  mutable std::vector<mrpt::math::TPoint3Df> m_vertex_buffer_data;
68  mutable std::vector<mrpt::img::TColor> m_color_buffer_data;
69 
70  private:
73 };
74 
75 } // namespace mrpt::opengl
A wrapper for an OpenGL vertex array object (VAO).
A wrapper for an OpenGL buffer object.
Definition: COpenGLBuffer.h:21
virtual shader_list_t requiredShaders() const override
Returns the ID of the OpenGL shader program required to render this class.
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration.
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
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
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
std::vector< mrpt::math::TPoint3Df > m_vertex_buffer_data
static constexpr shader_id_t WIREFRAME
std::vector< mrpt::img::TColor > m_color_buffer_data
Renderizable generic renderer for objects using the wireframe shader.
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13
virtual void onUpdateBuffers_Wireframe()=0
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
void freeOpenGLResources() override
Free opengl buffers.
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020