How to specify maximum mipmap level in opengles?


I specify the maximum mipmap level in opengl by the following code,but GL_TEXTURE_MAX_LEVEL not define in opengles.
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, maxLevel);

I use mipmap function  by the following method, but the texture does not show:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glTexImage2D(GL_TEXTURE_2D, 0, internalFormat,
                    width0, height0, 0,
                    internalFormat, dataType, data0);
glTexImage2D(GL_TEXTURE_2D, 1, internalFormat,
                    width1, height1, 0,
                    internalFormat, dataType, data1);
glTexImage2D(GL_TEXTURE_2D, 2, internalFormat,
                    width2, height2, 0,
                    internalFormat, dataType, data2);

mashangming wrote:
I specify the maximum mipmap level in opengl by the following code,but GL_TEXTURE_MAX_LEVEL not define in opengles.

Unfortunately this functionality does not exist in OpenGL ES. You have to provide a complete mipmap pyramid.

Thank you!
I use compressed texture load each level of mipmap , when the width or high  is less than 4 ,loading failed OpenGLES return GL_INVALID_VALUE.<span id=“result_” =“short_text”>Code is as follows:(level0 is 256*256)

    glGenTextures(1, &textureID);

    if(textureID == GL_INVALID_VALUE)
    {
        return NULL;
    }

    glBindTexture(GL_TEXTURE_2D , textureID );
   
    if (levelCount>1)
    {
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
    }
    else
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

   
   
    GLenum dataType;
    GLenum internalFormat = GetGLInternalPixelFormat(format,dataType);

    width = 256;
    height = 256;
   
    for(int mip=0; mip<levelCount; mip++)
    {

        glCompressedTexImage2D(GL_TEXTURE_2D, mip, internalFormat,
                width, height, 0,
                pixelDataSize, pixelData);
        width/=2;
        width = width?1:width;
        height/=2;
        height = height?1:height;
        pixelData +=pixelDataSize;
        pixelDataSize/=4;
    }

With PVRTC a texture level is always at least two blocks (4x4 pixels for 4bpp, 8x4 pixels for 2bpp) wide and high. However this only affects the imageSize argument, not width and height which still go down to 1x1 for the last level.





Code:
    
if (internalFormat == GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG ||
    internalFormat == GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG)
{
    for(int mip=0; mip<levelCount; mip++)
    {
        pixelDataSize = MAX(width, 8) * MAX(height, 8) / 2;
        glCompressedTexImage2D(GL_TEXTURE_2D, mip, internalFormat,
               width, height, 0,
               pixelDataSize, pixelData);
        width/=2;
        width = width?1:width;
        height/=2;
        height = height?1:height;
        pixelData +=pixelDataSize;
    }
}
Xmas wrote:
With PVRTC a texture level is always at least two blocks (4x4 pixels for 4bpp, 8x4 pixels for 2bpp) wide and high. However this only affects the imageSize argument, not width and height which still go down to 1x1 for the last level.





 

So for the PVRTC miplevels below the minimum block size (i.e. 2x2, 1x1), you're supposed to keep passing the minimum-size-block's data into glCompressedTexImage2D, even though it represents an image that is larger than the width && height parameters passed to glCompressedTexImage2D indicate?

 
Kris2010-11-05 00:07:42
Kris wrote:
So for the PVRTC miplevels below the minimum block size (i.e. 2x2, 1x1), you're supposed to keep passing the minimum-size-block's data into glCompressedTexImage2D, even though it represents an image that is larger than the width && height parameters passed to glCompressedTexImage2D indicate?

That's correct.