Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

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

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2012
    Posts
    4

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

    From the output of the man page:

    Code :
    NAME
           glTexStorage2D - simultaneously specify storage for all levels of a
           two-dimensional or one-dimensional array texture
     
    C SPECIFICATION
           void glTexStorage2D(GLenum target, GLsizei levels,
                               GLenum internalformat, GLsizei width,
                               GLsizei height);
     
    PARAMETERS
           target
               Specify the target of the operation.  target must be one of
               GL_TEXTURE_2D, GL_PROXY_TEXTURE_2D, GL_TEXTURE_1D_ARRAY,
               GL_PROXY_TEXTURE_1D_ARRAY, GL_TEXTURE_RECTANGLE,
               GL_PROXY_TEXTURE_RECTANGLE, or GL_PROXY_TEXTURE_CUBE_MAP.
     
           levels
               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.

  2. #2
    Intern Contributor
    Join Date
    Nov 2011
    Posts
    51
    Yeah, levels are mipmap levels.

    From the guide (http://www.opengl.org/sdk/docs/man4/...torage2D.xml): "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 xxxStorage*D() 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"

  3. #3
    Intern Contributor
    Join Date
    May 2013
    Posts
    65
    Would this be correct for a 2d texture storage with mipmaps then?:

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

  4. #4
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,209
    Quote Originally Posted by Osbios View Post
    Would this be correct for a 2d texture storage with mipmaps then?:

    Code :
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •