Archived

This topic is now archived and is closed to further replies.

cggm

How to do the Mipmapping using the glCompressedTexImage2DARB() without reading dds fi

Recommended Posts

Hi, all...: I am trying the glCompressedTexImage2DARB(...) function to do the texture compression for accelerating the frame rate. However, I refer to some examples and aware some problems as following codes: 1). glBindTexture(GL_TEXTURE_2D, compressed_map1); 2). gluBuild2DMipmaps(GL_TEXTURE_2D, (image->components == 4) ? GL_COMPRESSED_RGBA_ARB : GL_COMPRESSED_RGB_ARB, image->width, image->height, image->format, GL_UNSIGNED_BYTE, image->pixels); The 1 and 2 above mean that lets have GL do the compression and then we can use "compressed_map1" to do texture mapping with MipMapping. My first problem is that can I use the "compressed_map1" to utilize the hardware to accelertae rendering speed??? 3). glBindTexture(GL_TEXTURE_2D, compressed_map2); 4). glCompressedTexImage2DARB(GL_TEXTURE_2D, 0, internalformat, image->width, image->height, 0, compressed_size, img); The image data of "compressed_map2" is got by 1 and 2 line and some processes, e.g, glGetTexLevelParameteriv(..) and img=malloc(..) etc. Then, the 4 line passes directly the compressed data( compressed_map2) to GL. However, I aware that using compressed_map2 can''t do the MipMapping. The example I refer to also reads the "dds file format" and then use glCompressedTexImage2DARB(..) by loop to achieve mipmapping. finally, My second problem is how to do mipmapping without reading "dds file" if the answer of my first problem is "NO"????? deeply Appreciate anyone to reply my question. ^^

Share this post


Link to post
Share on other sites
How the heck did you get glCompressedTexImage2DARB(...) to work in the first place? I am trying to figure out dds loading from the nvidia source (the nv_dds.cpp compiles, but my main prog says that function is an undeclared identifier!!!)

Share this post


Link to post
Share on other sites
You can't use gluBuild2DMipmaps, use .dds format textures, these have mipmaps stored in the file, in compressed form.

the second parametre of the glCompressedTexImage2DARB command indicates the mipmap level you are loading to. As long as the image has dimmension of at least 1 by n or n by 1, you can load it.
The data for each mip level is simply head after the previous.

as far as I know there is no way to efficently generate a compressed mipmap without generating a mipmap normally, then software compressing it, then loading it, which is a massive waste of processor time since the compression isn't very fast.

As I say, just use the .dds format, it's a _very_ good format and the photoshop plugins you can get, and editors (such as ati's compressonator) make using them extremly easy.

The important thing to know is that when they are loaded into the video card, a .dds file takes up the same size as the file itself. Including mipmaps. All other textures (except luminance/pallet) are 32 bit (24 bit is converted). This gives dxtc/s3tc roughly a 12-1 compression ratio when on the video card compared to 32bit, Also, they load directly, they don't need format conversion,(it's effectivly a memory copy), so they are EXTREMLY fast to load. Generating mipmaps would destroy this advantage. They are pretty much now becomming a standard format, with the exception of things like bump maps. They also zip very nice. Overall pretty much perfect lossy game format.

| - Project-X - my mega project.. getting warmer - | - adDeath - an ad blocker I made - | - email me - |

[edited by - RipTorn on April 21, 2003 4:28:01 AM]

Share this post


Link to post
Share on other sites