Main MRPT website > C++ reference for MRPT 1.9.9
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 /** A base class for all OpenGL objects with loadable textures.
21  * \sa opengl::COpenGLScene, opengl::CTexturedPlane,
22  * opengl::CSetOfTexturedTriangles
23  * \ingroup mrpt_opengl_grp
24  */
26 {
28 
29  protected:
30  mutable unsigned int m_glTextureName;
31  mutable bool m_texture_is_loaded;
34  /** Of the texture using "m_textureImageAlpha" */
35  mutable bool m_enableTransparency;
36  /** Size of the texture image, rounded up to next power of 2 */
37  mutable int r_width, r_height;
38  /** The size of the fill in pixels in the textured image, w.r.t the image
39  * 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  /** Must be implemented by derived classes */
50  virtual void render_texturedobj() const = 0;
51 
54 
55  public:
56  /** Assigns a texture and a transparency image, and enables transparency (If
57  * the images are not 2^N x 2^M, they will be internally filled to its
58  * dimensions to be powers of two)
59  * \note Images are copied, the original ones can be deleted.
60  */
61  void assignImage(
62  const mrpt::utils::CImage& img, const mrpt::utils::CImage& imgAlpha);
63 
64  /** Assigns a texture image, and disable transparency.
65  * \note Images are copied, the original ones can be deleted. */
66  void assignImage(const mrpt::utils::CImage& img);
67 
68  /** Similar to assignImage, but the passed images will be returned as empty:
69  * it avoids making a copy of the whole image, just copies a pointer. */
70  void assignImage_fast(
72 
73  /** Similar to assignImage, but the passed images will be returned as empty:
74  * it avoids making a copy of the whole image, just copies a pointer. */
76 
77  /** VERY IMPORTANT: If you use a multi-thread application, you MUST call
78  * this from the same thread that will later destruct the object in order to
79  * the OpenGL texture memory to be correctly deleted.
80  * Calling this method more than once has no effects. If you use one
81  * thread, this method will be automatically called when rendering, so there
82  * is no need to explicitly call it.
83  */
84  void loadTextureInOpenGL() const;
85 
86  virtual void render_dl() const override;
87 };
88 
89 } // end namespace
90 
91 } // End of namespace
92 
93 #endif
virtual void render_post() const
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...
A base class for all OpenGL objects with loadable textures.
virtual void render_dl() const override
Derived classes must implement this method to the render the object.
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:118
int m_pad_x_right
The size of the fill in pixels in the textured image, w.r.t the image passed by the user...
int r_width
Size of the texture image, rounded up to next power of 2.
#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:41
bool m_enableTransparency
Of the texture using "m_textureImageAlpha".
GLint GLvoid * img
Definition: glext.h:3763
virtual void render_pre() const
void writeToStreamTexturedObject(mrpt::utils::CStream &out) const
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.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::utils::CImage m_textureImage
GLuint in
Definition: glext.h:7274
void loadTextureInOpenGL() const
VERY IMPORTANT: If you use a multi-thread application, you MUST call this from the same thread that w...
mrpt::utils::CImage m_textureImageAlpha
void readFromStreamTexturedObject(mrpt::utils::CStream &in)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019