MRPT  2.0.4
CFBORender.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 
12 #include <mrpt/img/CImage.h>
14 
15 namespace mrpt::opengl
16 {
17 /** A class for rendering 3D scenes off-screen directly into an image using
18  * OpenGL extensions (glext).
19  * To define a background color, set it in the scene's "main" viewport.
20  *
21  * You can add overlaid text messages, see base class CTextMessageCapable
22  *
23  * \sa Example "fbo_render_test"
24  * \ingroup mrpt_opengl_grp
25  */
27 {
28  public:
29  /** Constructor.
30  * \param[in] skip_glut_window Should be set to true only if another GUI
31  * windows already exist with an associated OpenGL context. If left to
32  * false, a hidden GLUT window will be created.
33  */
34  CFBORender(
35  unsigned int width = 800, unsigned int height = 600,
36  const bool skip_glut_window = false);
37 
38  /** Destructor */
39  virtual ~CFBORender();
40 
41  /** Change the scene camera.
42  */
43  void setCamera(const COpenGLScene& scene, const CCamera& camera);
44 
45  /** Get a reference to the scene camera.
46  */
47  CCamera& getCamera(const COpenGLScene& scene);
48 
49  /** Render the scene and get the rendered rgb image. Resizes the image
50  buffer if it
51  is necessary.
52  */
53  void getFrame(const COpenGLScene& scene, mrpt::img::CImage& image);
54 
55  /** Render the scene and get the rendered rgb image. Does not resize the
56  image buffer.
57  MANDATORY: The image origin must be bottom left.
58  */
59  void getFrame2(const COpenGLScene& scene, mrpt::img::CImage& image);
60 
61  /** Resize the rendering canvas size. */
62  void resize(unsigned int width, unsigned int height);
63 
64  /** Get the default background color (unles an COpenGLViewport defines a
65  * custom color) */
67  {
68  return m_default_bk_color;
69  }
70 
71  /** Set the default background color (unles an COpenGLViewport defines a
72  * custom color) */
74  {
75  m_default_bk_color = col;
76  }
77 
78  protected:
80  unsigned int m_fbo{0}, m_tex{0};
81  bool m_win_used;
83 
84  /** Provide information on Framebuffer object extension.
85  */
86  int isExtensionSupported(const char* extension);
87 };
88 } // namespace mrpt::opengl
CFBORender(unsigned int width=800, unsigned int height=600, const bool skip_glut_window=false)
Constructor.
Definition: CFBORender.cpp:23
int isExtensionSupported(const char *extension)
Provide information on Framebuffer object extension.
Definition: CFBORender.cpp:270
void getFrame(const COpenGLScene &scene, mrpt::img::CImage &image)
Render the scene and get the rendered rgb image.
Definition: CFBORender.cpp:156
const mrpt::img::TColorf & getBackgroundColor() const
Get the default background color (unles an COpenGLViewport defines a custom color) ...
Definition: CFBORender.h:66
CCamera & getCamera(const COpenGLScene &scene)
Get a reference to the scene camera.
Definition: CFBORender.cpp:143
virtual ~CFBORender()
Destructor.
Definition: CFBORender.cpp:118
void setBackgroundColor(const mrpt::img::TColorf &col)
Set the default background color (unles an COpenGLViewport defines a custom color) ...
Definition: CFBORender.h:73
void getFrame2(const COpenGLScene &scene, mrpt::img::CImage &image)
Render the scene and get the rendered rgb image.
Definition: CFBORender.cpp:183
void setCamera(const COpenGLScene &scene, const CCamera &camera)
Change the scene camera.
Definition: CFBORender.cpp:131
void resize(unsigned int width, unsigned int height)
Resize the rendering canvas size.
Definition: CFBORender.cpp:223
An RGBA color - floats in the range [0,1].
Definition: TColor.h:88
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives...
Definition: COpenGLScene.h:56
mrpt::img::TColorf m_default_bk_color
Definition: CFBORender.h:82
A camera: if added to a scene, the viewpoint defined by this camera will be used instead of the camer...
Definition: CCamera.h:33
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:148
A class for rendering 3D scenes off-screen directly into an image using OpenGL extensions (glext)...
Definition: CFBORender.h:26



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020