30 #define TEXTUREOBJ_USE_MEMPOOL
33 #ifdef TEXTUREOBJ_USE_MEMPOOL
47 vector<unsigned char>
data;
59 m_texture_is_loaded(false),
60 m_enableTransparency(false)
153 #ifdef TEXTUREOBJ_USE_MEMPOOL
179 #if MRPT_HAS_OPENGL_GLUT
180 unsigned char *dataAligned=NULL;
181 vector<unsigned char>
data;
183 # ifdef TEXTUREOBJ_PROFILE_MEM_ALLOC
239 # ifdef TEXTUREOBJ_PROFILE_MEM_ALLOC
242 tim.
enter(sSec.c_str());
268 #ifdef TEXTUREOBJ_PROFILE_MEM_ALLOC
270 tim.
enter(sSec.c_str());
275 #ifdef TEXTUREOBJ_PROFILE_MEM_ALLOC
276 tim.
leave(sSec.c_str());
283 unsigned char *ptr = dataAligned +
y*
width*4;
287 *ptr++ = *ptrSrcCol++;
288 *ptr++ = *ptrSrcCol++;
289 *ptr++ = *ptrSrcCol++;
290 *ptr++ = *ptrSrcAlfa++;
338 # ifdef TEXTUREOBJ_PROFILE_MEM_ALLOC
340 tim.
enter(sSec.c_str());
345 # ifdef TEXTUREOBJ_PROFILE_MEM_ALLOC
346 tim.
leave(sSec.c_str());
353 unsigned char *ptr = dataAligned +
y*
width*2;
356 *ptr++ = *ptrSrcCol++;
357 *ptr++ = *ptrSrcAlfa++;
400 # ifdef TEXTUREOBJ_PROFILE_MEM_ALLOC
403 tim.
leave(sSec.c_str());
408 #ifdef TEXTUREOBJ_USE_MEMPOOL
475 #if MRPT_HAS_OPENGL_GLUT
478 std::cerr <<
"render_pre: Error" << std::endl;
481 std::cerr <<
"render_texturedobj: Error" << std::endl;
484 std::cerr <<
"render_post: Error" << std::endl;
491 #if MRPT_HAS_OPENGL_GLUT
516 #if MRPT_HAS_OPENGL_GLUT
#define IMPLEMENTS_VIRTUAL_SERIALIZABLE(class_name, base_class_name, NameSpace)
This must be inserted as implementation of some required members for virtual CSerializable classes:
mrpt::system::CGenericMemoryPool< CTexturedObject_MemPoolParams, CTexturedObject_MemPoolData > TMyMemPool
unsigned char * reserveDataBuffer(const size_t len, vector< unsigned char > &data)
A renderizable object suitable for rendering with OpenGL's display lists.
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated)
static void releaseTextureName(unsigned int i)
static unsigned int getNewTextureNumber()
Returns the lowest next free texture name (avoid using OpenGL's own function since we may call them f...
static void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
mrpt::utils::TColor m_color
Color components in the range [0,255].
A base class for all OpenGL objects with loadable textures.
void loadTextureInOpenGL() const
VERY IMPORTANT: If you use a multi-thread application, you MUST call this from the same thread that w...
virtual ~CTexturedObject()
virtual void render_pre() const
void readFromStreamTexturedObject(mrpt::utils::CStream &in)
virtual void render_dl() const MRPT_OVERRIDE
Derived classes must implement this method to the render the object.
mrpt::utils::CImage m_textureImage
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...
void writeToStreamTexturedObject(mrpt::utils::CStream &out) const
virtual void render_texturedobj() const =0
Must be implemented by derived classes.
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.
unsigned int m_glTextureName
int r_height
Size of the texture image, rounded up to next power of 2.
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...
mrpt::utils::CImage m_textureImageAlpha
bool m_enableTransparency
Of the texture using "m_textureImageAlpha".
virtual void render_post() const
A generic system for versatile memory pooling.
POOLABLE_DATA * request_memory(const DATA_PARAMS ¶ms)
Request a block of data which fulfils the size requirements stated in params.
static CGenericMemoryPool< DATA_PARAMS, POOLABLE_DATA > * getInstance(const size_t max_pool_entries=5)
Construct-on-first-use (~singleton) pattern: Return the unique instance of this class for a given tem...
void dump_to_pool(const DATA_PARAMS ¶ms, POOLABLE_DATA *block)
Saves the passed data block (characterized by params) to the pool.
A class for storing images as grayscale or RGB bitmaps.
unsigned char * get_unsafe(unsigned int col, unsigned int row, unsigned int channel=0) const
Access to pixels without checking boundaries - Use normally the () operator better,...
CImage scaleHalf() const
Returns a new image scaled down to half its original size.
size_t getRowStride() const
Returns the row stride of the image: this is the number of bytes between two consecutive rows.
bool isColor() const
Returns true if the image is RGB, false if it is grayscale.
size_t getHeight() const MRPT_OVERRIDE
Returns the height of the image in pixels.
size_t getWidth() const MRPT_OVERRIDE
Returns the width of the image in pixels.
void copyFastFrom(CImage &o)
Moves an image from another object, erasing the origin image in the process (this is much faster than...
const char * getChannelsOrder() const
Returns a string of the form "BGR","RGB" or "GRAY" indicating the channels ordering.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
A versatile "profiler" that logs the time spent within each pair of calls to enter(X)-leave(X),...
void enter(const char *func_name)
Start of a named section.
double leave(const char *func_name)
End of a named section.
#define GL_MAX_TEXTURE_SIZE
#define GL_TEXTURE_MIN_FILTER
GLAPI void GLAPIENTRY glEnable(GLenum cap)
#define GL_TEXTURE_WRAP_S
#define GL_LUMINANCE_ALPHA
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
#define GL_UNPACK_ALIGNMENT
GLAPI void GLAPIENTRY glBindTexture(GLenum target, GLuint texture)
GLAPI GLenum GLAPIENTRY glGetError(void)
#define GL_ONE_MINUS_SRC_ALPHA
GLAPI void GLAPIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
#define GL_TEXTURE_WRAP_T
#define GL_TEXTURE_MAG_FILTER
GLAPI void GLAPIENTRY glDisable(GLenum cap)
GLAPI void GLAPIENTRY glPixelStorei(GLenum pname, GLint param)
GLAPI void GLAPIENTRY glGetIntegerv(GLenum pname, GLint *params)
GLAPI void GLAPIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param)
#define GL_UNPACK_ROW_LENGTH
GLsizei GLsizei GLenum GLenum const GLvoid * data
GLenum GLsizei GLsizei height
GLsizei const GLchar ** string
unsigned long POINTER_TYPE
For performing type casting from a pointer to its numeric value.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
#define THROW_EXCEPTION(msg)
This base provides a set of functions for maths stuff.
The namespace for 3D scene representation and rendering.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
vector< unsigned char > data
bool isSuitable(const CTexturedObject_MemPoolParams &req) const
size_t len
size of the vector<unsigned char>