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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: cb8dd5fc8 Sat Dec 7 21:55:39 2019 +0100 at sáb dic 7 22:00:13 CET 2019