PDA

View Full Version : Automatic MIPMAPS



Cyndrome
08-25-2001, 10:07 AM
I am trying to use gluBuildMipmaps to automatically generate mipmap textures, but I keep running in to an access violation...
here is my code......

glGenTextures(1,&land);
glBindTexture(GL_TEXTURE_2D,land);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R, GL_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, landInfo.biWidth, landInfo.biHeight, GL_RGB, GL_UNSIGNED_BYTE,landTexture);

Mezz
08-25-2001, 01:45 PM
For the last parameter of the gluBuild2DMipMaps() function are you sure you are passing a pointer to the image data?

I mean, are you
a) passing a pointer
b) is it at the image data, NOT the texture

-Mezz

Shag
08-25-2001, 03:55 PM
on a similar note - is it better to use the built in functions? or create your own textures to be used at different distances?

what are the performance advantages/disadvanteages?

zed
08-25-2001, 04:56 PM
mipmapping should usually increase performance.
generating your own textures to be used at the smaller resolutions should look better than the ones from gluBuildMipmaps(..).
though of course this is time consuming esp if the artist has to paint them.
perhaps its best to rescale them with say gluScaleImage(..) + then check to see if theres any improvements u can make

08-25-2001, 11:34 PM
Couldn't you just use a program like photoshop to rescale the image? Halfing it each time using bicubic and you could probable just use the batch/action to do it.

On the performance note I definately notice a performance increase when using mipmaps.

Mezz
08-26-2001, 01:22 AM
MasterDark: if you rescaled the image in photoshop you'd need to store it on the HDD or somewhere, which would increase the space required for whatever program you are creating.

gluBuild2DMipMaps() uses gluScaleImage() internally to do at least some of the work.

If you want to see a method of generating your own mipmaps I believe there is one somewhere in the Quake 1 engine source code.

-Mezz

zed
08-26-2001, 02:33 PM
a link to some fast scaleimage code was posted about a week ago on the c.g.a.o usenet group.
im using it + its a lot quicker than gluScaleImage 50x ?

ffish
08-26-2001, 11:07 PM
From memory nVidia recommends using SGIS_generate_mipmap instead of gluBuildiDMipmaps for better performance.

Hope that helps.

Osku
08-27-2001, 09:20 AM
The last parmeter in the second glTexParameteri() should be GL_x_MIPMAP_y where x and y are LINEAR or NEAREST, otherwise it wont use the mipmaps.

Osku