PDA

View Full Version : Getting smallest mipmap on ATI



JWeaver
06-19-2002, 07:29 PM
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);

V-man
06-20-2002, 04:58 AM
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

davepermen
06-20-2002, 05:05 AM
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?

JWeaver
06-20-2002, 06:12 AM
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