Main MRPT website > C++ reference
MRPT logo
CFBORender.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 
29 #ifndef opengl_CFBORender_H
30 #define opengl_CFBORender_H
31 
32 #include <mrpt/utils/CImage.h>
35 
36 namespace mrpt
37 {
38  namespace opengl
39  {
40  /** A class for rendering 3D scenes off-screen directly into an image using OpenGL extensions (glext).
41  * To define a background color, set it in the scene's "main" viewport.
42  *
43  * You can add overlaid text messages, see base class CTextMessageCapable
44  *
45  * \sa Example "fbo_render_test"
46  * \ingroup mrpt_opengl_grp
47  */
49  {
50  public:
51  /** Constructor.
52  * \param[in] skip_glut_window Should be set to true only if another GUI windows already exist with an associated OpenGL context. If left to false, a hidden GLUT window will be created.
53  */
54  CFBORender( unsigned int width = 800, unsigned int height = 600, const bool skip_glut_window = false );
55 
56  /** Destructor */
57  virtual ~CFBORender();
58 
59  /** Change the scene camera.
60  */
61  void setCamera( const COpenGLScene& scene, const CCamera& camera );
62 
63  /** Get a reference to the scene camera.
64  */
65  CCamera &getCamera( const COpenGLScene& scene );
66 
67  /** Render the scene and get the rendered rgb image. Resizes the image buffer if it
68  is necessary.
69  */
70  void getFrame( const COpenGLScene& scene, mrpt::utils::CImage& image );
71 
72  /** Render the scene and get the rendered rgb image. Does not resize the image buffer.
73  MANDATORY: The image origin must be bottom left.
74  */
75  void getFrame2( const COpenGLScene& scene, mrpt::utils::CImage& image );
76 
77  /** Resize the rendering canvas size. */
78  void resize( unsigned int width, unsigned int height );
79 
80  /** Get the default background color (unles an COpenGLViewport defines a custom color) */
81  const mrpt::utils::TColorf & getBackgroundColor() const { return m_default_bk_color; }
82 
83  /** Set the default background color (unles an COpenGLViewport defines a custom color) */
84  void setBackgroundColor(const mrpt::utils::TColorf &col){ m_default_bk_color=col; }
85 
86  protected:
87  int m_win, m_width, m_height;
88  unsigned int m_fbo, m_tex;
89  bool m_win_used;
91 
92  /** Provide information on Framebuffer object extension.
93  */
94  int isExtensionSupported( const char* extension );
95  };
96  } // end namespace
97 
98 } // End of namespace
99 
100 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013