Results 1 to 8 of 8

Thread: glCompressedTexImage2D

  1. #1

    glCompressedTexImage2D

    Hi all,

    I'm looking for some clarification on glCompressedTexImage2D.

    From the function description on khronos.org:
    "level - Specifies the level-of-detail number. Must be less than or equal to 0. Level 0 indicates a single mip-level. Negative values indicate how many mip-levels are described by data."

    Does this mean that the variable "data" points to successive mipmaps such that each mipmap is always half the size of the mipmap that came before it? If this is true, does this not mean that it is impossible to assign a compressed image of a specific size as a mipmap for two or more consecutive levels, and impossible to have "irregular" mipmap sizes (i.e. 256 x 256 followed by 192x192 and followed again by 128x128 ...)

    Appreciate any help,
    - Ben

  2. #2
    Senior Member
    Join Date
    Sep 2003
    Location
    Seattle, WA
    Posts
    246

    Re: glCompressedTexImage2D

    You observations about these restrictions seem correct.

    I think the power of 2 requirement even holds for regular mipmap textures that are specified individually.

    - HM

  3. #3

    Re: glCompressedTexImage2D

    I don't believe so. A quick look at glTexImage2D suggests nothing about defining several mipmap values at once.

    There should be no reason, unless an implementation has made such an assumption, why someone couldn't define "irregular" mipmaps individually - the function definition doesn't mention returning GL_INVALID_OPERATION or some other error in such a case.

    I'm sure you're right, in any case, about the compressed equivalent. I just needed some sort of reassurance before I carried on with it

    Thanks,
    - Ben

  4. #4
    Senior Member
    Join Date
    Sep 2003
    Location
    Seattle, WA
    Posts
    246

    Re: glCompressedTexImage2D

    There's a clause deep in the spec. about what makes a mipmap "complete". At that point the requirement that the sizes are consecutive powers of 2 is enforced.

    That they have to be powers of 2 in general is already in the reference manual.

    <BLOCKQUOTE><font size="1" face="Arial, Verdana, Helvetica, sans-serif">quote:</font><HR>
    width:
    Specifies the width of the texture image. Must be 2^n + 2border for some
    integer n. All implementations support texture images that are at least 64
    texels wide.

    height:
    Specifies the height of the texture image. Must be 2^m + 2border for some
    integer m. All implementations support texture images that are at least 64
    texels high.

    border
    Specifies the width of the border. Must be 0.
    <HR></BLOCKQUOTE>

    - HM

    [ August 04, 2004: Message edited by: Hans-Martin Will ]

  5. #5

    Re: glCompressedTexImage2D

    Granted, yes, they must be powers of two - but I'm suggesting that we could skip any such power where we please, though I'm not sure anyone actually would.

    i.e. mipmap 0 being 128x128, and mipmap 1 being 32x32 ... or 32x64 would still be legal.

    - Ben

  6. #6
    Senior Member
    Join Date
    Sep 2003
    Location
    Seattle, WA
    Posts
    246

    Re: glCompressedTexImage2D

    If "legal" includes that it does not use such a texture, we are on the same page...

    - HM

  7. #7

    Re: glCompressedTexImage2D

    I think so - aren't we? heh

    Thanks for your time,
    - Ben

  8. #8

    Re: glCompressedTexImage2D

    > Granted, yes, they must be powers of two - but I'm suggesting that we could skip any such > power where we please, though I'm not sure > anyone actually would.
    >
    >i.e. mipmap 0 being 128x128, and mipmap 1 being 32x32 ... or 32x64 would still be legal.
    >
    >- Ben

    Such a texture is legal, but not complete. If this texture would be used with mipmapping enabled, the texture wouldn't get displayed at all.

    From the specification (gl1.3, texture completeness):

    "The dimensions of the arrays follow the sequence described in the Mipmapping discussion section of 3.8.7."

    3.8.7 states then that the next level always has to be:

    @(i-1) x @(j-1) x @(k-1)

    i,j,k are pow-2 exponents of the dimensions of the previous level, @ operator is:

    x > 0: @(x) = 2^x
    x <= 0: @(x) = 1

    The only case where one of your texture dimensions can be other than half of the dimension in the previous level is when the size gets below 1 other dimension is still bigger than 1.

    For example:

    256x64, 128x32, 64x16, 32x8, 16x4, 8x2, 4x1, 2x1, 1x1 is ok, but

    256x64, 128x64, 64x64, 32x32, 16x16, ... is not.

    --jani;

Similar Threads

  1. Size of data in glCompressedTexImage2D
    By maximus-dev in forum OpenGL ES 1.X - fixed function hardware
    Replies: 3
    Last Post: 04-28-2010, 06:22 PM
  2. how to use glCompressedTexImage2D()
    By ralphend in forum OpenGL ES general technical discussions
    Replies: 1
    Last Post: 12-09-2004, 02:49 AM

Posting Permissions

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