Main MRPT website > C++ reference for MRPT 1.9.9
CFBORender.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #ifndef opengl_CFBORender_H
11 #define opengl_CFBORender_H
12 
13 #include <mrpt/img/CImage.h>
16 
17 namespace mrpt
18 {
19 namespace opengl
20 {
21 /** A class for rendering 3D scenes off-screen directly into an image using
22  * OpenGL extensions (glext).
23  * To define a background color, set it in the scene's "main" viewport.
24  *
25  * You can add overlaid text messages, see base class CTextMessageCapable
26  *
27  * \sa Example "fbo_render_test"
28  * \ingroup mrpt_opengl_grp
29  */
31 {
32  public:
33  /** Constructor.
34  * \param[in] skip_glut_window Should be set to true only if another GUI
35  * windows already exist with an associated OpenGL context. If left to
36  * false, a hidden GLUT window will be created.
37  */
38  CFBORender(
39  unsigned int width = 800, unsigned int height = 600,
40  const bool skip_glut_window = false);
41 
42  /** Destructor */
43  virtual ~CFBORender();
44 
45  /** Change the scene camera.
46  */
47  void setCamera(const COpenGLScene& scene, const CCamera& camera);
48 
49  /** Get a reference to the scene camera.
50  */
51  CCamera& getCamera(const COpenGLScene& scene);
52 
53  /** Render the scene and get the rendered rgb image. Resizes the image
54  buffer if it
55  is necessary.
56  */
57  void getFrame(const COpenGLScene& scene, mrpt::img::CImage& image);
58 
59  /** Render the scene and get the rendered rgb image. Does not resize the
60  image buffer.
61  MANDATORY: The image origin must be bottom left.
62  */
63  void getFrame2(const COpenGLScene& scene, mrpt::img::CImage& image);
64 
65  /** Resize the rendering canvas size. */
66  void resize(unsigned int width, unsigned int height);
67 
68  /** Get the default background color (unles an COpenGLViewport defines a
69  * custom color) */
71  {
72  return m_default_bk_color;
73  }
74 
75  /** Set the default background color (unles an COpenGLViewport defines a
76  * custom color) */
78  {
79  m_default_bk_color = col;
80  }
81 
82  protected:
84  unsigned int m_fbo, m_tex;
85  bool m_win_used;
87 
88  /** Provide information on Framebuffer object extension.
89  */
90  int isExtensionSupported(const char* extension);
91 };
92 } // end namespace
93 
94 } // End of namespace
95 
96 #endif
mrpt::opengl::CFBORender::setBackgroundColor
void setBackgroundColor(const mrpt::img::TColorf &col)
Set the default background color (unles an COpenGLViewport defines a custom color)
Definition: CFBORender.h:77
mrpt::opengl::CFBORender::m_width
int m_width
Definition: CFBORender.h:83
mrpt::opengl::CFBORender::getCamera
CCamera & getCamera(const COpenGLScene &scene)
Get a reference to the scene camera.
Definition: CFBORender.cpp:143
mrpt::opengl::CFBORender::CFBORender
CFBORender(unsigned int width=800, unsigned int height=600, const bool skip_glut_window=false)
Constructor.
Definition: CFBORender.cpp:23
mrpt::opengl::COpenGLScene
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives.
Definition: COpenGLScene.h:59
mrpt::opengl::CFBORender::getBackgroundColor
const mrpt::img::TColorf & getBackgroundColor() const
Get the default background color (unles an COpenGLViewport defines a custom color)
Definition: CFBORender.h:70
mrpt::opengl::CFBORender::m_tex
unsigned int m_tex
Definition: CFBORender.h:84
CTextMessageCapable.h
mrpt::opengl::CFBORender::resize
void resize(unsigned int width, unsigned int height)
Resize the rendering canvas size.
Definition: CFBORender.cpp:231
mrpt::opengl::CFBORender::m_win_used
bool m_win_used
Definition: CFBORender.h:85
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::opengl::CTextMessageCapable
Keeps a list of text messages which can be rendered to OpenGL contexts by graphic classes.
Definition: CTextMessageCapable.h:24
mrpt::opengl::CFBORender::setCamera
void setCamera(const COpenGLScene &scene, const CCamera &camera)
Change the scene camera.
Definition: CFBORender.cpp:131
mrpt::opengl::CFBORender::m_height
int m_height
Definition: CFBORender.h:83
COpenGLScene.h
mrpt::img::TColorf
A RGB color - floats in the range [0,1].
Definition: TColor.h:79
mrpt::opengl::CCamera
A camera: if added to a scene, the viewpoint defined by this camera will be used instead of the camer...
Definition: CCamera.h:30
mrpt::opengl::CFBORender::~CFBORender
virtual ~CFBORender()
Destructor.
Definition: CFBORender.cpp:118
mrpt::opengl::CFBORender::getFrame
void getFrame(const COpenGLScene &scene, mrpt::img::CImage &image)
Render the scene and get the rendered rgb image.
Definition: CFBORender.cpp:156
mrpt::opengl::CFBORender::m_win
int m_win
Definition: CFBORender.h:83
height
GLenum GLsizei GLsizei height
Definition: glext.h:3554
mrpt::img::CImage
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130
mrpt::opengl::CFBORender::getFrame2
void getFrame2(const COpenGLScene &scene, mrpt::img::CImage &image)
Render the scene and get the rendered rgb image.
Definition: CFBORender.cpp:185
image
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: glext.h:3552
width
GLenum GLsizei width
Definition: glext.h:3531
mrpt::opengl::CFBORender::m_default_bk_color
mrpt::img::TColorf m_default_bk_color
Definition: CFBORender.h:86
CImage.h
mrpt::opengl::CFBORender
A class for rendering 3D scenes off-screen directly into an image using OpenGL extensions (glext).
Definition: CFBORender.h:30
mrpt::opengl::CFBORender::isExtensionSupported
int isExtensionSupported(const char *extension)
Provide information on Framebuffer object extension.
Definition: CFBORender.cpp:280
mrpt::opengl::CFBORender::m_fbo
unsigned int m_fbo
Definition: CFBORender.h:84



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST