Loaded ofTexture's width and height

If I call ofTexture::loadData the texture is reallocated only if the data being loaded is wider or higher than the currently allocated data.

Hence, if I load less pixels to the texture, ofTexture::getWidth and ofTexture::getHeight will no longer give me the last loaded pixel information, rather than the previously allocated width and height.

Currently I’m keeping track of that information outside of ofTexture, is there a way to retrieve it from ofTexture in a reliable way?

I’ve noticed the ofTextureData class, holding the following:

float tex_t; ///< Texture horiz coordinate, ratio of width to display width. 
float tex_u; ///< Texture vert coordinate, ratio of height to display height.
float tex_w; ///< Texture width.
float tex_h; ///< Texture height.
float width, height; ///< Texture display size.

I’m not sure any of these is the one I need.


Could you just call allocate explicitly first with the correct width and height, since it sets the width and height directly and then call loadData?

actually tex_t and tex_u store the last uploaded width and height so drawing is correct when uploading smaller sizes than the allocation

@NickHardeman, I’m using preallocated ofTexture buffers and the texture size can change at any moment. I need to send the correct texture size to the rendering shader without deallocating and reallocating the object.

Thanks! I’ll use those then.