Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Esap1

OpenGL Mipmapping in OpenGL.

This topic is 6609 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to use Mip-Mapping in my OpenGL App. Do I use glTexImage2D()? If I do, how do I use it. Could someone show me a simple example of building Mip-Maps in Code. Thanks alot PS: A demo is comming soon

Share this post


Link to post
Share on other sites
Advertisement
Hi,

You can do it in two ways:

1) You create your mipmaps yourself, then you set your texture filters appropriately(GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR or GL_LINEAR_MIPMAP_LINEAR), and then call one glTexImage2D for each mipmap, with the appropriate level (0 for the normal image, 1 for the next mipmap, and so on).
like this:

    

glBindTexture(GL_TEXTURE_2D, Tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, Image);

MakeMipmap(Image);

glTexImage2D(GL_TEXTURE_2D, 1, GL_RGB, width/2, height/2, 0, GL_RGB, GL_UNSIGNED_BYTE, Image);

// and so on



But don't forget that you must indicate ALL the mipmap's sizes, otherwise it will act as if GL_TEXTURE_2D is disabled.


2) You can let GLU create the mipmaps for you. Just call gluBuild2DMipMaps:



glBindTexture(GL_TEXTURE_2D, Tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, width, height, GL_RGB, GL_UNSIGNED_BYTE, Image);




Hope that helps,

Nicodemus.

----
"When everything goes well, something will go wrong." - Murphy


Edited by - Nicodemus on July 16, 2000 12:39:13 AM

Share this post


Link to post
Share on other sites
I have it using Mip-Mapping but I have a question. Its VERY Apparent where each Mip-map is in use(Theres like three Lines). Doesnt Tri-linear Mip-Mapping cover this up, by blending the MipMaps togather. Is there a way to use TriLinear MipMapping, or is there another way to cover up the lines between each MipMap Level?

Edited by - Esap1 on July 17, 2000 1:38:06 AM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
GL_LINEAR_MIPMAP_LINEAR is what you want for tri-linear mip mapping. I think what you have is GL_LINEAR_MIPMAP_NEAREST

-K

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!