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 3 of 3

Thread: Mipmap generation fails second time

  1. #1
    Intern Contributor
    Join Date
    Mar 2011
    Location
    Israel
    Posts
    53

    Mipmap generation fails second time

    I have the following situation: I have a material with a texture which I load from file.In some cases I just load the image, create OpenGL texture and generate mipmaps.Then just render it.Works fine when minimized.In other cases,I do some processing on that texture after the initial mipmaps generation.And because I do the processing only on the level zero I regenerate the mipmaps before returning to the renderer.The issue is that after second generation of mipmaps they don't exist.The texture looks as if it has GL_NEAREST mag and min.I can't understand why it doesn't work second time.Here is my code to generate mipmaps:

    glBindTexture(GL_TEXTURE_2D,_id);
    glTexParameteri ( _target, GL_TEXTURE_BASE_LEVEL, 0 );
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glGenerateMipmap(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D,0);


    My hardware is NVidia QUADRO K4000 ,OpenGL 4.2
    One more thing.In OpenGL debug output I am getting the following warning:
    State usage warning: Texture 2 is base level inconsistent.Check texture size.Severity:low ,ID131204

  2. #2
    Newbie Newbie
    Join Date
    Aug 2013
    Posts
    2
    How are you updating the texture data?

  3. #3
    Intern Contributor
    Join Date
    Nov 2011
    Posts
    51
    Texture data should be "allocated" with glTexImage2D() at least one time (with right parameters) and already updated (using sync or async methods) on GPU before call glGenerateMipmap().

    So (sync upload method):
    Code :
    glGenTextures(1, _id);
    glBindTexture(GL_TEXTURE_2D,_id);   
    glTexParameteri  (GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0 );
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);  
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);                       
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, DEFAULT_RGBA_INTERNAL_FORMAT, pixelsData);
    glGenerateMipmap(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D,0);

Tags for this Thread

Posting Permissions

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