OK…I’m new to mip mapping and not sure what is wrong…and what method to use…
- I have a 565 16bit texture pre-made and in a file. It has 256x256 to 8x8, basically six levels.
1a) I setup a function to adjust the RGB for each level as it goes back so I can see the mips change…
-
I have a polygon starting at the viewer extending deep into the screen so I can test the mipmapping.
-
I manually install each mip level with glTexImage2D and set the filters as so…
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
This creates a white polygon(no texuring)…Changing the MIN filter to GL_NEAREST produces the texture but no mipmapping.
If I comment out all the manual entries and use gluBuild2DMipmaps it appears to work but I am assuming it creates the mips for me so I do not get the RGB changes…Hard to tell if it is actually mipmapping…
So…Questions…
-
I have read some where that one needs to create mipmaps all the way to 1x1. Is this true? Is this why I don’t see anything when I manually define the mips to 8x8?
-
I guess I would prefer to define my maps, but is there an advantage to using gluBuild2DMipmaps?
2a) Which brings up an interesting question…How does one manage texture memory. At this point I don’t have enough textures yet to be an issue but I’m sure it will arise. I had to do it manually for Glide(3DFX) but not sure about OpenGL. Is there a technique for this in GL? Is it even required? Will the GL driver load and unlaod from the card? Examples?
Basically when I gave up on mine…I went to mipmap.c from RedBook and altered it…
—The Code to install the texture—
void init(MIPTEXTURE_t *mipTexture)
{
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_FLAT);
glTranslatef(0.0, 0.0, 0.0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
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_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB5, mipTexture->width, mipTexture->height, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, mipTexture->mipdata[0].data);
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5, 256, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, mipTexture->mipdata[0].data);
// glTexImage2D(GL_TEXTURE_2D, 1, GL_RGB5, 128, 128, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, mipTexture->mipdata[1].data);
// glTexImage2D(GL_TEXTURE_2D, 2, GL_RGB5, 64, 64, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, mipTexture->mipdata[2].data);
// glTexImage2D(GL_TEXTURE_2D, 3, GL_RGB5, 32, 32, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, mipTexture->mipdata[3].data);
// glTexImage2D(GL_TEXTURE_2D, 4, GL_RGB5, 16, 16, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, mipTexture->mipdata[4].data);
// glTexImage2D(GL_TEXTURE_2D, 5, GL_RGB5, 8, 8, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, mipTexture->mipdata[5].data);
glMatrixMode(GL_TEXTURE);
glScalef(1.0/mipTexture->width, 1.0/mipTexture->height, 1.0);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glEnable(GL_TEXTURE_2D);
}
Thanks…