Add experimental image based interface.
This commit is contained in:
parent
5070cc98d3
commit
299ad176fc
@ -9,6 +9,7 @@ NVIDIA Texture Tools version 2.0.2
|
|||||||
* Fix vc8 post build command, reported by Richard Sim.
|
* Fix vc8 post build command, reported by Richard Sim.
|
||||||
* Fix RGBA modes with less than 32 bpp by Viktor Linder.
|
* Fix RGBA modes with less than 32 bpp by Viktor Linder.
|
||||||
* Fix alpha decompression by amorilia. See issue 40.
|
* Fix alpha decompression by amorilia. See issue 40.
|
||||||
|
* Avoid default-initialized constructors for POD types, reported by Jim Tilander.
|
||||||
|
|
||||||
NVIDIA Texture Tools version 2.0.1
|
NVIDIA Texture Tools version 2.0.1
|
||||||
* Fix memory leaks.
|
* Fix memory leaks.
|
||||||
|
60
src/nvtt/experimental/nvtt_experimental.cpp
Normal file
60
src/nvtt/experimental/nvtt_experimental.cpp
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
|
||||||
|
#include "nvtt_experimental.h"
|
||||||
|
|
||||||
|
struct NvttImage
|
||||||
|
{
|
||||||
|
NvttImage() :
|
||||||
|
m_constant(false),
|
||||||
|
m_image(NULL),
|
||||||
|
m_floatImage(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~NvttImage()
|
||||||
|
{
|
||||||
|
if (m_constant && m_image) m_image->unwrap();
|
||||||
|
delete m_image;
|
||||||
|
delete m_floatImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool m_constant;
|
||||||
|
Image * m_image;
|
||||||
|
FloatImage * m_floatImage;
|
||||||
|
};
|
||||||
|
|
||||||
|
NvttImage * nvttCreateImage()
|
||||||
|
{
|
||||||
|
return new NvttImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
void nvttDestroyImage(NvttImage * img)
|
||||||
|
{
|
||||||
|
delete img;
|
||||||
|
}
|
||||||
|
|
||||||
|
void nvttSetImageData(NvttImage * img, NvttInputFormat format, uint w, uint h, void * data)
|
||||||
|
{
|
||||||
|
nvCheck(img != NULL);
|
||||||
|
|
||||||
|
if (format == NVTT_InputFormat_BGRA_8UB)
|
||||||
|
{
|
||||||
|
img->m_constant = false;
|
||||||
|
img->m_image->allocate(w, h);
|
||||||
|
memcpy(img->m_image->pixels(), data, w * h * 4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nvCheck(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void nvttCompressImage(NvttImage * img, NvttFormat format)
|
||||||
|
{
|
||||||
|
nvCheck(img != NULL);
|
||||||
|
|
||||||
|
// @@ Invoke appropriate compressor.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // NVTT_EXPERIMENTAL_H
|
55
src/nvtt/experimental/nvtt_experimental.h
Normal file
55
src/nvtt/experimental/nvtt_experimental.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
|
||||||
|
#ifndef NVTT_EXPERIMENTAL_H
|
||||||
|
#define NVTT_EXPERIMENTAL_H
|
||||||
|
|
||||||
|
#include <nvtt/nvtt.h>
|
||||||
|
|
||||||
|
typedef struct NvttImage NvttImage;
|
||||||
|
|
||||||
|
NvttImage * nvttCreateImage();
|
||||||
|
void nvttDestroyImage(NvttImage * img);
|
||||||
|
|
||||||
|
void nvttSetImageData(NvttImage * img, NvttInputFormat format, uint w, uint h, void * data);
|
||||||
|
|
||||||
|
void nvttCompressImage(NvttImage * img, NvttFormat format);
|
||||||
|
|
||||||
|
// How to control the compression parameters?
|
||||||
|
|
||||||
|
// Using many arguments:
|
||||||
|
// void nvttCompressImage(img, format, quality, r, g, b, a, ...);
|
||||||
|
|
||||||
|
// Using existing compression option class:
|
||||||
|
// compressionOptions = nvttCreateCompressionOptions();
|
||||||
|
// nvttSetCompressionOptionsFormat(compressionOptions, format);
|
||||||
|
// nvttSetCompressionOptionsQuality(compressionOptions, quality);
|
||||||
|
// nvttSetCompressionOptionsQuality(compressionOptions, quality);
|
||||||
|
// nvttSetCompressionOptionsColorWeights(compressionOptions, r, g, b, a);
|
||||||
|
// ...
|
||||||
|
// nvttCompressImage(img, compressionOptions);
|
||||||
|
|
||||||
|
// Using thread local context state:
|
||||||
|
// void nvttSetCompressionFormat(format);
|
||||||
|
// void nvttSetCompressionQuality(quality);
|
||||||
|
// void nvttSetCompressionColorWeights(r, g, b, a);
|
||||||
|
// ...
|
||||||
|
// nvttCompressImage(img);
|
||||||
|
|
||||||
|
// Using thread local context state, but with GL style function arguments:
|
||||||
|
// nvttCompressorParameteri(NVTT_FORMAT, format);
|
||||||
|
// nvttCompressorParameteri(NVTT_QUALITY, quality);
|
||||||
|
// nvttCompressorParameterf(NVTT_COLOR_WEIGHT_RED, r);
|
||||||
|
// nvttCompressorParameterf(NVTT_COLOR_WEIGHT_GREEN, g);
|
||||||
|
// nvttCompressorParameterf(NVTT_COLOR_WEIGHT_BLUE, b);
|
||||||
|
// nvttCompressorParameterf(NVTT_COLOR_WEIGHT_ALPHA, a);
|
||||||
|
// or nvttCompressorParameter4f(NVTT_COLOR_WEIGHTS, r, g, b, a);
|
||||||
|
// ...
|
||||||
|
// nvttCompressImage(img);
|
||||||
|
|
||||||
|
// How do we get the compressed output?
|
||||||
|
// - Using callbacks. (via new entrypoints, or through outputOptions)
|
||||||
|
// - Return it explicitely from nvttCompressImage.
|
||||||
|
// - Store it along the image, retrieve later explicitely with 'nvttGetCompressedData(img, ...)'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // NVTT_EXPERIMENTAL_H
|
@ -207,7 +207,6 @@ NVTT_API void nvttDestroyCompressionOptions(NvttCompressionOptions * compression
|
|||||||
NVTT_API void nvttSetCompressionOptionsFormat(NvttCompressionOptions * compressionOptions, NvttFormat format);
|
NVTT_API void nvttSetCompressionOptionsFormat(NvttCompressionOptions * compressionOptions, NvttFormat format);
|
||||||
NVTT_API void nvttSetCompressionOptionsQuality(NvttCompressionOptions * compressionOptions, NvttQuality quality);
|
NVTT_API void nvttSetCompressionOptionsQuality(NvttCompressionOptions * compressionOptions, NvttQuality quality);
|
||||||
NVTT_API void nvttSetCompressionOptionsColorWeights(NvttCompressionOptions * compressionOptions, float red, float green, float blue, float alpha);
|
NVTT_API void nvttSetCompressionOptionsColorWeights(NvttCompressionOptions * compressionOptions, float red, float green, float blue, float alpha);
|
||||||
NVTT_API void nvttEnableCompressionOptionsCudaCompression(NvttCompressionOptions * compressionOptions, NvttBoolean enable);
|
|
||||||
NVTT_API void nvttSetCompressionOptionsPixelFormat(NvttCompressionOptions * compressionOptions, unsigned int bitcount, unsigned int rmask, unsigned int gmask, unsigned int bmask, unsigned int amask);
|
NVTT_API void nvttSetCompressionOptionsPixelFormat(NvttCompressionOptions * compressionOptions, unsigned int bitcount, unsigned int rmask, unsigned int gmask, unsigned int bmask, unsigned int amask);
|
||||||
NVTT_API void nvttSetCompressionOptionsQuantization(NvttCompressionOptions * compressionOptions, NvttBoolean colorDithering, NvttBoolean alphaDithering, NvttBoolean binaryAlpha, int alphaThreshold);
|
NVTT_API void nvttSetCompressionOptionsQuantization(NvttCompressionOptions * compressionOptions, NvttBoolean colorDithering, NvttBoolean alphaDithering, NvttBoolean binaryAlpha, int alphaThreshold);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user