.dds file format any heads up I should know...
I am currently using .tga files and am thinking you can't use .tga for cubemaps? or 3D textures? Is that correct? If so can one just code up a loader for .dds files or is it locked out? Also how hard is it to code a .dds loader? Thanks
you can get DDS working right from the specs over at MSDN I've done that myself and it's really not that hard, but I think there's free image loading libraries with DDS support available too, [google] can probably help you.
Quote:Original post by DigitalDelusion
you can get DDS working right from the specs over at MSDN I've done that myself and it's really not that hard, but I think there's free image loading libraries with DDS support available too, [google] can probably help you.
Thanks, but what about cubemap or 3D texture support in .tga files???
DDS is pretty easy, the spec are over on the MSDN site as DigitalDelusion said (DSS loader).
I'd beware of the free image loaders however, FreeImage looks like it decompresses them! and doesnt look like it has sane support for mipmaps/cubemaps/3d textures. God knows what DevIL does with them (the interface put me off looking much further), afaik SDL_Image doesnt support them and Corona doesnt either.
I have plans afoot to get my own image loader supporting DDS + other image types working, however I'm a bit behind where I wanted to be right now and I dare say you cant wait [grin]. If ya intrested however keep an eye on my journal as I'll be waffling about it from time to time...
edit: tga are just normal 2d images
I'd beware of the free image loaders however, FreeImage looks like it decompresses them! and doesnt look like it has sane support for mipmaps/cubemaps/3d textures. God knows what DevIL does with them (the interface put me off looking much further), afaik SDL_Image doesnt support them and Corona doesnt either.
I have plans afoot to get my own image loader supporting DDS + other image types working, however I'm a bit behind where I wanted to be right now and I dare say you cant wait [grin]. If ya intrested however keep an eye on my journal as I'll be waffling about it from time to time...
edit: tga are just normal 2d images
edit: seems like my guesstimate was um, well crap so ignore this post.
I haven't actually experimented with cubemaps or had the need for 3D textures myself so I can't help you with that. But basicly there shouldn't be a problem, I seriously can't imagine one anyhow, sure maybe you would need to convert to some funky data layout or something but that seems a bit, well, strange too.
A 3D texture should just be a lot of 2D ones stacked so that shouldn't be a problem and a cube map as far as I know isn't anything more complex than 6diffrent textures (one for each cube side) stored togheter.
I could be way off though.
Quote:Original post by MARS_999
Thanks, but what about cubemap or 3D texture support in .tga files???
I haven't actually experimented with cubemaps or had the need for 3D textures myself so I can't help you with that. But basicly there shouldn't be a problem, I seriously can't imagine one anyhow, sure maybe you would need to convert to some funky data layout or something but that seems a bit, well, strange too.
A 3D texture should just be a lot of 2D ones stacked so that shouldn't be a problem and a cube map as far as I know isn't anything more complex than 6diffrent textures (one for each cube side) stored togheter.
I could be way off though.
bool cTexture::LoadDDS(const char *filename){ DDSURFACEDESC2 ddsd; char filecode[4]; int factor; int bufferSize; int format; FILE *file=NULL; file = fopen(filename, "rb"); // Verify the file is a true .dds file fread(&filecode, 1, 4, file); if( strncmp( filecode, "DDS ", 4 ) != 0 ) { DebugManager->Print(Error, __FUNCTION__, "\"%s\" is not a valid .dds file !", filename); return false; } // Get the surface descriptor fread(&ddsd, 1, sizeof(ddsd), file); // // Type de compression switch(ddsd.ddpfPixelFormat.dwFourCC) { case FOURCC_DXT1: // DXT1's compression ratio is 8:1 format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; factor = 2; break; case FOURCC_DXT3: // DXT3's compression ratio is 4:1 format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; factor = 4; break; case FOURCC_DXT5: // DXT5's compression ratio is 4:1 format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; factor = 4; break; default: TODO("The file \"%s\" doesn't appear to be compressed using DXT1, DXT3, or DXT5!", filename); fclose(file); return false; break; } // // Taille du buffer // if(!ddsd.dwLinearSize) { DebugManager->Print(Error, __FUNCTION__, "ddsd.dwLinearSize is 0 !"); fclose(file); return false; } if (ddsd.dwMipMapCount > 1) bufferSize = ddsd.dwLinearSize * factor; else bufferSize = ddsd.dwLinearSize; ImageData = new unsigned char[bufferSize]; memset(ImageData, 0, bufferSize); int ret = 0; ret = fread(ImageData, 1, bufferSize, file); fclose(file); // Sauvegarde les infos Width = ddsd.dwWidth; Height = ddsd.dwHeight; if(ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT1 ) PixelFormat = PF_RGB; else PixelFormat = PF_RGBA; // // Generation de la texture glGenTextures(1, (GLuint *)&GLid); glBindTexture(GL_TEXTURE_2D, GLid); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); // Chargement des mipmaps int nSize = 0; int nOffset = 0; int nHeight = Height; int nWidth = Width; int nNumMipMaps = ddsd.dwMipMapCount; int nBlockSize = format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ? 8 : 16; for( unsigned long i = 0; i < ddsd.dwMipMapCount; ++i ) { if( nWidth == 0 ) nWidth = 1; if( nHeight == 0 ) nHeight = 1; nSize = ((nWidth+3)/4) * ((nHeight+3)/4) * nBlockSize; glCompressedTexImage2DARB( GL_TEXTURE_2D, i, format, nWidth, nHeight, 0, nSize, ImageData + nOffset ); nOffset += nSize; // Moitie de la taille pour le prochain mipmap... nWidth /= 2; nHeight /= 2; } return true;}
Quote:Original post by _the_phantom_Pardon my ignorance, but isn't that what you want the image loader to do, decompress the image and load it into a buffer/surface/whatever-you-use-in-API-of-choice?
I'd beware of the free image loaders however, FreeImage looks like it decompresses them!
Quote:Original post by _the_phantom_
I'd beware of the free image loaders however, FreeImage looks like it decompresses them! and doesnt look like it has sane support for mipmaps/cubemaps/3d textures.
Um, that's like exactly what Im doing to... OTOH I need them for pixel purposes so I really can't do it any other way but just out of curiosity how do you get OGL to actually swallow the compressed data? Im guessing extension but which one?
@benryves
not really, its fine for general image mipulation but given that both D3D and OGL can deal with DXT compressed textures directly. Stuff like PNG/JPG/etc needs to be converted however,its just with DDS it makes no sense when working on a game.
@DigitalDelusion
The GL_ARB_texture_compression extension allows you to load data directly to the gfx card if its supported (it was promoted to core in OpenGL 1.3 so should be widely avaiable), and both NV and ATI cards have excellent support for DXT compressed textures ofcourse. It also supports ATI's normal map compression (ATI X800 and NV G70 cards onwards).
not really, its fine for general image mipulation but given that both D3D and OGL can deal with DXT compressed textures directly. Stuff like PNG/JPG/etc needs to be converted however,its just with DDS it makes no sense when working on a game.
@DigitalDelusion
The GL_ARB_texture_compression extension allows you to load data directly to the gfx card if its supported (it was promoted to core in OpenGL 1.3 so should be widely avaiable), and both NV and ATI cards have excellent support for DXT compressed textures ofcourse. It also supports ATI's normal map compression (ATI X800 and NV G70 cards onwards).
Quote:Original post by _the_phantom_
@DigitalDelusion
The GL_ARB_texture_compression extension allows you to load data directly to the gfx card if its supported (it was promoted to core in OpenGL 1.3 so should be widely avaiable), and both NV and ATI cards have excellent support for DXT compressed textures ofcourse. It also supports ATI's normal map compression (ATI X800 and NV G70 cards onwards).
Ah, wonderful! thanks.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement