Compresses data to a DXT format using nVidia's Texture Tools library. The data must be in unsigned byte RGBA format. The alpha channel will be ignored if DxtType is IL_DXT1. DxtSize is used to return the size in bytes of the DXTC data returned.
| 83 | // The data must be in unsigned byte RGBA format. The alpha channel will be ignored if DxtType is IL_DXT1. |
| 84 | // DxtSize is used to return the size in bytes of the DXTC data returned. |
| 85 | ILAPI ILubyte* ILAPIENTRY ilNVidiaCompressDXT(ILubyte *Data, ILuint Width, ILuint Height, ILuint Depth, ILenum DxtFormat, ILuint *DxtSize) |
| 86 | { |
| 87 | if (Data == NULL) { // We cannot operate on a null pointer. |
| 88 | ilSetError(IL_INVALID_PARAM); |
| 89 | return NULL; |
| 90 | } |
| 91 | |
| 92 | // The nVidia Texture Tools library does not support volume textures yet. |
| 93 | if (Depth != 1) { |
| 94 | ilSetError(IL_INVALID_PARAM); |
| 95 | return NULL; |
| 96 | } |
| 97 | |
| 98 | InputOptions inputOptions; |
| 99 | inputOptions.setTextureLayout(TextureType_2D, Width, Height); |
| 100 | inputOptions.setMipmapData(Data, Width, Height); |
| 101 | inputOptions.setMipmapGeneration(false, -1); //@TODO: Use this in certain cases. |
| 102 | |
| 103 | OutputOptions outputOptions; |
| 104 | ilOutputHandlerMem outputHandler(Width, Height, DxtFormat); |
| 105 | outputOptions.setOutputHeader(false); |
| 106 | outputOptions.setOutputHandler(&outputHandler); |
| 107 | |
| 108 | if (outputHandler.NewData == NULL) |
| 109 | return NULL; |
| 110 | |
| 111 | CompressionOptions compressionOptions; |
| 112 | switch (DxtFormat) |
| 113 | { |
| 114 | case IL_DXT1: |
| 115 | compressionOptions.setFormat(Format_DXT1); |
| 116 | break; |
| 117 | case IL_DXT1A: |
| 118 | compressionOptions.setFormat(Format_DXT1a); |
| 119 | break; |
| 120 | case IL_DXT3: |
| 121 | compressionOptions.setFormat(Format_DXT1); |
| 122 | break; |
| 123 | case IL_DXT5: |
| 124 | compressionOptions.setFormat(Format_DXT5); |
| 125 | break; |
| 126 | default: // Does not support DXT2 or DXT4. |
| 127 | ilSetError(IL_INVALID_PARAM); |
| 128 | break; |
| 129 | } |
| 130 | |
| 131 | Compressor compressor; |
| 132 | compressor.process(inputOptions, compressionOptions, outputOptions); |
| 133 | |
| 134 | *DxtSize = outputHandler.Size; |
| 135 | return outputHandler.NewData; |
| 136 | } |
| 137 | |
| 138 | |
| 139 |
nothing calls this directly
no test coverage detected