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
mrpt::opengl::CTexturedObject::render_pre
virtual void render_pre() const
Definition: CTexturedObject.cpp:500
mrpt::opengl::CTexturedObject::render_texturedobj
virtual void render_texturedobj() const =0
Must be implemented by derived classes.
mrpt::opengl::CTexturedObject::m_enableTransparency
bool m_enableTransparency
Of the texture using "m_textureImageAlpha".
Definition: CTexturedObject.h:35
mrpt::opengl::CTexturedObject::m_textureImage
mrpt::img::CImage m_textureImage
Definition: CTexturedObject.h:32
geometry.h
mrpt::opengl::CTexturedObject::m_pad_x_right
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.
Definition: CTexturedObject.h:40
mrpt::opengl::CTexturedObject::assignImage_fast
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...
Definition: CTexturedObject.cpp:97
CRenderizableDisplayList.h
mrpt::opengl::CTexturedObject::readFromStreamTexturedObject
void readFromStreamTexturedObject(mrpt::serialization::CArchive &in)
Definition: CTexturedObject.cpp:549
mrpt::opengl::CTexturedObject::m_texture_is_loaded
bool m_texture_is_loaded
Definition: CTexturedObject.h:31
mrpt::opengl::CRenderizableDisplayList
A renderizable object suitable for rendering with OpenGL's display lists.
Definition: CRenderizableDisplayList.h:39
mrpt::opengl::CTexturedObject::render_post
virtual void render_post() const
Definition: CTexturedObject.cpp:526
mrpt::opengl::CTexturedObject::assignImage
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...
Definition: CTexturedObject.cpp:58
mrpt::opengl::CTexturedObject::render_dl
virtual void render_dl() const override
Derived classes must implement this method to the render the object.
Definition: CTexturedObject.cpp:485
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::opengl::CTexturedObject::r_height
int r_height
Definition: CTexturedObject.h:37
mrpt::opengl::CTexturedObject::loadTextureInOpenGL
void loadTextureInOpenGL() const
VERY IMPORTANT: If you use a multi-thread application, you MUST call this from the same thread that w...
Definition: CTexturedObject.cpp:164
mrpt::opengl::CTexturedObject::~CTexturedObject
virtual ~CTexturedObject()
Definition: CTexturedObject.cpp:460
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
mrpt::opengl::CTexturedObject::m_textureImageAlpha
mrpt::img::CImage m_textureImageAlpha
Definition: CTexturedObject.h:33
mrpt::opengl::CTexturedObject::r_width
int r_width
Size of the texture image, rounded up to next power of 2.
Definition: CTexturedObject.h:37
mrpt::opengl::CTexturedObject::m_pad_y_bottom
int m_pad_y_bottom
Definition: CTexturedObject.h:40
mrpt::opengl::CTexturedObject::unloadTexture
void unloadTexture()
Definition: CTexturedObject.cpp:464
mrpt::opengl::CTexturedObject
A base class for all OpenGL objects with loadable textures.
Definition: CTexturedObject.h:25
DEFINE_VIRTUAL_SERIALIZABLE
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
Definition: CSerializable.h:119
mrpt::img::CImage
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130
img
GLint GLvoid * img
Definition: glext.h:3763
mrpt::opengl::CTexturedObject::writeToStreamTexturedObject
void writeToStreamTexturedObject(mrpt::serialization::CArchive &out) const
Definition: CTexturedObject.cpp:474
in
GLuint in
Definition: glext.h:7274
CImage.h
mrpt::opengl::CTexturedObject::m_glTextureName
unsigned int m_glTextureName
Definition: CTexturedObject.h:30



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST