PDA

View Full Version : how can i use the mipmap function?



dujinlian
05-23-2002, 05:24 PM
My dear friends
I meet a difficult problem ,you see,I have a chain of mipmaps which are of diffrient resolution of one texture,now I want to map them to a terrain according the distance the texture from the camera, Could you give me some advice on how to use the mipmappint function?or are there any example on this promblem?thanks a lot!

Yossarian
05-23-2002, 08:07 PM
When you call glTexImage2D(), the second parameter is the mipmap level. Just load each of your textures into a different mip level. Note that if you need to have all the mipmap levels down to 1x1 or OpenGL will become unhappy and turn off texturing. Something like this:

glBindTexture(GL_TEXTURE_2D, texName);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, image64);
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGB8, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, image32);
glTexImage2D(GL_TEXTURE_2D, 2, GL_RGB8, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, image16);
glTexImage2D(GL_TEXTURE_2D, 3, GL_RGB8, 8, 8, 0, GL_RGB, GL_UNSIGNED_BYTE, image8);
glTexImage2D(GL_TEXTURE_2D, 4, GL_RGB8, 4, 4, 0, GL_RGB, GL_UNSIGNED_BYTE, image4);
glTexImage2D(GL_TEXTURE_2D, 5, GL_RGB8, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, image2);
glTexImage2D(GL_TEXTURE_2D, 6, GL_RGB8, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, image1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);


[This message has been edited by Yossarian (edited 05-23-2002).]

[This message has been edited by Yossarian (edited 05-23-2002).]