Pretty much all hardware now supports SGIS_generate_mipmap extension, which asks the hardware to generate the mipmaps autmagically, it will probably be more efficient at it than GLU. Code snippet:
Code:
if GL_SGIS_generate_mipmap then begin
// hardware-accelerated mipmap generation
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
glTexImage2d(GL_TEXTURE_2D, 0, textureFormat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
end else begin
// software GLU-based mipmap generation
gluBuild2DMipmaps(GL_TEXTURE_2D, textureFormat, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
end;
Replace GL_RGBA with whatever format the buffer is in (GL_BGR if a straight 24bpp windows bitmap f.i.), textureFormat is one of the hardware texture formats GL_RGB8, GL_RGBA8, etc.
Bookmarks