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 virtual void render_dl() const MRPT_OVERRIDE
Derived classes must implement this method to the render the object.
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...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
#define GL_TEXTURE_WRAP_T
A base class for all OpenGL objects with loadable textures.
GLAPI void GLAPIENTRY glEnable(GLenum cap)
mrpt::system::CGenericMemoryPool< CTexturedObject_MemPoolParams, CTexturedObject_MemPoolData > TMyMemPool
A class for storing images as grayscale or RGB bitmaps.
void copyFastFrom(CImage &o)
Moves an image from another object, erasing the origin image in the process (this is much faster than...
#define THROW_EXCEPTION(msg)
virtual ~CTexturedObject()
const char * getChannelsOrder() const
Returns a string of the form "BGR","RGB" or "GRAY" indicating the channels ordering.
void dump_to_pool(const DATA_PARAMS ¶ms, POOLABLE_DATA *block)
Saves the passed data block (characterized by params) to the pool.
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
#define GL_ONE_MINUS_SRC_ALPHA
POOLABLE_DATA * request_memory(const DATA_PARAMS ¶ms)
Request a block of data which fulfils the size requirements stated in params.
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
A renderizable object suitable for rendering with OpenGL's display lists.
GLAPI void GLAPIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param)
A generic system for versatile memory pooling.
GLAPI void GLAPIENTRY glBindTexture(GLenum target, GLuint texture)
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
vector< unsigned char > data
This base provides a set of functions for maths stuff.
#define IMPLEMENTS_VIRTUAL_SERIALIZABLE(class_name, base_class_name, NameSpace)
This must be inserted as implementation of some required members for virtual CSerializable classes: ...
size_t len
size of the vector<unsigned char>
bool m_enableTransparency
Of the texture using "m_textureImageAlpha".
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
bool isSuitable(const CTexturedObject_MemPoolParams &req) const
mrpt::utils::TColor m_color
Color components in the range [0,255].
size_t getRowStride() const
Returns the row stride of the image: this is the number of bytes between two consecutive rows...
unsigned int m_glTextureName
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
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...
GLsizei const GLchar ** string
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
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 char * reserveDataBuffer(const size_t len, vector< unsigned char > &data)
static void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define GL_UNPACK_ROW_LENGTH
#define GL_TEXTURE_MIN_FILTER
#define GL_UNPACK_ALIGNMENT
static unsigned int getNewTextureNumber()
Returns the lowest next free texture name (avoid using OpenGL's own function since we may call them f...
unsigned long POINTER_TYPE
For performing type casting from a pointer to its numeric value.
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...
#define GL_TEXTURE_MAG_FILTER
mrpt::utils::CImage m_textureImage
CImage scaleHalf() const
Returns a new image scaled down to half its original size.
GLAPI void GLAPIENTRY glGetIntegerv(GLenum pname, GLint *params)
GLAPI GLenum GLAPIENTRY glGetError(void)
The namespace for 3D scene representation and rendering.
A versatile "profiler" that logs the time spent within each pair of calls to enter(X)-leave(X), among other stats.
double leave(const char *func_name)
End of a named section.
int r_height
Size of the texture image, rounded up to next power of 2.
bool isColor() const
Returns true if the image is RGB, false if it is grayscale.
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, which checks the coordinates.
#define GL_MAX_TEXTURE_SIZE
#define GL_LUMINANCE_ALPHA
void loadTextureInOpenGL() const
VERY IMPORTANT: If you use a multi-thread application, you MUST call this from the same thread that w...
GLenum GLsizei GLsizei height
void enter(const char *func_name)
Start of a named section.
GLAPI void GLAPIENTRY glDisable(GLenum cap)
GLsizei GLsizei GLenum GLenum const GLvoid * data
GLAPI void GLAPIENTRY glPixelStorei(GLenum pname, GLint param)
size_t getWidth() const MRPT_OVERRIDE
Returns the width of the image in pixels.
#define GL_TEXTURE_WRAP_S
static void releaseTextureName(unsigned int i)
GLAPI void GLAPIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
mrpt::utils::CImage m_textureImageAlpha
size_t getHeight() const MRPT_OVERRIDE
Returns the height of the image in pixels.
void readFromStreamTexturedObject(mrpt::utils::CStream &in)