Add nvtt plain C wrapper.
This commit is contained in:
parent
1d5d3d7270
commit
1a14b8a1ba
86
src/nvtt/nvtt_wrapper.cpp
Normal file
86
src/nvtt/nvtt_wrapper.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
|
||||
|
||||
|
||||
// Input Options
|
||||
NvttInputOptions nvttCreateInputOptions()
|
||||
{
|
||||
return (NvttInputOptions *) new nvtt::InputOptions();
|
||||
}
|
||||
|
||||
void nvttDestroyInputOptions(NvttInputOptions inputOptions)
|
||||
{
|
||||
delete (nvtt::InputOptions *) inputOptions;
|
||||
}
|
||||
|
||||
void nvttSetInputOptionsTextureLayout(NvttInputOptions inputOptions, NvttTextureType type, int w, int h, int d)
|
||||
{
|
||||
((nvtt::InputOptions *)inputOptions)->setTextureLayout(type, w, h, d);
|
||||
}
|
||||
|
||||
void nvttResetInputOptionsTextureLayout(NvttInputOptions inputOptions)
|
||||
{
|
||||
((nvtt::InputOptions *)inputOptions)->resetTextureLayout();
|
||||
}
|
||||
|
||||
NvttBoolean nvttSetInputOptionsMipmapData(NvttInputOptions inputOptions, const void * data, int w, int h, int d, int face, int mipmap)
|
||||
{
|
||||
return ((nvtt::InputOptions *)inputOptions)->setMipmapData(data, w, h, d, face, mipmap);
|
||||
}
|
||||
|
||||
|
||||
// Compression Options
|
||||
NvttCompressionOptions nvttCreateCompressionOptions()
|
||||
{
|
||||
return (NvttCompressionOptions *) new nvtt::CompressionOptions();
|
||||
}
|
||||
|
||||
void nvttDestroyCompressionOptions(NvttCompressionOptions compressionOptions)
|
||||
{
|
||||
delete (nvtt::CompressionOptions *) compressionOptions;
|
||||
}
|
||||
|
||||
void nvttSetCompressionOptionsFormat(NvttCompressionOptions compressionOptions, NvttFormat format)
|
||||
{
|
||||
((nvtt::CompressionOptions *)compressionOptions)->setFormat(format);
|
||||
}
|
||||
|
||||
void nvttSetCompressionOptionsQuality(NvttCompressionOptions compressionOptionso, NvttQuality quality)
|
||||
{
|
||||
((nvtt::CompressionOptions *)compressionOptions)->setQuality(quality);
|
||||
}
|
||||
|
||||
void nvttSetCompressionOptionsPixelFormat(unsigned int bitcount, unsigned int rmask, unsigned int gmask, unsigned int bmask, unsigned int amask)
|
||||
{
|
||||
((nvtt::CompressionOptions *)compressionOptions)->setPixelFormat(bitcount, rmask, gmask, bmask, amask);
|
||||
}
|
||||
|
||||
|
||||
// Output Options
|
||||
NvttOutputOptions nvttCreateOutputOptions()
|
||||
{
|
||||
return (NvttOutputOptions *) new nvtt::OutputOptions();
|
||||
}
|
||||
|
||||
void nvttDestroyOutputOptions(NvttOutputOptions outputOptions)
|
||||
{
|
||||
delete (nvtt::OutputOptions *) outputOptions;
|
||||
}
|
||||
|
||||
void nvttSetOutputOptionsFileName(NvttOutputOptions outputOptions, const char * fileName)
|
||||
{
|
||||
((nvtt::OutputOptions *)outputOptions)->setFileName(fileName);
|
||||
}
|
||||
|
||||
|
||||
// Main entrypoint of the compression library.
|
||||
NvttBoolean nvttCompress(NvttInputOptions inputOptions, NvttOutputOptions outputOptions, NvttCompressionOptions compressionOptions)
|
||||
{
|
||||
return nvtt::compress((nvtt::InputOptions *)inputOptions, (nvtt::OutputOptions *)outputOptions, (nvtt::CompressionOptions *)compressionOptions);
|
||||
}
|
||||
|
||||
// Estimate the size of compressing the input with the given options.
|
||||
int nvttEstimateSize(NvttInputOptions inputOptions, NvttCompressionOptions compressionOptions)
|
||||
{
|
||||
return nvtt::estimateSize((nvtt::InputOptions *)inputOptions, (nvtt::CompressionOptions *)compressionOptions);
|
||||
}
|
||||
|
135
src/nvtt/nvtt_wrapper.h
Normal file
135
src/nvtt/nvtt_wrapper.h
Normal file
@ -0,0 +1,135 @@
|
||||
// Copyright NVIDIA Corporation 2007 -- 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.
|
||||
|
||||
#ifndef NVTT_CWRAPPER_H
|
||||
#define NVTT_CWRAPPER_H
|
||||
|
||||
#include <nvcore/nvcore.h>
|
||||
|
||||
// Function linkage
|
||||
#if NVTT_SHARED
|
||||
#ifdef NVTT_EXPORTS
|
||||
#define NVTT_API DLL_EXPORT
|
||||
#define NVTT_CLASS DLL_EXPORT_CLASS
|
||||
#else
|
||||
#define NVTT_API DLL_IMPORT
|
||||
#define NVTT_CLASS DLL_IMPORT
|
||||
#endif
|
||||
#else
|
||||
#define NVTT_API
|
||||
#define NVTT_CLASS
|
||||
#endif
|
||||
|
||||
typedef struct InputOptions * NvttInputOptions;
|
||||
typedef struct CompressionOptions * NvttCompressionOptions;
|
||||
typedef struct OutputOptions * NvttOutputOptions;
|
||||
|
||||
|
||||
/// Supported compression formats.
|
||||
typedef enum
|
||||
{
|
||||
// No compression.
|
||||
NVTT_Format_RGB,
|
||||
NVTT_Format_RGBA = NVTT_Format_RGB,
|
||||
|
||||
// DX9 formats.
|
||||
NVTT_Format_DXT1,
|
||||
NVTT_Format_DXT1a,
|
||||
NVTT_Format_DXT3,
|
||||
NVTT_Format_DXT5,
|
||||
NVTT_Format_DXT5n,
|
||||
|
||||
// DX10 formats.
|
||||
NVTT_Format_BC1 = NVTT_Format_DXT1,
|
||||
NVTT_Format_BC1a = NVTT_Format_DXT1a,
|
||||
NVTT_Format_BC2 = NVTT_Format_DXT3,
|
||||
NVTT_Format_BC3 = NVTT_Format_DXT5,
|
||||
NVTT_Format_BC3n = NVTT_Format_DXT5n,
|
||||
NVTT_Format_BC4,
|
||||
NVTT_Format_BC5,
|
||||
} NvttFormat;
|
||||
|
||||
/// Quality modes.
|
||||
typedef enum
|
||||
{
|
||||
NVTT_Quality_Fastest,
|
||||
NVTT_Quality_Normal,
|
||||
NVTT_Quality_Production,
|
||||
NVTT_Quality_Highest,
|
||||
} NvttQuality;
|
||||
|
||||
/// Texture types.
|
||||
typedef enum
|
||||
{
|
||||
NVTT_TextureType_2D,
|
||||
NVTT_TextureType_Cube,
|
||||
} NvttTextureType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NVTT_True,
|
||||
NVTT_False,
|
||||
} NvttBoolean;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Input Options
|
||||
NVTT_API NvttInputOptions nvttCreateInputOptions();
|
||||
NVTT_API void nvttDestroyInputOptions(NvttInputOptions inputOptions);
|
||||
|
||||
NVTT_API void nvttSetInputOptionsTextureLayout(NvttInputOptions inputOptions, NvttTextureType type, int w, int h, int d);
|
||||
NVTT_API void nvttResetInputOptionsTextureLayout(NvttInputOptions inputOptions);
|
||||
NVTT_API NvttBoolean nvttSetInputOptionsMipmapData(NvttInputOptions inputOptions, const void * data, int w, int h, int d, int face, int mipmap);
|
||||
|
||||
|
||||
// Compression Options
|
||||
NVTT_API NvttCompressionOptions nvttCreateCompressionOptions();
|
||||
NVTT_API void nvttDestroyCompressionOptions(NvttCompressionOptions compressionOptions);
|
||||
|
||||
NVTT_API void nvttSetCompressionOptionsFormat(NvttCompressionOptions compressionOptions, NvttFormat format);
|
||||
NVTT_API void nvttSetCompressionOptionsQuality(NvttCompressionOptions compressionOptions, NvttQuality quality);
|
||||
NVTT_API void nvttSetCompressionOptionsPixelFormat(unsigned int bitcount, unsigned int rmask, unsigned int gmask, unsigned int bmask, unsigned int amask);
|
||||
|
||||
|
||||
// Output Options
|
||||
NVTT_API NvttOutputOptions nvttCreateOutputOptions();
|
||||
NVTT_API void nvttDestroyOutputOptions(NvttOutputOptions outputOptions);
|
||||
|
||||
NVTT_API void nvttSetOutputOptionsFileName(NvttOutputOptions outputOptions, const char * fileName);
|
||||
|
||||
|
||||
// Main entrypoint of the compression library.
|
||||
NVTT_API NvttBoolean nvttCompress(NvttInputOptions inputOptions, NvttOutputOptions outputOptions, NvttCompressionOptions compressionOptions);
|
||||
|
||||
// Estimate the size of compressing the input with the given options.
|
||||
NVTT_API int nvttEstimateSize(NvttInputOptions inputOptions, NvttCompressionOptions compressionOptions);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // NVTT_CWRAPPER_H
|
Loading…
Reference in New Issue
Block a user