Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Different MipMap Technic!

  1. #1
    Junior Member Regular Contributor
    Join Date
    Mar 2006
    Posts
    157

    Different MipMap Technic!

    Hi all!

    Is this possible to create Mipmaps after glTexImage2D() as been called, instead of using gluBuild2DMipmaps()?

    thx

  2. #2
    Member Regular Contributor CrazyButcher's Avatar
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    401

    Re: Different MipMap Technic!

    yes, glu just wraps the gl calls and does a simple scaling method for the mipmaps

    the second parameter of glTexImage "level" means which mipmap you want to upload (0 is fullsize, 1 quarter and so on)

  3. #3
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,407

    Re: Different MipMap Technic!

    true, if u want gl to automatically create mipmaps use the generate_mipmap thingee (theres also something for FBO as well)
    basically what happens when u change the base level 0 texture (the largest sized texture) all the smaller sized mipmaps will get recreated (does come with a performance hit, but is far faster than glubuildmipmaps)

  4. #4
    Junior Member Regular Contributor
    Join Date
    Mar 2006
    Posts
    157

    Re: Different MipMap Technic!

    the second parameter of glTexImage "level"
    that is really interesting... been using the glu function for ages, didnt realy care till i hit on glGenerateMipmapEXT();...
    basically what happens when u change the base level 0 texture (the largest sized texture) all the smaller sized mipmaps will get recreated
    not sure i get what u mean... if level is set to 1... you ll end up with the full size plus one mimap 1/2 size? if level is set to 2... full, 1/2 and 1/4... ?

    thx

  5. #5
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,407

    Re: Different MipMap Technic!

    level is like describes the mipmaps (smaller textures substituted when the texture covers lesser screen area, ie farther away usually)
    thus for a 256x128 sized texture if u have mipmapping u have actually 9 textures in total
    256x128 level 0
    128x64 level 1
    64x32 level 2
    32x16 level 3
    16x8 level 4
    8x4 level 5
    4x2 level 6
    2x1 level 7
    1x1 level 8

    normally u just create the base texture (level0) and let gl generate the smaller textures, but its also possible to create the smaller mipmaps yourslef (esp useful for textures with alpha)

  6. #6
    Junior Member Regular Contributor
    Join Date
    Mar 2006
    Posts
    157

    Re: Different MipMap Technic!

    hummm.... what im confused about is:

    when calling glTexImage2D with level 0... are all mimaps automaticly created or do we have to call glTexImage2D for each level?

    i m use to do something like:

    if (in_texture->IsState(TEX_MIP_MAP))
    gluBuild2DMipmaps
    else
    glTexImage2D with level 0

  7. #7
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,107

    Re: Different MipMap Technic!

    Yes, you have to call glTexImage2D multiple times - one per each level.
    Remember: if you use mipmaps then you mnust define all levels up to the point where texture gets downscaled to 1x1. If one or more levels remain undefined (glTexImage2D wasn't called for that level) OpenGL will act as if texturing was disabled.

  8. #8
    Member Regular Contributor CrazyButcher's Avatar
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    401

    Re: Different MipMap Technic!

    he was referring to "GL_GENERATE_MIPMAP_SGIS" when that is set, the automatic mip map stuff will create all mipmaps when level 0 is changed.

    else you must specify all levels with teximage yourself (this is wrapped by gluBuildMipmaps)

  9. #9
    Junior Member Regular Contributor
    Join Date
    Mar 2006
    Posts
    157

    Re: Different MipMap Technic!

    alright!

    Yes, you have to call glTexImage2D multiple times - one per each level.
    that sounds over kill... anyone is doing this?

    so i should use instead:
    glTexParameterf(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);?

    would it cause any problems when called on 1d and 3d textures?

  10. #10
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,345

    Re: Different MipMap Technic!

    Originally posted by Golgoth:
    that sounds over kill... anyone is doing this?
    Pretty much everyone I'd guess. These days some use automipmapping, but repeated glTexImage2D() calls is the standard way. What's so overkill about it? In D3D you upload all mipmaps separately too.

    Originally posted by Golgoth:
    would it cause any problems when called on 1d and 3d textures?
    Use glTexParameterf(GL_TEXTURE_1D, GL_GENERATE_MIPMAP, GL_TRUE); and glTexParameterf(GL_TEXTURE_3D, GL_GENERATE_MIPMAP, GL_TRUE); for those.

Posting Permissions

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