Main MRPT website > C++ reference for MRPT 1.4.0
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-2016, 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:
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 
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  */
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. */
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. */
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
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
#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...
A renderizable object suitable for rendering with OpenGL's display lists.
A base class for all OpenGL objects with loadable textures.
void assignImage(const mrpt::utils::CImage &img, const mrpt::utils::CImage &imgAlpha)
Assigns a texture and a transparency image, and enables transparency (If the images are not 2^N x 2^M...
virtual void render_post() const
void assignImage_fast(mrpt::utils::CImage &img)
Similar to assignImage, but the passed images will be returned as empty: it avoids making a copy of t...
virtual void render_pre() const
mrpt::utils::CImage m_textureImage
virtual void render_dl() const MRPT_OVERRIDE
Derived classes must implement this method to the render the object.
void assignImage_fast(mrpt::utils::CImage &img, mrpt::utils::CImage &imgAlpha)
Similar to assignImage, but the passed images will be returned as empty: it avoids making a copy of t...
virtual void render_texturedobj() const =0
Must be implemented by derived classes.
void loadTextureInOpenGL() const
VERY IMPORTANT: If you use a multi-thread application, you MUST call this from the same thread that w...
int r_height
Size of the texture image, rounded up to next power of 2.
void writeToStreamTexturedObject(mrpt::utils::CStream &out) const
mrpt::utils::CImage m_textureImageAlpha
bool m_enableTransparency
Of the texture using "m_textureImageAlpha".
void assignImage(const mrpt::utils::CImage &img)
Assigns a texture image, and disable transparency.
void readFromStreamTexturedObject(mrpt::utils::CStream &in)
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:102
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:39
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
Definition: mrpt_macros.h:28
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.



Page generated by Doxygen 1.9.1 for MRPT 1.4.0 SVN: at Mon Apr 18 04:07:33 UTC 2022