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: Getting smallest mipmap on ATI

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2002
    Location
    Columbia, SC
    Posts
    16

    Getting smallest mipmap on ATI

    I have a mipmapped RGB texture and I want to get the color of the smallest mipmap. The following works on NVidia and in software mode but not on an 8500. For example, I should get 157,147,128 but I always get 120,1,26. Is there a way to get the correct value on an ATI?

    glBindTexture(GL_TEXTURE_2D, nTexture);
    int nLevel = 0;
    int nWidth, nHeight;
    glGetTexLevelParameteriv(GL_TEXTURE_2D, nLevel, GL_TEXTURE_WIDTH, &nWidth);
    glGetTexLevelParameteriv(GL_TEXTURE_2D, nLevel, GL_TEXTURE_HEIGHT, &nHeight);
    while (nWidth > 1 | | nHeight > 1)
    {
    nLevel++;
    glGetTexLevelParameteriv(GL_TEXTURE_2D, nLevel, GL_TEXTURE_WIDTH, &nWidth);
    glGetTexLevelParameteriv(GL_TEXTURE_2D, nLevel, GL_TEXTURE_HEIGHT, &nHeight);
    }
    unsigned char pPixel[4];
    glGetTexImage(GL_TEXTURE_2D, nLevel, GL_RGB, GL_UNSIGNED_BYTE, &pPixel);

  2. #2
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: Getting smallest mipmap on ATI

    You just need the width and height,
    then in your while loop you just divide

    if(width>1)
    width/=2;
    if(height>1)
    height/=2;

    Not sure why your code doesn't work.

    V-man
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Feb 2001
    Location
    Switzerland
    Posts
    1,840

    Re: Getting smallest mipmap on ATI

    something like

    maxXlevel = 0;
    while(XSize>>=1) maxXlevel++;
    maxYlevel = 0;
    while(YSize>>=1) maxYlevel++;

    maxlevel = min(maxXlevel,maxYlevel)

    should basically work..

    standard question: you have actual drivers?
    http://davepermen.net - if i could stay true to my heart, i would feel totally free

  4. #4
    Junior Member Newbie
    Join Date
    Apr 2002
    Location
    Columbia, SC
    Posts
    16

    Re: Getting smallest mipmap on ATI

    Thanks for the suggestions. I will use those optimizations but nLevel is right it just gives wrong results.

    I am using the latest official drivers.

    James

Posting Permissions

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