glTexStorage* 'levels' param, and bad texture rendering.

From the output of the man page:

       glTexStorage2D - simultaneously specify storage for all levels of a
       two-dimensional or one-dimensional array texture

       void glTexStorage2D(GLenum target, GLsizei levels,
                           GLenum internalformat, GLsizei width,
                           GLsizei height);

           Specify the target of the operation.  target must be one of

           Specify the number of texture levels.


I wound up pulling a Google search on “texture levels” and found only references to mipmaps, but no official definition on what this actually means. If someone could clarify that this is in fact
what the parameter correlates with, I’d appreciate it.

Regardless, how do I know what an appropriate value is for this parameter?

I have a 36*36 texture which is composed of unsigned chars. The texture is rendererd on the faces
of a cube (36 vertices; no indices are used).

For instance, passing in 16 as a value causes nothing at all to show,
where as a value of 2 causes a “wtf” mixture of colors which simply shouldn’t be there.

So, I’m just not sure exactly where to begin with this. Thanks again for any clarifications/advice.

Yeah, levels are mipmap levels.

From the guide ( “glTexStorage2D specifies the storage requirements for all levels of a two-dimensional texture or one-dimensional texture array simultaneously. Once a texture is specified with this command, the format and dimensions of all levels become immutable unless it is a proxy texture. The contents of the image may still be modified, however, its storage requirements may not change. Such a texture is referred to as an immutable-format texture

So the xxxStorageD() functions are used to specify an “immutable” (in size and format) texture with fixed size. You can upload/update its bytes but within the same size in bytes.
If you are using Storage
D functions for textures without mipmaps, you need to set “levels = 1”

Would this be correct for a 2d texture storage with mipmaps then?:

int levels = int(ceil(log(max(sizeX, sizeY) + 1)));

[QUOTE=Osbios;1257526]Would this be correct for a 2d texture storage with mipmaps then?:

int levels = int(ceil(log(max(sizeX, sizeY) + 1)));


ARB_texture_non_power_of_two contains this definition for the number of MIPmaps:
numLevels = 1 + floor(log2(max(w, h, d)))

Your formula seems to be equivalent.