Jump to content
  • Advertisement
Sign in to follow this  
Scarlet Harlot

Saving out dds dxt5 with Devil/Opengl

This topic is 3039 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)

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

ILuint devil_id;

ilGenImages(1, &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()));

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

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

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

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!