Start implementing experimental interface.
parent
e965b0e4a9
commit
508f9fbdc2
@ -0,0 +1,131 @@
|
||||
// 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.
|
||||
|
||||
#include "Texture.h"
|
||||
|
||||
using namespace nvtt;
|
||||
|
||||
|
||||
Texture::Texture() : m(*new Texture::Private())
|
||||
{
|
||||
}
|
||||
|
||||
Texture::~Texture()
|
||||
{
|
||||
delete &m;
|
||||
}
|
||||
|
||||
Texture::Texture(const Texture & tex) : m(*new Texture::Private())
|
||||
{
|
||||
// @@ Not implemented.
|
||||
}
|
||||
|
||||
void Texture::operator=(const Texture & tex)
|
||||
{
|
||||
// @@ Not implemented.
|
||||
}
|
||||
|
||||
bool Texture::load(const char * fileName)
|
||||
{
|
||||
// @@ Not implemented.
|
||||
return false;
|
||||
}
|
||||
|
||||
void Texture::setType(TextureType type)
|
||||
{
|
||||
m.type = type;
|
||||
}
|
||||
|
||||
void Texture::setTexture2D(InputFormat format, int w, int h, int idx, void * data)
|
||||
{
|
||||
// @@ Not implemented.
|
||||
}
|
||||
|
||||
void Texture::resize(int w, int h, ResizeFilter filter)
|
||||
{
|
||||
// if cubemap, make sure w==h.s
|
||||
// @@ Not implemented.
|
||||
}
|
||||
|
||||
bool Texture::buildMipmap(MipmapFilter filter)
|
||||
{
|
||||
// @@ Not implemented.
|
||||
}
|
||||
|
||||
// Color transforms.
|
||||
void Texture::toLinear(float gamma)
|
||||
{
|
||||
foreach(i, m.imageArray)
|
||||
{
|
||||
m.imageArray[i].toLinear(0, 3, gamma);
|
||||
}
|
||||
}
|
||||
|
||||
void Texture::toGamma(float gamma)
|
||||
{
|
||||
foreach(i, m.imageArray)
|
||||
{
|
||||
m.imageArray[i].toGamma(0, 3, gamma);
|
||||
}
|
||||
}
|
||||
|
||||
void Texture::transform(const float w0[4], const float w1[4], const float w2[4], const float w3[4], const float offset[4])
|
||||
{
|
||||
// @@ Not implemented.
|
||||
}
|
||||
|
||||
void Texture::swizzle(int r, int g, int b, int a)
|
||||
{
|
||||
foreach(i, m.imageArray)
|
||||
{
|
||||
m.imageArray[i].swizzle(0, r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
void Texture::scaleBias(int channel, float scale, float bias)
|
||||
{
|
||||
foreach(i, m.imageArray)
|
||||
{
|
||||
m.imageArray[i].scaleBias(channel, 1, scale, bias);
|
||||
}
|
||||
}
|
||||
|
||||
void Texture::normalize()
|
||||
{
|
||||
foreach(i, m.imageArray)
|
||||
{
|
||||
m.imageArray[i].normalize(0);
|
||||
}
|
||||
}
|
||||
|
||||
void Texture::blend(float r, float g, float b, float a)
|
||||
{
|
||||
// @@ Not implemented.
|
||||
}
|
||||
|
||||
void Texture::premultiplyAlpha()
|
||||
{
|
||||
// @@ Not implemented.
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,47 @@
|
||||
// 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 NV_TT_TEXTURE_H
|
||||
#define NV_TT_TEXTURE_H
|
||||
|
||||
#include "nvtt.h"
|
||||
|
||||
#include <nvcore/Containers.h>
|
||||
|
||||
#include <nvimage/Image.h>
|
||||
#include <nvimage/FloatImage.h>
|
||||
|
||||
namespace nvtt
|
||||
{
|
||||
|
||||
struct Texture::Private
|
||||
{
|
||||
TextureType type;
|
||||
nv::Array<nv::FloatImage> imageArray;
|
||||
};
|
||||
|
||||
|
||||
} // nvtt namespace
|
||||
|
||||
|
||||
#endif // NV_TT_TEXTURE_H
|
@ -0,0 +1,61 @@
|
||||
|
||||
#include "nvtt_experimental.h"
|
||||
|
||||
/*
|
||||
Errors in the original API:
|
||||
- Too many memory copies.
|
||||
- Implementation too complicated.
|
||||
- Error output should not be in output options.
|
||||
- Data driven interface. Follows the dialog model. Provide all the data upfront.
|
||||
*/
|
||||
|
||||
|
||||
// Output texture with mipmaps
|
||||
void example0()
|
||||
{
|
||||
CompressionOptions compressionOptions;
|
||||
OutputOptions outputOptions;
|
||||
|
||||
Texture img;
|
||||
img.setTexture2D(format, w, h, 0, data);
|
||||
|
||||
Compressor context;
|
||||
context.outputHeader(outputOptions);
|
||||
context.outputCompressed(img, compressionOptions, outputOptions);
|
||||
|
||||
img.toLinear(2.2);
|
||||
while (img.downsample(NVTT_FILTER_BOX))
|
||||
{
|
||||
img.toGamma(2.2);
|
||||
outputCompressed(img, compressionOptions, outputOptions);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Output texture with colored mipmaps
|
||||
void example1()
|
||||
{
|
||||
CompressionOptions compressionOptions;
|
||||
OutputOptions outputOptions;
|
||||
|
||||
Texture img;
|
||||
img.setTexture2D(format, w, h, 0, data);
|
||||
|
||||
Compressor context;
|
||||
context.outputHeader(outputOptions);
|
||||
context.outputCompressed(img, compressionOptions, outputOptions);
|
||||
|
||||
img.toLinear(2.2);
|
||||
while (img.downsample(NVTT_FILTER_BOX))
|
||||
{
|
||||
img.toGamma(2.2);
|
||||
|
||||
Texture mipmap = img;
|
||||
mipmap.blend(color[i].r, color[i].g, color[i].b, 0.5f);
|
||||
|
||||
context.outputCompressed(mipmap, compressionOptions, outputOptions);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue