• Advertisement
Sign in to follow this  

Saving out dds dxt5 with Devil/Opengl

This topic is 2773 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


Hey guys, I've been racking my brain trying to figure this out and it seems it is beyond me. I'm trying to compress some RGBA data and then save it out using DevIL



void compressBlock(void* uBuf, unsigned char* cBuf, int xSize, int ySize, bool ogl, int dxtformat)
{

if (ogl)
{
GLuint temp;
glGenTextures(1, &temp);
glBindTexture(GL_TEXTURE_2D, temp);
glTexImage2D(GL_TEXTURE_2D, 0, dxtformat, xSize, ySize, 0, GL_RGBA, GL_UNSIGNED_BYTE, uBuf);
glGetCompressedTexImage(GL_TEXTURE_2D, 0, cBuf);
glDeleteTextures(1, &temp);

}

}




this first method returns cbuf with the compressed data which is then passed into an ImageObject structure I've created, which is turn is passed :




bool ImageSaver::saveWithDevil(const ImageObject& src, const char* filename)
{
if (!g_DevilInitialised)
DevilInitialise();

int devFmt = FormatTranslate_GLToDevil(src.getFormat()); // return = IL_DXT5
int chNum = GetNumberOfChannels(src.getFormat()); // return = 1

ILuint devil_id;

ilGenImages(1, &devil_id);
ilBindImage(devil_id);

ilSetInteger(IL_DXTC_FORMAT, devFmt);

ilTexImage(src.getSize().x, src.getSize().y, 1, chNum, devFmt, IL_UNSIGNED_BYTE, 0);
void* ptr = ilGetData();
memcpy(ptr, src.getData(), src.getSize().x*src.getSize().y*glGetImageFormatSize(src.getFormat()));


ilEnable(IL_FILE_OVERWRITE);
bool ret = ilSaveImage((ILstring)filename) ? true:false;

ilBindImage(0);
ilDeleteImages(1, &devil_id);

return ret;
}




Is there anything wrong with this as you see it? I'm finding it difficult to find a code snippet that does something similar, which indicates that I am getting it wildly wrong. Any help would be really great.

Thank you, Nic.

Share this post


Link to post
Share on other sites
Advertisement

Okay the solution to this isn't really a solution. DevIL actually has the capability to compress within it. After downloading the source, i saw that it can use Nvidia, squish or its own system to compress DDS files.

I wish I'd known that before i spent a week reading up on dds and dxt compression. Oh well, we live and learn.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement