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-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 #ifndef opengl_CTexturedObject_H
10 #define opengl_CTexturedObject_H
11 
13 #include <mrpt/img/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{0};
31  mutable bool m_texture_is_loaded{false};
34  /** Of the texture using "m_textureImageAlpha" */
35  mutable bool m_enableTransparency{false};
36  /** Size of the texture image, rounded up to next power of 2 */
37  mutable int r_width{0}, r_height{0};
38  /** The size of the fill in pixels in the textured image, w.r.t the image
39  * passed by the user. */
40  mutable int m_pad_x_right{0}, m_pad_y_bottom{0};
41 
42  virtual ~CTexturedObject();
43  void unloadTexture();
44 
45  virtual void render_pre() const;
46  virtual void render_post() const;
47 
48  /** Must be implemented by derived classes */
49  virtual void render_texturedobj() const = 0;
50 
53 
54  public:
55  /** Assigns a texture and a transparency image, and enables transparency (If
56  * the images are not 2^N x 2^M, they will be internally filled to its
57  * dimensions to be powers of two)
58  * \note Images are copied, the original ones can be deleted.
59  */
60  void assignImage(
61  const mrpt::img::CImage& img, const mrpt::img::CImage& imgAlpha);
62 
63  /** Assigns a texture image, and disable transparency.
64  * \note Images are copied, the original ones can be deleted. */
65  void assignImage(const mrpt::img::CImage& img);
66 
67  /** Similar to assignImage, but the passed images will be returned as empty:
68  * it avoids making a copy of the whole image, just copies a pointer. */
70 
71  /** Similar to assignImage, but the passed images will be returned as empty:
72  * it avoids making a copy of the whole image, just copies a pointer. */
74 
75  /** VERY IMPORTANT: If you use a multi-thread application, you MUST call
76  * this from the same thread that will later destruct the object in order to
77  * the OpenGL texture memory to be correctly deleted.
78  * Calling this method more than once has no effects. If you use one
79  * thread, this method will be automatically called when rendering, so there
80  * is no need to explicitly call it.
81  */
82  void loadTextureInOpenGL() const;
83 
84  virtual void render_dl() const override;
85 };
86 
87 } // namespace opengl
88 
89 } // namespace mrpt
90 
91 #endif
virtual void render_post() const
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.
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.
void assignImage_fast(mrpt::img::CImage &img, mrpt::img::CImage &imgAlpha)
Similar to assignImage, but the passed images will be returned as empty: it avoids making a copy of t...
#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.
bool m_enableTransparency
Of the texture using "m_textureImageAlpha".
GLint GLvoid * img
Definition: glext.h:3763
virtual void render_pre() const
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.
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
mrpt::img::CImage m_textureImage
GLuint in
Definition: glext.h:7274
void readFromStreamTexturedObject(mrpt::serialization::CArchive &in)
mrpt::img::CImage m_textureImageAlpha
void loadTextureInOpenGL() const
VERY IMPORTANT: If you use a multi-thread application, you MUST call this from the same thread that w...
void assignImage(const mrpt::img::CImage &img, const mrpt::img::CImage &imgAlpha)
Assigns a texture and a transparency image, and enables transparency (If the images are not 2^N x 2^M...
void writeToStreamTexturedObject(mrpt::serialization::CArchive &out) const
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019