Main MRPT website > C++ reference for MRPT 1.5.6
CTexturedObject.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-2017, 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 #ifndef opengl_CTexturedObject_H
10 #define opengl_CTexturedObject_H
11 
13 #include <mrpt/utils/CImage.h>
14 #include <mrpt/math/geometry.h>
15 
16 namespace mrpt
17 {
18  namespace opengl
19  {
20 
21 
22  // This must be added to any CSerializable derived class:
23  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CTexturedObject, CRenderizableDisplayList, OPENGL_IMPEXP )
24 
25  /** A base class for all OpenGL objects with loadable textures.
26  * \sa opengl::COpenGLScene, opengl::CTexturedPlane, opengl::CSetOfTexturedTriangles
27  * \ingroup mrpt_opengl_grp
28  */
30  {
32 
33  protected:
34  mutable unsigned int m_glTextureName;
35  mutable bool m_texture_is_loaded;
38  mutable bool m_enableTransparency; //!< Of the texture using "m_textureImageAlpha"
39  mutable int r_width,r_height; //!< Size of the texture image, rounded up to next power of 2
40  mutable int m_pad_x_right,m_pad_y_bottom; //!< The size of the fill in pixels in the textured image, w.r.t the image passed by the user.
41 
43  virtual ~CTexturedObject();
44  void unloadTexture();
45 
46  virtual void render_pre() const;
47  virtual void render_post() const;
48 
49  virtual void render_texturedobj() const = 0; //!< Must be implemented by derived classes
50 
51  void writeToStreamTexturedObject(mrpt::utils::CStream &out) const;
52  void readFromStreamTexturedObject(mrpt::utils::CStream &in);
53 
54  public:
55  /** Assigns a texture and a transparency image, and enables transparency (If the images are not 2^N x 2^M, they will be internally filled to its dimensions to be powers of two)
56  * \note Images are copied, the original ones can be deleted.
57  */
58  void assignImage(
59  const mrpt::utils::CImage& img,
60  const mrpt::utils::CImage& imgAlpha );
61 
62  /** Assigns a texture image, and disable transparency.
63  * \note Images are copied, the original ones can be deleted. */
64  void assignImage(const mrpt::utils::CImage& img );
65 
66  /** Similar to assignImage, but the passed images will be returned as empty: it avoids making a copy of the whole image, just copies a pointer. */
67  void assignImage_fast(
69  mrpt::utils::CImage& imgAlpha );
70 
71  /** Similar to assignImage, but the passed images will be returned as empty: it avoids making a copy of the whole image, just copies a pointer. */
72  void assignImage_fast(mrpt::utils::CImage& img );
73 
74  /** VERY IMPORTANT: If you use a multi-thread application, you MUST call this from the same thread that will later destruct the object in order to the OpenGL texture memory to be correctly deleted.
75  * Calling this method more than once has no effects. If you use one thread, this method will be automatically called when rendering, so there is no need to explicitly call it.
76  */
77  void loadTextureInOpenGL() const;
78 
79  virtual void render_dl() const MRPT_OVERRIDE;
80 
81  };
83 
84  } // end namespace
85 
86 } // End of namespace
87 
88 
89 #endif
A base class for all OpenGL objects with loadable textures.
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:101
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
A renderizable object suitable for rendering with OpenGL&#39;s display lists.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
bool m_enableTransparency
Of the texture using "m_textureImageAlpha".
GLint GLvoid * img
Definition: glext.h:3645
int m_pad_y_bottom
The size of the fill in pixels in the textured image, w.r.t the image passed by the user...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::utils::CImage m_textureImage
GLuint in
Definition: glext.h:6301
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
mrpt::utils::CImage m_textureImageAlpha



Page generated by Doxygen 1.8.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019