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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020