PDA

View Full Version : The Speed of Texture Mapping



Rong Yao
10-22-2004, 11:52 AM
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!

ZbuffeR
10-22-2004, 12:51 PM
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 ! :D ]

Rong Yao
10-22-2004, 01:06 PM
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.

Rong Yao
10-22-2004, 01:21 PM
Why cannot I find GL_GENERATE_MIPMAP_SGIS?

CrazyButcher
10-23-2004, 12:16 AM
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)

mpan3
10-24-2004, 09:41 AM
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...

Rong Yao
10-25-2004, 06:12 AM
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.

Aeluned
10-25-2004, 06:30 AM
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?

Rong Yao
10-25-2004, 08:38 AM
Originally posted by Aeluned:


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?What is it? How to use it?

Aeluned
10-25-2004, 08:49 AM
here's info on the extension:

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

Rong Yao
10-25-2004, 10:36 AM
Originally posted by Aeluned:
here's info on the extension:

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

mpan3
10-25-2004, 12:07 PM
Originally posted by Rong Yao:
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.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.