Apply patch to update C# wraper. Fixes issue 184.

pull/216/head
castano 10 years ago
parent f705b2eaa1
commit ac87eefa6d

@ -421,9 +421,19 @@ namespace Nvidia.TextureTools
public class OutputOptions
{
#region Delegates
public delegate void ErrorHandler(Error error);
private delegate void WriteDataDelegate(IntPtr data, int size);
private delegate void ImageDelegate(int size, int width, int height, int depth, int face, int miplevel);
public delegate void ErrorHandler(Error error);
//[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
//public delegate void InternalErrorHandlerDelegate(Error error);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void BeginImageDelegate(int size, int width, int height, int depth, int face, int miplevel);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate bool WriteDataDelegate(IntPtr data, int size);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void EndImageDelegate();
#endregion
#region Bindings
@ -447,8 +457,8 @@ namespace Nvidia.TextureTools
[DllImport("nvtt"), SuppressUnmanagedCodeSecurity]
private extern static void nvttSetOutputOptionsOutputHeader(IntPtr outputOptions, bool b);
//[DllImport("nvtt"), SuppressUnmanagedCodeSecurity]
//private extern static void nvttSetOutputOptionsOutputHandler(IntPtr outputOptions, WriteDataDelegate writeData, ImageDelegate image);
[DllImport("nvtt", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
private extern static void nvttSetOutputOptionsOutputHandler(IntPtr outputOptions, IntPtr beginImage, IntPtr writeData, IntPtr endImage);
#endregion
@ -476,7 +486,21 @@ namespace Nvidia.TextureTools
nvttSetOutputOptionsOutputHeader(options, b);
}
// @@ Add OutputHandler interface.
public void SetOutputHandler(BeginImageDelegate beginImage, WriteDataDelegate writeImage, EndImageDelegate endImage)
{
IntPtr ptrBeginImage = IntPtr.Zero;
IntPtr ptrWriteData = IntPtr.Zero;
IntPtr ptrEndImage = IntPtr.Zero;
if (beginImage != null || writeImage != null || endImage != null)
{
ptrBeginImage = Marshal.GetFunctionPointerForDelegate(beginImage);
ptrWriteData = Marshal.GetFunctionPointerForDelegate(writeImage);
ptrEndImage = Marshal.GetFunctionPointerForDelegate(endImage);
}
nvttSetOutputOptionsOutputHandler(options, ptrBeginImage, ptrWriteData, ptrEndImage);
}
}
#endregion

@ -117,6 +117,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hdrtest", "hdrtest\hdrtest.
{4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hlslparser", "hlslparser\hlslparser.vcproj", "{FEBA8AE3-0628-4870-B087-05A4974F0729}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bc7", "bc7\bc7.vcproj", "{F974F34B-AF02-4C88-8E1E-85475094EA78}"
EndProject
Global
@ -419,6 +421,26 @@ Global
{E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Release-CUDA|Win32.Build.0 = Release|Win32
{E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Release-CUDA|x64.ActiveCfg = Release|x64
{E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Release-CUDA|x64.Build.0 = Release|x64
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Debug|Win32.ActiveCfg = Debug|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Debug|Win32.Build.0 = Debug|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Debug|x64.ActiveCfg = Debug|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Debug-CUDA|Mixed Platforms.ActiveCfg = Debug|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Debug-CUDA|Mixed Platforms.Build.0 = Debug|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Debug-CUDA|Win32.Build.0 = Debug|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Debug-CUDA|x64.ActiveCfg = Debug|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Release|Mixed Platforms.Build.0 = Release|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Release|Win32.ActiveCfg = Release|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Release|Win32.Build.0 = Release|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Release|x64.ActiveCfg = Release|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Release-CUDA|Mixed Platforms.ActiveCfg = Release|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Release-CUDA|Mixed Platforms.Build.0 = Release|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Release-CUDA|Win32.ActiveCfg = Release|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Release-CUDA|Win32.Build.0 = Release|Win32
{FEBA8AE3-0628-4870-B087-05A4974F0729}.Release-CUDA|x64.ActiveCfg = Release|Win32
{F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug|Win32.ActiveCfg = Debug|Win32
{F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug|Win32.Build.0 = Debug|Win32
{F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug|x64.ActiveCfg = Debug|x64

@ -1,79 +1,79 @@
// Copyright (c) 2009-2011 Ignacio Castano <castano@gmail.com>
// Copyright (c) 2007-2009 NVIDIA Corporation -- Ignacio Castano <icastano@nvidia.com>
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#include "CompressorDX10.h"
#include "QuickCompressDXT.h"
#include "OptimalCompressDXT.h"
#include "nvtt.h"
#include "nvimage/ColorBlock.h"
#include "nvimage/BlockDXT.h"
#include <new> // placement new
using namespace nv;
using namespace nvtt;
void FastCompressorBC4::compressBlock(ColorBlock & rgba, nvtt::AlphaMode alphaMode, const nvtt::CompressionOptions::Private & compressionOptions, void * output)
{
BlockATI1 * block = new(output) BlockATI1;
rgba.swizzle(0, 1, 2, 0); // Copy red to alpha
QuickCompress::compressDXT5A(rgba, &block->alpha);
}
void FastCompressorBC5::compressBlock(ColorBlock & rgba, nvtt::AlphaMode alphaMode, const nvtt::CompressionOptions::Private & compressionOptions, void * output)
{
BlockATI2 * block = new(output) BlockATI2;
rgba.swizzle(0, 1, 2, 0); // Copy red to alpha
QuickCompress::compressDXT5A(rgba, &block->x);
rgba.swizzle(0, 1, 2, 1); // Copy green to alpha
QuickCompress::compressDXT5A(rgba, &block->y);
}
void ProductionCompressorBC4::compressBlock(ColorBlock & rgba, nvtt::AlphaMode alphaMode, const nvtt::CompressionOptions::Private & compressionOptions, void * output)
{
BlockATI1 * block = new(output) BlockATI1;
rgba.swizzle(0, 1, 2, 0); // Copy red to alpha
OptimalCompress::compressDXT5A(rgba, &block->alpha);
}
void ProductionCompressorBC5::compressBlock(ColorBlock & rgba, nvtt::AlphaMode alphaMode, const nvtt::CompressionOptions::Private & compressionOptions, void * output)
{
BlockATI2 * block = new(output) BlockATI2;
rgba.swizzle(0, 1, 2, 0); // Copy red to alpha
OptimalCompress::compressDXT5A(rgba, &block->x);
rgba.swizzle(0, 1, 2, 1); // Copy green to alpha
OptimalCompress::compressDXT5A(rgba, &block->y);
}
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#include "CompressorDX10.h"
#include "QuickCompressDXT.h"
#include "OptimalCompressDXT.h"
#include "nvtt.h"
#include "nvimage/ColorBlock.h"
#include "nvimage/BlockDXT.h"
#include <new> // placement new
using namespace nv;
using namespace nvtt;
void FastCompressorBC4::compressBlock(ColorBlock & rgba, nvtt::AlphaMode alphaMode, const nvtt::CompressionOptions::Private & compressionOptions, void * output)
{
BlockATI1 * block = new(output) BlockATI1;
rgba.swizzle(0, 1, 2, 0); // Copy red to alpha
QuickCompress::compressDXT5A(rgba, &block->alpha);
}
void FastCompressorBC5::compressBlock(ColorBlock & rgba, nvtt::AlphaMode alphaMode, const nvtt::CompressionOptions::Private & compressionOptions, void * output)
{
BlockATI2 * block = new(output) BlockATI2;
rgba.swizzle(0, 1, 2, 0); // Copy red to alpha
QuickCompress::compressDXT5A(rgba, &block->x);
rgba.swizzle(0, 1, 2, 1); // Copy green to alpha
QuickCompress::compressDXT5A(rgba, &block->y);
}
void ProductionCompressorBC4::compressBlock(ColorBlock & rgba, nvtt::AlphaMode alphaMode, const nvtt::CompressionOptions::Private & compressionOptions, void * output)
{
BlockATI1 * block = new(output) BlockATI1;
rgba.swizzle(0, 1, 2, 0); // Copy red to alpha
OptimalCompress::compressDXT5A(rgba, &block->alpha);
}
void ProductionCompressorBC5::compressBlock(ColorBlock & rgba, nvtt::AlphaMode alphaMode, const nvtt::CompressionOptions::Private & compressionOptions, void * output)
{
BlockATI2 * block = new(output) BlockATI2;
rgba.swizzle(0, 1, 2, 0); // Copy red to alpha
OptimalCompress::compressDXT5A(rgba, &block->x);
rgba.swizzle(0, 1, 2, 1); // Copy green to alpha
OptimalCompress::compressDXT5A(rgba, &block->y);
}

@ -77,6 +77,8 @@ namespace nvtt
int version;
bool srgb;
bool deleteOutputHandler;
void * wrapperProxy; // For the C/C# wrapper.
bool hasValidOutputHandler() const;

@ -73,8 +73,9 @@ namespace nvtt
// Supported compression formats.
// @@ I wish I had distinguished between "formats" and compressors.
// That is, 'DXT1' is a format 'DXT1a' and 'DXT1n' are DXT1 compressors.
// That is, 'DXT3' is a format 'DXT3n' is a DXT3 compressor.
// That is:
// - 'DXT1' is a format 'DXT1a' and 'DXT1n' are DXT1 compressors.
// - 'DXT3' is a format 'DXT3n' is a DXT3 compressor.
// Having multiple enums for the same ids only creates confusion. Clean this up.
enum Format
{
@ -98,13 +99,11 @@ namespace nvtt
Format_BC4, // ATI1
Format_BC5, // 3DC, ATI2
Format_DXT1n, // Not supported on CPU yet.
Format_CTX1, // Not supported on CPU yet.
Format_DXT1n, // Not supported.
Format_CTX1, // Not supported.
Format_BC6,
Format_BC7,
Format_DXT1_Luma,
};
// Pixel types. These basically indicate how the output should be interpreted, but do not have any influence over the input. They are only relevant in RGBA mode.
@ -133,7 +132,6 @@ namespace nvtt
Decoder_D3D10,
Decoder_D3D9,
Decoder_NV5x,
//Decoder_RSX, // To take advantage of DXT5 bug.
};
@ -163,7 +161,7 @@ namespace nvtt
NVTT_API void setPitchAlignment(int pitchAlignment);
// @@ I wish this wasn't part of the compression options. Quantization is applied before compression. We don't have compressors with error diffusion.
NVTT_API void setQuantization(bool colorDithering, bool alphaDithering, bool binaryAlpha, int alphaThreshold = 127);
NVTT_API void setQuantization(bool colorDithering, bool alphaDithering, bool binaryAlpha, int alphaThreshold = 127); // (Deprecated in NVTT 2.1)
NVTT_API void setTargetDecoder(Decoder decoder);
@ -243,7 +241,7 @@ namespace nvtt
AlphaMode_Premultiplied,
};
// Input options. Specify format and layout of the input texture.
// Input options. Specify format and layout of the input texture. (Deprecated in NVTT 2.1)
struct InputOptions
{
NVTT_FORBID_COPY(InputOptions);
@ -303,7 +301,7 @@ namespace nvtt
// Output data. Compressed data is output as soon as it's generated to minimize memory allocations.
virtual bool writeData(const void * data, int size) = 0;
// Indicate the end of a the compressed image.
// Indicate the end of a the compressed image. (New in NVTT 2.1)
virtual void endImage() = 0;
};
@ -363,8 +361,10 @@ namespace nvtt
NVTT_API void setSrgbFlag(bool b);
};
// (New in NVTT 2.1)
typedef void Task(void * context, int id);
// (New in NVTT 2.1)
struct TaskDispatcher
{
virtual void dispatch(Task * task, void * context, int count) = 0;
@ -382,23 +382,23 @@ namespace nvtt
// Context settings.
NVTT_API void enableCudaAcceleration(bool enable);
NVTT_API bool isCudaAccelerationEnabled() const;
NVTT_API void setTaskDispatcher(TaskDispatcher * disp);
NVTT_API void setTaskDispatcher(TaskDispatcher * disp); // (New in NVTT 2.1)
// InputOptions API.
NVTT_API bool process(const InputOptions & inputOptions, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const;
NVTT_API int estimateSize(const InputOptions & inputOptions, const CompressionOptions & compressionOptions) const;
// Surface API.
// Surface API. (New in NVTT 2.1)
NVTT_API bool outputHeader(const Surface & img, int mipmapCount, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const;
NVTT_API bool compress(const Surface & img, int face, int mipmap, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const;
NVTT_API int estimateSize(const Surface & img, int mipmapCount, const CompressionOptions & compressionOptions) const;
// CubeSurface API.
// CubeSurface API. (New in NVTT 2.1)
NVTT_API bool outputHeader(const CubeSurface & cube, int mipmapCount, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const;
NVTT_API bool compress(const CubeSurface & cube, int mipmap, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const;
NVTT_API int estimateSize(const CubeSurface & cube, int mipmapCount, const CompressionOptions & compressionOptions) const;
// Raw API.
// Raw API. (New in NVTT 2.1)
NVTT_API bool outputHeader(TextureType type, int w, int h, int d, int mipmapCount, bool isNormalMap, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const;
NVTT_API bool compress(int w, int h, int d, int face, int mipmap, const float * rgba, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const;
NVTT_API int estimateSize(int w, int h, int d, int mipmapCount, const CompressionOptions & compressionOptions) const;
@ -407,6 +407,7 @@ namespace nvtt
// "Compressor" is deprecated. This should have been called "Context"
typedef Compressor Context;
// (New in NVTT 2.1)
enum NormalTransform {
NormalTransform_Orthographic,
NormalTransform_Stereographic,
@ -415,6 +416,7 @@ namespace nvtt
//NormalTransform_DualParaboloid,
};
// (New in NVTT 2.1)
enum ToneMapper {
ToneMapper_Linear,
ToneMapper_Reindhart,
@ -422,15 +424,8 @@ namespace nvtt
ToneMapper_Lightmap,
};
/*enum ChannelMask {
R = 0x70000001,
G = 0x70000002,
B = 0x70000004,
A = 0x70000008,
};*/
// A surface is one level of a 2D or 3D texture.
// @@ It would be nice to add support for texture borders for correct resizing of tiled textures and constrained DXT compression.
// A surface is one level of a 2D or 3D texture. (New in NVTT 2.1)
struct Surface
{
NVTT_API Surface();
@ -559,7 +554,7 @@ namespace nvtt
};
// Cube layout formats.
// Cube layout formats. (New in NVTT 2.1)
enum CubeLayout {
CubeLayout_VerticalCross,
CubeLayout_HorizontalCross,
@ -568,6 +563,7 @@ namespace nvtt
CubeLayout_LatitudeLongitude
};
// (New in NVTT 2.1)
enum EdgeFixup {
EdgeFixup_None,
EdgeFixup_Stretch,
@ -575,7 +571,7 @@ namespace nvtt
EdgeFixup_Average,
};
// A CubeSurface is one level of a cube map texture.
// A CubeSurface is one level of a cube map texture. (New in NVTT 2.1)
struct CubeSurface
{
NVTT_API CubeSurface();
@ -645,6 +641,7 @@ namespace nvtt
// Return NVTT version.
NVTT_API unsigned int version();
// Image comparison and error measurement functions. (New in NVTT 2.1)
NVTT_API float rmsError(const Surface & reference, const Surface & img);
NVTT_API float rmsAlphaError(const Surface & reference, const Surface & img);
NVTT_API float cieLabError(const Surface & reference, const Surface & img);

@ -25,207 +25,269 @@
#include "nvtt.h"
#include "nvtt_wrapper.h"
#include "OutputOptions.h"
// An OutputHandler that sets and calls function pointers, rather than
// requiring interfaces to derive from OutputHandler itself
struct HandlerProxy : public nvtt::OutputHandler
{
public:
HandlerProxy() {}
nvttBeginImageHandler beginImageHandler;
nvttOutputHandler writeDataHandler;
nvttEndImageHandler endImageHandler;
virtual void beginImage(int size, int width, int height, int depth, int face, int miplevel)
{
if (beginImageHandler != NULL)
{
beginImageHandler(size, width, height, depth, face, miplevel);
}
}
virtual bool writeData(const void * data, int size)
{
if (writeDataHandler != NULL)
{
return writeDataHandler(data, size);
}
return false;
}
virtual void endImage()
{
if (endImageHandler != NULL)
{
endImageHandler();
}
}
};
// InputOptions class.
NvttInputOptions * nvttCreateInputOptions()
{
return new nvtt::InputOptions();
return new nvtt::InputOptions();
}
void nvttDestroyInputOptions(NvttInputOptions * inputOptions)
{
delete inputOptions;
delete inputOptions;
}
void nvttSetInputOptionsTextureLayout(NvttInputOptions * inputOptions, NvttTextureType type, int w, int h, int d)
{
inputOptions->setTextureLayout((nvtt::TextureType)type, w, h, d);
inputOptions->setTextureLayout((nvtt::TextureType)type, w, h, d);
}
void nvttResetInputOptionsTextureLayout(NvttInputOptions * inputOptions)
{
inputOptions->resetTextureLayout();
inputOptions->resetTextureLayout();
}
NvttBoolean nvttSetInputOptionsMipmapData(NvttInputOptions * inputOptions, const void * data, int w, int h, int d, int face, int mipmap)
{
return (NvttBoolean)inputOptions->setMipmapData(data, w, h, d, face, mipmap);
return (NvttBoolean)inputOptions->setMipmapData(data, w, h, d, face, mipmap);
}
void nvttSetInputOptionsFormat(NvttInputOptions * inputOptions, NvttInputFormat format)
{
inputOptions->setFormat((nvtt::InputFormat)format);
inputOptions->setFormat((nvtt::InputFormat)format);
}
void nvttSetInputOptionsAlphaMode(NvttInputOptions * inputOptions, NvttAlphaMode alphaMode)
{
inputOptions->setAlphaMode((nvtt::AlphaMode)alphaMode);
inputOptions->setAlphaMode((nvtt::AlphaMode)alphaMode);
}
void nvttSetInputOptionsGamma(NvttInputOptions * inputOptions, float inputGamma, float outputGamma)
{
inputOptions->setGamma(inputGamma, outputGamma);
inputOptions->setGamma(inputGamma, outputGamma);
}
void nvttSetInputOptionsWrapMode(NvttInputOptions * inputOptions, NvttWrapMode mode)
{
inputOptions->setWrapMode((nvtt::WrapMode)mode);
inputOptions->setWrapMode((nvtt::WrapMode)mode);
}
void nvttSetInputOptionsMipmapFilter(NvttInputOptions * inputOptions, NvttMipmapFilter filter)
{
inputOptions->setMipmapFilter((nvtt::MipmapFilter)filter);
inputOptions->setMipmapFilter((nvtt::MipmapFilter)filter);
}
void nvttSetInputOptionsMipmapGeneration(NvttInputOptions * inputOptions, NvttBoolean enabled, int maxLevel)
{
inputOptions->setMipmapGeneration(enabled != NVTT_False, maxLevel);
inputOptions->setMipmapGeneration(enabled != NVTT_False, maxLevel);
}
void nvttSetInputOptionsKaiserParameters(NvttInputOptions * inputOptions, float width, float alpha, float stretch)
{
inputOptions->setKaiserParameters(width, alpha, stretch);
inputOptions->setKaiserParameters(width, alpha, stretch);
}
void nvttSetInputOptionsNormalMap(NvttInputOptions * inputOptions, NvttBoolean b)
{
inputOptions->setNormalMap(b != NVTT_False);
inputOptions->setNormalMap(b != NVTT_False);
}
void nvttSetInputOptionsConvertToNormalMap(NvttInputOptions * inputOptions, NvttBoolean convert)
{
inputOptions->setConvertToNormalMap(convert != NVTT_False);
inputOptions->setConvertToNormalMap(convert != NVTT_False);
}
void nvttSetInputOptionsHeightEvaluation(NvttInputOptions * inputOptions, float redScale, float greenScale, float blueScale, float alphaScale)
{
inputOptions->setHeightEvaluation(redScale, greenScale, blueScale, alphaScale);
inputOptions->setHeightEvaluation(redScale, greenScale, blueScale, alphaScale);
}
void nvttSetInputOptionsNormalFilter(NvttInputOptions * inputOptions, float small, float medium, float big, float large)
{
inputOptions->setNormalFilter(small, medium, big, large);
inputOptions->setNormalFilter(small, medium, big, large);
}
void nvttSetInputOptionsNormalizeMipmaps(NvttInputOptions * inputOptions, NvttBoolean b)
{
inputOptions->setNormalizeMipmaps(b != NVTT_False);
inputOptions->setNormalizeMipmaps(b != NVTT_False);
}
void nvttSetInputOptionsMaxExtents(NvttInputOptions * inputOptions, int dim)
{
inputOptions->setMaxExtents(dim);
inputOptions->setMaxExtents(dim);
}
void nvttSetInputOptionsRoundMode(NvttInputOptions * inputOptions, NvttRoundMode mode)
{
inputOptions->setRoundMode((nvtt::RoundMode)mode);
inputOptions->setRoundMode((nvtt::RoundMode)mode);
}
// CompressionOptions class.
NvttCompressionOptions * nvttCreateCompressionOptions()
{
return new nvtt::CompressionOptions();
return new nvtt::CompressionOptions();
}
void nvttDestroyCompressionOptions(NvttCompressionOptions * compressionOptions)
{
delete compressionOptions;
delete compressionOptions;
}
void nvttSetCompressionOptionsFormat(NvttCompressionOptions * compressionOptions, NvttFormat format)
{
compressionOptions->setFormat((nvtt::Format)format);
compressionOptions->setFormat((nvtt::Format)format);
}
void nvttSetCompressionOptionsQuality(NvttCompressionOptions * compressionOptions, NvttQuality quality)
{
compressionOptions->setQuality((nvtt::Quality)quality);
compressionOptions->setQuality((nvtt::Quality)quality);
}
void nvttSetCompressionOptionsColorWeights(NvttCompressionOptions * compressionOptions, float red, float green, float blue, float alpha)
{
compressionOptions->setColorWeights(red, green, blue, alpha);
compressionOptions->setColorWeights(red, green, blue, alpha);
}
/*void nvttEnableCompressionOptionsCudaCompression(NvttCompressionOptions * compressionOptions, NvttBoolean enable)
{
compressionOptions->enableCudaCompression(enable != NVTT_False);
compressionOptions->enableCudaCompression(enable != NVTT_False);
}*/
void nvttSetCompressionOptionsPixelFormat(NvttCompressionOptions * compressionOptions, unsigned int bitcount, unsigned int rmask, unsigned int gmask, unsigned int bmask, unsigned int amask)
{
compressionOptions->setPixelFormat(bitcount, rmask, gmask, bmask, amask);
compressionOptions->setPixelFormat(bitcount, rmask, gmask, bmask, amask);
}
void nvttSetCompressionOptionsQuantization(NvttCompressionOptions * compressionOptions, NvttBoolean colorDithering, NvttBoolean alphaDithering, NvttBoolean binaryAlpha, int alphaThreshold)
{
compressionOptions->setQuantization(colorDithering != NVTT_False, alphaDithering != NVTT_False, binaryAlpha != NVTT_False, alphaThreshold);
compressionOptions->setQuantization(colorDithering != NVTT_False, alphaDithering != NVTT_False, binaryAlpha != NVTT_False, alphaThreshold);
}
// OutputOptions class.
NvttOutputOptions * nvttCreateOutputOptions()
{
return new nvtt::OutputOptions();
nvtt::OutputOptions * outputOptions = new nvtt::OutputOptions();
HandlerProxy * handlerProxy = new HandlerProxy();
outputOptions->m.wrapperProxy = handlerProxy;
return outputOptions;
}
void nvttDestroyOutputOptions(NvttOutputOptions * outputOptions)
{
delete outputOptions;
HandlerProxy * handlerProxy = (HandlerProxy *)outputOptions->m.wrapperProxy;
delete handlerProxy;
delete outputOptions;
}
void nvttSetOutputOptionsFileName(NvttOutputOptions * outputOptions, const char * fileName)
{
outputOptions->setFileName(fileName);
outputOptions->setFileName(fileName);
}
void nvttSetOutputOptionsOutputHeader(NvttOutputOptions * outputOptions, NvttBoolean b)
{
outputOptions->setOutputHeader(b != NVTT_False);
outputOptions->setOutputHeader(b != NVTT_False);
}
/*
void nvttSetOutputOptionsErrorHandler(NvttOutputOptions * outputOptions, nvttErrorHandler errorHandler)
{
outputOptions->setErrorHandler(errorHandler);
outputOptions->setErrorHandler(errorHandler);
}
*/
void nvttSetOutputOptionsOutputHandler(NvttOutputOptions * outputOptions, nvttOutputHandler outputHandler, nvttImageHandler imageHandler)
void nvttSetOutputOptionsOutputHandler(NvttOutputOptions * outputOptions, nvttBeginImageHandler beginImageHandler, nvttOutputHandler writeDataHandler, nvttEndImageHandler endImageHandler)
{
HandlerProxy * handler = (HandlerProxy *)outputOptions->m.wrapperProxy;
handler->beginImageHandler = beginImageHandler;
handler->writeDataHandler = writeDataHandler;
handler->endImageHandler = endImageHandler;
if(beginImageHandler == NULL && writeDataHandler == NULL && endImageHandler == NULL)
{
outputOptions->setOutputHandler(NULL);
}
else
{
outputOptions->setOutputHandler(handler);
}
}
*/
// Compressor class.
NvttCompressor * nvttCreateCompressor()
{
return new nvtt::Compressor();
return new nvtt::Compressor();
}
void nvttDestroyCompressor(NvttCompressor * compressor)
{
delete compressor;
delete compressor;
}
NvttBoolean nvttCompress(const NvttCompressor * compressor, const NvttInputOptions * inputOptions, const NvttCompressionOptions * compressionOptions, const NvttOutputOptions * outputOptions)
{
return (NvttBoolean)compressor->process(*inputOptions, *compressionOptions, *outputOptions);
return (NvttBoolean)compressor->process(*inputOptions, *compressionOptions, *outputOptions);
}
int nvttEstimateSize(const NvttCompressor * compressor, const NvttInputOptions * inputOptions, const NvttCompressionOptions * compressionOptions)
{
return compressor->estimateSize(*inputOptions, *compressionOptions);
return compressor->estimateSize(*inputOptions, *compressionOptions);
}
// Global functions.
const char * nvttErrorString(NvttError e)
{
return nvtt::errorString((nvtt::Error)e);
return nvtt::errorString((nvtt::Error)e);
}
unsigned int nvttVersion()
{
return nvtt::version();
return nvtt::version();
}

@ -166,8 +166,9 @@ extern "C" {
// Callbacks
//typedef void (* nvttErrorHandler)(NvttError e);
//typedef void (* nvttOutputHandler)(const void * data, int size);
//typedef void (* nvttImageHandler)(int size, int width, int height, int depth, int face, int miplevel);
typedef void (* nvttBeginImageHandler)(int size, int width, int height, int depth, int face, int miplevel);
typedef bool (* nvttOutputHandler)(const void * data, int size);
typedef void (* nvttEndImageHandler)();
// InputOptions class.
@ -211,7 +212,7 @@ NVTT_API void nvttDestroyOutputOptions(NvttOutputOptions * outputOptions);
NVTT_API void nvttSetOutputOptionsFileName(NvttOutputOptions * outputOptions, const char * fileName);
NVTT_API void nvttSetOutputOptionsOutputHeader(NvttOutputOptions * outputOptions, NvttBoolean b);
//NVTT_API void nvttSetOutputOptionsErrorHandler(NvttOutputOptions * outputOptions, nvttErrorHandler errorHandler);
//NVTT_API void nvttSetOutputOptionsOutputHandler(NvttOutputOptions * outputOptions, nvttOutputHandler outputHandler, nvttImageHandler imageHandler);
NVTT_API void nvttSetOutputOptionsOutputHandler(NvttOutputOptions * outputOptions, nvttBeginImageHandler beginImageHandler, nvttOutputHandler outputHandler, nvttEndImageHandler endImageHandler);
// Compressor class.

Loading…
Cancel
Save