PDA

View Full Version : mipmapping



marcus.silfver
11-10-2003, 02:43 AM
I am having problem with mipmapping images loaded with DevIL.
My texture coordinates are imported from 3ds MAX and are correct. I
load the textures with DevIL and the textures are shown correctly.
However if I mipmap the image they get shown upside down.
Here is a code snippet of how I am doing my mipmapping:

imageLoaded = ilLoadImage("my image.jpg");
int sizeX = ilGetInteger(IL_IMAGE_WIDTH);
int sizeY = ilGetInteger(IL_IMAGE_HEIGHT);
ilTexImage (sizeX, sizeY, 1, 4, IL_RGBA, IL_UNSIGNED_BYTE, NULL);

ILubyte *imgData = ilGetData ();

if(imageLoaded == IL_FALSE){
printf("ERROR: gdlCreateMipMaps3: couldnt load image\n");
exit(0);
}

glGenTextures(1, &textureName);
glBindTexture(GL_TEXTURE_2D, textureName);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, sizeX, sizeY, GL_RGB,
GL_UNSIGNED_BYTE, imgData);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR_MIPMAP_LINEAR);


another problem i get when mipmapping as explained above is that bmp
files gets blue, they dont become upside down though, strange.....

Bob
11-10-2003, 03:49 AM
OpenGL expects images to be stored bottom up, and bitmaps are (usually) stored that way, which is why bitmaps appears correct. JPEGs are stored top down, which is why it appears upside down. Make sure the images origin (bottom left for BMP, top left for JPG) matches the way you use it. If it doesn't, flip the image.

And GL_LINEAR_MIPMAP_LINEAR is not a valid magnification filter. Mipmapping applies to minification only.