Loading DXT compressed textures

Hi,

In my code I’m successfully loading in-memory textures. This is what I do for example for a 8-bit RGBA texture:

tex = Texture(guid)
tex.setup2dTexture(width, height, Texture.TUnsignedByte, Texture.FRgba)
tex_data = tex.makeRamImage()
tex_data.setData(image_data)

Now I want to do the same thing for DXT compressed in-memory textures. I understand that I should use something like:

 tex.setRamImage(tex_data, Texture.CMDxt1)

But I don’t clearly see how to replace the “setup2DTexture” call, because there’s no corresponding Texture Format in that case.

Should I use something like:

tex.setup2dTexture()
tex.setXSize(width)
tex.setYSize(height)
tex.setRamImage(tex_data, Texture.CMDxt1)

Would that be enough?

Thanks
-David

That should work. But calling:

tex.setup2DTexture(width, height, Texture.TUnsignedByte, Texture.FRgba)
tex.setRamImage(tex_data, Texture.CMDxt1)

is also appropriate. The format is still meaningful, even though TUnsignedByte is a bit of an exaggeration when in-memory compression is used.

David

Thanks

Would that also be appropriate for Dxt2, Dxt3, Dxt4 and Dxt5?

Yes. You should use either FRgba or FRgb, according to whether you wish to respect the alpha channel or not. Not sure whether it actually matters, but it’s never a bad idea to be precise. :slight_smile:

David