The Speed of Texture Mapping

I use gluBuild2DMipmaps to do texture mapping. My bitmap’s size is around 30,000 by 500. It takes 4 to 5 seconds to do the job in release mode. Is there anyway to improve the process? Thanks!

Yes, in several ways.
In fact gluBuild2DMipmaps is (as name implies) merely a convenient Utility, doing the job in software.
Either you let the hardware do it automatically with :
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE );

Or you build by hand once all the mipmaps and store them for good to reuse whenever you need.

The algorithm is not too complex, each smaller mipmap level has 2 times less pixel in both x and y.
So average the 4 pixel of previous level for each pixel of next level, until there is only one pixel left.
Of course you will need a power-of-two texture, and may need to cope with non square resolutions (such as 128x512 etc).

[Darn ! I just passed the 666 posts barrier ! :smiley: ]

The reason why I use gluBuild2DMipmaps instead of glTexImage2D is that the dimensions of my bitmap is not power of 2. :confused: Any suggestion? Thanks.

Why cannot I find GL_GENERATE_MIPMAP_SGIS?

http://oss.sgi.com/projects/ogl-sample/registry/SGIS/generate_mipmap.txt

this extension is required for automatic mipmapping.
however your textures must be power of two
so scale the image first, before submitting to GL.

eg. using gluScaleImage

however a image having 30,000 x 500 wont fit into (any?) graphics card anyway. Afaik 4096 x 4096 is the highest you get (probably more on highend cards)

however a image having 30,000 x 500 wont fit into (any?) graphics card anyway. Afaik 4096 x 4096 is the highest you get (probably more on highend cards)
Confirmed. Don’t use anything larger than 2k by 2k just to be safe…

Thank you all!

When CrazyButcher said 4096 X 4096 is the highest I can get, do you mean each dimension of the bitmap should be smaller than 4096 or the total size of the bitmap should be smaller than 4k x 4k = 16m? In my case, the size is 30k x 0.5k = 15m.

The reason why I use gluBuild2DMipmaps instead of glTexImage2D is that the dimensions of my bitmap is not power of 2. Any suggestion? Thanks.

why not use texture rectangles?

Originally posted by Aeluned:
[b] [quote]
The reason why I use gluBuild2DMipmaps instead of glTexImage2D is that the dimensions of my bitmap is not power of 2. Any suggestion? Thanks.

why not use texture rectangles?[/b][/QUOTE]What is it? How to use it?

here’s info on the extension:

http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_rectangle.txt

Originally posted by Aeluned:
[b]here’s info on the extension:

http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_rectangle.txt [/b]
Thanks a lot!

Originally posted by Rong Yao:
[b]Thank you all!

When CrazyButcher said 4096 X 4096 is the highest I can get, do you mean each dimension of the bitmap should be smaller than 4096 or the total size of the bitmap should be smaller than 4k x 4k = 16m? In my case, the size is 30k x 0.5k = 15m.[/b]
I think he meant a single texture should be smaller than 4k x 4k. It really doesn’t matter how big the total dimension is, just keep the total video memory usuage below 256mb or the performance will be heavily cripled due to AGP swap.