diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..7674a17 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: csharp +os: + - osx +compiler: + - clang + - gcc +script: +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir build ; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cd build ; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cmake -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" -DNVTT_SHARED="TRUE" .. ; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then make ; fi diff --git a/project/vc12/Nvidia.TextureTools.UnitTests/Nvidia.TextureTools.UnitTests.csproj b/project/vc12/Nvidia.TextureTools.UnitTests/Nvidia.TextureTools.UnitTests.csproj new file mode 100644 index 0000000..b5f50fa --- /dev/null +++ b/project/vc12/Nvidia.TextureTools.UnitTests/Nvidia.TextureTools.UnitTests.csproj @@ -0,0 +1,46 @@ + + + + Debug + AnyCPU + {553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA} + Library + Nvidia.TextureTools.UnitTests + Nvidia.TextureTools.UnitTests + v4.6.1 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + + + true + bin\Release + prompt + 4 + + + + + ..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll + + + + + + + + {CAB55C39-8FA9-4912-98D9-E52669C8911D} + Nvidia.TextureTools + + + + + + + \ No newline at end of file diff --git a/project/vc12/Nvidia.TextureTools.UnitTests/Test.cs b/project/vc12/Nvidia.TextureTools.UnitTests/Test.cs new file mode 100644 index 0000000..2c516c9 --- /dev/null +++ b/project/vc12/Nvidia.TextureTools.UnitTests/Test.cs @@ -0,0 +1,66 @@ +using NUnit.Framework; +using System; +using Nvidia.TextureTools; +using System.Runtime.InteropServices; + +namespace Nvidia.TextureTools.UnitTests { + [TestFixture ()] + public class Test { + [Test ()] + public void TestCase () + { + var inputOptions = new InputOptions (); + var outputOptions = new OutputOptions (); + var compressionOptions = new CompressionOptions (); + var compressor = new Compressor (); + inputOptions.SetAlphaMode (AlphaMode.Premultiplied); + inputOptions.SetTextureLayout (TextureType.Texture2D, 128, 128, 1); + byte [] sourceData = new byte [128*128*4]; + var dataHandle = GCHandle.Alloc (sourceData, GCHandleType.Pinned); + var BeginImage = new OutputOptions.BeginImageHandler (BeginImageInternal); + var WriteData = new OutputOptions.OutputHandler (WriteDataInternal); + var EndImage = new OutputOptions.EndImageHandler (EndImageInternal); + var a = GCHandle.Alloc (BeginImage); + var b = GCHandle.Alloc (WriteData); + var c = GCHandle.Alloc (EndImage); + try { + var dataPtr = dataHandle.AddrOfPinnedObject (); + inputOptions.SetMipmapData (dataPtr, 128, 128, 1, 0, 0); + inputOptions.SetMipmapGeneration (false); + inputOptions.SetGamma (1.0f, 1.0f); + compressionOptions.SetFormat (Format.RGBA); + outputOptions.SetOutputHeader (false); + outputOptions.SetOutputOptionsOutputHandler (BeginImage, WriteData, EndImage); + var estsize = compressor.EstimateSize (inputOptions, compressionOptions); + Assert.True (compressor.Compress (inputOptions, compressionOptions, outputOptions)); + Assert.AreEqual (estsize, buffer.Length); + }finally { + a.Free (); + b.Free (); + c.Free (); + dataHandle.Free (); + } + } + + byte [] buffer; + int offset; + + void BeginImageInternal (int size, int width, int height, int depth, int face, int miplevel) + { + buffer = new byte [size]; + offset = 0; + } + + bool WriteDataInternal (IntPtr data, int length) + { + Marshal.Copy (data, buffer, offset, length); + offset += length; + return true; + } + + void EndImageInternal () + { + // add done write the buffer. + } + } +} diff --git a/project/vc12/Nvidia.TextureTools.UnitTests/packages.config b/project/vc12/Nvidia.TextureTools.UnitTests/packages.config new file mode 100644 index 0000000..b93fa21 --- /dev/null +++ b/project/vc12/Nvidia.TextureTools.UnitTests/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/project/vc12/Nvidia.TextureTools/Nvidia.TextureTools.csproj b/project/vc12/Nvidia.TextureTools/Nvidia.TextureTools.csproj index e4d8d6f..0ae8e2d 100644 --- a/project/vc12/Nvidia.TextureTools/Nvidia.TextureTools.csproj +++ b/project/vc12/Nvidia.TextureTools/Nvidia.TextureTools.csproj @@ -44,6 +44,11 @@ + + + PreserveNewest + +