Skip to main content
GameDev.net gamedev.net
🔒 Locked

Mipmapping

Started by AIRmichael Jul 20, 2002 at 5:40 AM 3 replies 500+ views
Original Post
AIRmichael
AIRmichael
Hey, I know I can do mipmapping by rendering instead of 1 quad, several quads, and load them up with a lower res texture. But isnt there a way to do mipmapping, on 1 surface?
TangentZ
TangentZ
gluBuild2DMipmaps(...) comes to the rescue!


  
// First bind the texture...

glBindTexture(GL_TEXTURE_2D, TextureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, Width, Height, GL_RGB, GL_UNSIGNED_BYTE, pImageData);

// Then later draw the textured quad...

glBindTexture(GL_TEXTURE_2D, TextureID);
glBegin(GL_QUAD);
// Draw the quad with texture coordinates...

glEnd();


Nice and easy! Or you can supply your own set of images
at varying resolution and call glTexImage2D to set the
different levels. In practice though, I find gluBuild2DMipmaps(...)
quite sufficient.


~~~~
Kami no Itte ga ore ni zettai naru!
神はサイコロを振らない!
AIRmichael
AIRmichael
Geforce 2mx and matrox doesnt display some of the textures anymore. It''s only at surfaces which are being blended.


kindfluffysteve
kindfluffysteve
your code which i modify to suit:

I prepared the texture using DevIL

ilImage image("Road.bmp");
ilOgl::Init();
Texture=ilOgl::BindTex(image);
Width = image.Width();
Height = image.Height();

gluBuild2DMipmaps(GL_TEXTURE_2D, 3, Width, Height, format, GL_UNSIGNED_BYTE, image.GetData());

this seems to do something at least. It makes everything kind of red.

somebody else suggested using gluBuild.. and the adaption from his code was this:


gluBuild2DMipmaps(GL_TEXTURE_2D, format, Width, Height, format, GL_UNSIGNED_BYTE, image.GetData());


which resulted in a blue scale image.

what am i missing out?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.