Merge pull request #301 from Starnick/master
Updated C-API to expose some functionality present in the C++ API
This commit is contained in:
commit
a131e4c6b0
@ -27,9 +27,9 @@
|
|||||||
|
|
||||||
#include "OutputOptions.h"
|
#include "OutputOptions.h"
|
||||||
|
|
||||||
// An OutputHandler that sets and calls function pointers, rather than
|
// An OutputHandler/ErrorHandler that sets and calls function pointers, rather than
|
||||||
// requiring interfaces to derive from OutputHandler itself
|
// requiring interfaces to derive from OutputHandler/ErrorHandler itself
|
||||||
struct HandlerProxy : public nvtt::OutputHandler
|
struct HandlerProxy : public nvtt::OutputHandler, public nvtt::ErrorHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -39,6 +39,8 @@ public:
|
|||||||
nvttOutputHandler writeDataHandler;
|
nvttOutputHandler writeDataHandler;
|
||||||
nvttEndImageHandler endImageHandler;
|
nvttEndImageHandler endImageHandler;
|
||||||
|
|
||||||
|
nvttErrorHandler errorHandler;
|
||||||
|
|
||||||
virtual void beginImage(int size, int width, int height, int depth, int face, int miplevel)
|
virtual void beginImage(int size, int width, int height, int depth, int face, int miplevel)
|
||||||
{
|
{
|
||||||
if (beginImageHandler != NULL)
|
if (beginImageHandler != NULL)
|
||||||
@ -64,6 +66,14 @@ public:
|
|||||||
endImageHandler();
|
endImageHandler();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void error(nvtt::Error e)
|
||||||
|
{
|
||||||
|
if (errorHandler != NULL)
|
||||||
|
{
|
||||||
|
errorHandler((NvttError)e);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -233,12 +243,32 @@ void nvttSetOutputOptionsOutputHeader(NvttOutputOptions * outputOptions, NvttBoo
|
|||||||
{
|
{
|
||||||
outputOptions->setOutputHeader(b != NVTT_False);
|
outputOptions->setOutputHeader(b != NVTT_False);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
|
void nvttSetOutputOptionsContainer(NvttOutputOptions * outputOptions, NvttContainer containerFormat)
|
||||||
|
{
|
||||||
|
outputOptions->setContainer((nvtt::Container)containerFormat);
|
||||||
|
}
|
||||||
|
|
||||||
|
void nvttSetOutputOptionsSrgbFlag(NvttOutputOptions * outputOptions, NvttBoolean b)
|
||||||
|
{
|
||||||
|
outputOptions->setSrgbFlag(b != NVTT_False);
|
||||||
|
}
|
||||||
|
|
||||||
void nvttSetOutputOptionsErrorHandler(NvttOutputOptions * outputOptions, nvttErrorHandler errorHandler)
|
void nvttSetOutputOptionsErrorHandler(NvttOutputOptions * outputOptions, nvttErrorHandler errorHandler)
|
||||||
{
|
{
|
||||||
outputOptions->setErrorHandler(errorHandler);
|
HandlerProxy * handler = (HandlerProxy *)outputOptions->m.wrapperProxy;
|
||||||
|
|
||||||
|
handler->errorHandler = errorHandler;
|
||||||
|
|
||||||
|
if (errorHandler == NULL)
|
||||||
|
{
|
||||||
|
outputOptions->setErrorHandler(NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
outputOptions->setErrorHandler(handler);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
void nvttSetOutputOptionsOutputHandler(NvttOutputOptions * outputOptions, nvttBeginImageHandler beginImageHandler, nvttOutputHandler writeDataHandler, nvttEndImageHandler endImageHandler)
|
void nvttSetOutputOptionsOutputHandler(NvttOutputOptions * outputOptions, nvttBeginImageHandler beginImageHandler, nvttOutputHandler writeDataHandler, nvttEndImageHandler endImageHandler)
|
||||||
{
|
{
|
||||||
@ -270,6 +300,16 @@ void nvttDestroyCompressor(NvttCompressor * compressor)
|
|||||||
delete compressor;
|
delete compressor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nvttEnableCudaAcceleration(NvttCompressor * compressor, NvttBoolean b)
|
||||||
|
{
|
||||||
|
compressor->enableCudaAcceleration(b != NVTT_False);
|
||||||
|
}
|
||||||
|
|
||||||
|
NvttBoolean nvttIsCudaAccelerationEnabled(const NvttCompressor* compressor)
|
||||||
|
{
|
||||||
|
return (NvttBoolean)compressor->isCudaAccelerationEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
NvttBoolean nvttCompress(const NvttCompressor * compressor, const NvttInputOptions * inputOptions, const NvttCompressionOptions * compressionOptions, const NvttOutputOptions * outputOptions)
|
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);
|
||||||
|
@ -171,18 +171,26 @@ typedef enum
|
|||||||
NVTT_AlphaMode_Premultiplied,
|
NVTT_AlphaMode_Premultiplied,
|
||||||
} NvttAlphaMode;
|
} NvttAlphaMode;
|
||||||
|
|
||||||
|
// Error codes.
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
NVTT_Error_Unknown,
|
||||||
NVTT_Error_InvalidInput,
|
NVTT_Error_InvalidInput,
|
||||||
NVTT_Error_UserInterruption,
|
|
||||||
NVTT_Error_UnsupportedFeature,
|
NVTT_Error_UnsupportedFeature,
|
||||||
NVTT_Error_CudaError,
|
NVTT_Error_CudaError,
|
||||||
NVTT_Error_Unknown,
|
|
||||||
NVTT_Error_FileOpen,
|
NVTT_Error_FileOpen,
|
||||||
NVTT_Error_FileWrite,
|
NVTT_Error_FileWrite,
|
||||||
NVTT_Error_UnsupportedOutputFormat,
|
NVTT_Error_UnsupportedOutputFormat,
|
||||||
} NvttError;
|
} NvttError;
|
||||||
|
|
||||||
|
// Output container format types.
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
NVTT_Container_DDS,
|
||||||
|
NVTT_Container_DDS10,
|
||||||
|
NVTT_Container_KTX,
|
||||||
|
} NvttContainer;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
NVTT_False,
|
NVTT_False,
|
||||||
@ -195,7 +203,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Callbacks
|
// Callbacks
|
||||||
//typedef void (* nvttErrorHandler)(NvttError e);
|
typedef void (* nvttErrorHandler)(NvttError e);
|
||||||
typedef void (* nvttBeginImageHandler)(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 bool (* nvttOutputHandler)(const void * data, int size);
|
||||||
typedef void (* nvttEndImageHandler)();
|
typedef void (* nvttEndImageHandler)();
|
||||||
@ -241,7 +249,9 @@ NVTT_API void nvttDestroyOutputOptions(NvttOutputOptions * outputOptions);
|
|||||||
|
|
||||||
NVTT_API void nvttSetOutputOptionsFileName(NvttOutputOptions * outputOptions, const char * fileName);
|
NVTT_API void nvttSetOutputOptionsFileName(NvttOutputOptions * outputOptions, const char * fileName);
|
||||||
NVTT_API void nvttSetOutputOptionsOutputHeader(NvttOutputOptions * outputOptions, NvttBoolean b);
|
NVTT_API void nvttSetOutputOptionsOutputHeader(NvttOutputOptions * outputOptions, NvttBoolean b);
|
||||||
//NVTT_API void nvttSetOutputOptionsErrorHandler(NvttOutputOptions * outputOptions, nvttErrorHandler errorHandler);
|
NVTT_API void nvttSetOutputOptionsContainer(NvttOutputOptions * outputOptions, NvttContainer containerFormat);
|
||||||
|
NVTT_API void nvttSetOutputOptionsSrgbFlag(NvttOutputOptions * outputOptions, NvttBoolean b);
|
||||||
|
NVTT_API void nvttSetOutputOptionsErrorHandler(NvttOutputOptions * outputOptions, nvttErrorHandler errorHandler);
|
||||||
NVTT_API void nvttSetOutputOptionsOutputHandler(NvttOutputOptions * outputOptions, nvttBeginImageHandler beginImageHandler, nvttOutputHandler outputHandler, nvttEndImageHandler endImageHandler);
|
NVTT_API void nvttSetOutputOptionsOutputHandler(NvttOutputOptions * outputOptions, nvttBeginImageHandler beginImageHandler, nvttOutputHandler outputHandler, nvttEndImageHandler endImageHandler);
|
||||||
|
|
||||||
|
|
||||||
@ -249,6 +259,8 @@ NVTT_API void nvttSetOutputOptionsOutputHandler(NvttOutputOptions * outputOption
|
|||||||
NVTT_API NvttCompressor * nvttCreateCompressor();
|
NVTT_API NvttCompressor * nvttCreateCompressor();
|
||||||
NVTT_API void nvttDestroyCompressor(NvttCompressor * compressor);
|
NVTT_API void nvttDestroyCompressor(NvttCompressor * compressor);
|
||||||
|
|
||||||
|
NVTT_API void nvttEnableCudaAcceleration(NvttCompressor * compressor, NvttBoolean b);
|
||||||
|
NVTT_API NvttBoolean nvttIsCudaAccelerationEnabled(const NvttCompressor* compressor);
|
||||||
NVTT_API NvttBoolean nvttCompress(const NvttCompressor * compressor, const NvttInputOptions * inputOptions, const NvttCompressionOptions * compressionOptions, const NvttOutputOptions * outputOptions);
|
NVTT_API NvttBoolean nvttCompress(const NvttCompressor * compressor, const NvttInputOptions * inputOptions, const NvttCompressionOptions * compressionOptions, const NvttOutputOptions * outputOptions);
|
||||||
NVTT_API int nvttEstimateSize(const NvttCompressor * compressor, const NvttInputOptions * inputOptions, const NvttCompressionOptions * compressionOptions);
|
NVTT_API int nvttEstimateSize(const NvttCompressor * compressor, const NvttInputOptions * inputOptions, const NvttCompressionOptions * compressionOptions);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user