MCPcopy Create free account
hub / github.com/DentonW/DevIL / ilNVidiaCompressDXTFile

Function ilNVidiaCompressDXTFile

DevIL/src-IL/src/il_nvidia.cpp:172–216  ·  view source on GitHub ↗

Compresses data to a DXT format using nVidia's Texture Tools library. This version is supposed to be completely internal to DevIL. The data must be in unsigned byte RGBA format. The alpha channel will be ignored if DxtType is IL_DXT1.

Source from the content-addressed store, hash-verified

170// This version is supposed to be completely internal to DevIL.
171// The data must be in unsigned byte RGBA format. The alpha channel will be ignored if DxtType is IL_DXT1.
172ILuint ilNVidiaCompressDXTFile(ILubyte *Data, ILuint Width, ILuint Height, ILuint Depth, ILenum DxtFormat)
173{
174 ILuint FilePos = itellw();
175
176 // The nVidia Texture Tools library does not support volume textures yet.
177 if (Depth != 1) {
178 ilSetError(IL_INVALID_PARAM);
179 return 0;
180 }
181
182 InputOptions inputOptions;
183 inputOptions.setTextureLayout(TextureType_2D, Width, Height);
184 inputOptions.setMipmapData(Data, Width, Height);
185 inputOptions.setMipmapGeneration(false, -1); //@TODO: Use this in certain cases.
186
187 OutputOptions outputOptions;
188 ilOutputHandlerFile outputHandler(Width, Height, DxtFormat);
189 outputOptions.setOutputHeader(false);
190 outputOptions.setOutputHandler(&outputHandler);
191
192 CompressionOptions compressionOptions;
193 switch (DxtFormat)
194 {
195 case IL_DXT1:
196 compressionOptions.setFormat(Format_DXT1);
197 break;
198 case IL_DXT1A:
199 compressionOptions.setFormat(Format_DXT1a);
200 break;
201 case IL_DXT3:
202 compressionOptions.setFormat(Format_DXT1);
203 break;
204 case IL_DXT5:
205 compressionOptions.setFormat(Format_DXT5);
206 break;
207 default: // Does not support DXT2 or DXT4.
208 ilSetError(IL_INVALID_PARAM);
209 break;
210 }
211
212 Compressor compressor;
213 compressor.process(inputOptions, compressionOptions, outputOptions);
214
215 return itellw() - FilePos; // Return the number of characters written.
216}
217
218#else
219// Let's have this so that the function is always created and exported, even if it does nothing.

Callers 1

CompressFunction · 0.85

Calls 1

ilSetErrorFunction · 0.85

Tested by

no test coverage detected