├── .gitignore ├── LICENSE.txt ├── PVRTexLibNET.sln ├── PVRTexLibNET ├── PVRTexLibNET.cs ├── PVRTexLibNET.csproj └── Properties │ └── AssemblyInfo.cs ├── PVRTexLibWrapper ├── PVRTexLibWrapper.cpp ├── PVRTexLibWrapper.h ├── PVRTexLibWrapper.vcxproj ├── PVRTexLibWrapper.vcxproj.filters ├── PVRTexTool │ └── Library │ │ ├── Include │ │ ├── PVRTArray.h │ │ ├── PVRTDecompress.h │ │ ├── PVRTError.h │ │ ├── PVRTGlobal.h │ │ ├── PVRTMap.h │ │ ├── PVRTString.h │ │ ├── PVRTTexture.h │ │ ├── PVRTexture.h │ │ ├── PVRTextureDefines.h │ │ ├── PVRTextureFormat.h │ │ ├── PVRTextureHeader.h │ │ ├── PVRTextureUtilities.h │ │ └── PVRTextureVersion.h │ │ ├── Linux_x86_32 │ │ └── libPVRTexLib.so │ │ ├── Linux_x86_64 │ │ └── libPVRTexLib.so │ │ ├── OSX_x86 │ │ └── libPVRTexLib.dylib │ │ ├── Windows_x86_32 │ │ ├── PVRTexLib.dll │ │ └── PVRTexLib.lib │ │ └── Windows_x86_64 │ │ ├── PVRTexLib.dll │ │ └── PVRTexLib.lib ├── Stdafx.cpp ├── Stdafx.h └── resource.h └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Roslyn cache directories 26 | *.ide/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | #NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | *_i.c 42 | *_p.c 43 | *_i.h 44 | *.ilk 45 | *.meta 46 | *.obj 47 | *.pch 48 | *.pdb 49 | *.pgc 50 | *.pgd 51 | *.rsp 52 | *.sbr 53 | *.tlb 54 | *.tli 55 | *.tlh 56 | *.tmp 57 | *.tmp_proj 58 | *.log 59 | *.vspscc 60 | *.vssscc 61 | .builds 62 | *.pidb 63 | *.svclog 64 | *.scc 65 | 66 | # Chutzpah Test files 67 | _Chutzpah* 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | *.cachefile 76 | 77 | # Visual Studio profiler 78 | *.psess 79 | *.vsp 80 | *.vspx 81 | 82 | # TFS 2012 Local Workspace 83 | $tf/ 84 | 85 | # Guidance Automation Toolkit 86 | *.gpState 87 | 88 | # ReSharper is a .NET coding add-in 89 | _ReSharper*/ 90 | *.[Rr]e[Ss]harper 91 | *.DotSettings.user 92 | 93 | # JustCode is a .NET coding addin-in 94 | .JustCode 95 | 96 | # TeamCity is a build add-in 97 | _TeamCity* 98 | 99 | # DotCover is a Code Coverage Tool 100 | *.dotCover 101 | 102 | # NCrunch 103 | _NCrunch_* 104 | .*crunch*.local.xml 105 | 106 | # MightyMoose 107 | *.mm.* 108 | AutoTest.Net/ 109 | 110 | # Web workbench (sass) 111 | .sass-cache/ 112 | 113 | # Installshield output folder 114 | [Ee]xpress/ 115 | 116 | # DocProject is a documentation generator add-in 117 | DocProject/buildhelp/ 118 | DocProject/Help/*.HxT 119 | DocProject/Help/*.HxC 120 | DocProject/Help/*.hhc 121 | DocProject/Help/*.hhk 122 | DocProject/Help/*.hhp 123 | DocProject/Help/Html2 124 | DocProject/Help/html 125 | 126 | # Click-Once directory 127 | publish/ 128 | 129 | # Publish Web Output 130 | *.[Pp]ublish.xml 131 | *.azurePubxml 132 | # TODO: Comment the next line if you want to checkin your web deploy settings 133 | # but database connection strings (with potential passwords) will be unencrypted 134 | *.pubxml 135 | *.publishproj 136 | 137 | # NuGet Packages 138 | *.nupkg 139 | # The packages folder can be ignored because of Package Restore 140 | **/packages/* 141 | # except build/, which is used as an MSBuild target. 142 | !**/packages/build/ 143 | # Uncomment if necessary however generally it will be regenerated when needed 144 | #!**/packages/repositories.config 145 | 146 | # Windows Azure Build Output 147 | csx/ 148 | *.build.csdef 149 | 150 | # Windows Store app package directory 151 | AppPackages/ 152 | 153 | # Others 154 | *.[Cc]ache 155 | ClientBin/ 156 | [Ss]tyle[Cc]op.* 157 | ~$* 158 | *~ 159 | *.dbmdl 160 | *.dbproj.schemaview 161 | *.pfx 162 | *.publishsettings 163 | node_modules/ 164 | bower_components/ 165 | 166 | # RIA/Silverlight projects 167 | Generated_Code/ 168 | 169 | # Backup & report files from converting an old project file 170 | # to a newer Visual Studio version. Backup files are not needed, 171 | # because we have git ;-) 172 | _UpgradeReport_Files/ 173 | Backup*/ 174 | UpgradeLog*.XML 175 | UpgradeLog*.htm 176 | 177 | # SQL Server files 178 | *.mdf 179 | *.ldf 180 | 181 | # Business Intelligence projects 182 | *.rdl.data 183 | *.bim.layout 184 | *.bim_*.settings 185 | 186 | # Microsoft Fakes 187 | FakesAssemblies/ 188 | 189 | # Node.js Tools for Visual Studio 190 | .ntvs_analysis.dat 191 | 192 | # Visual Studio 6 build log 193 | *.plg 194 | 195 | # Visual Studio 6 workspace options file 196 | *.opt 197 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Flying Development Studio LLC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PVRTexLibNET.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PVRTexLibNET", "PVRTexLibNET\PVRTexLibNET.csproj", "{BAAF1192-884B-4DA2-8C93-E738C2F452A4}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {7CC59D82-06E1-4BA7-8644-2552CBC34316} = {7CC59D82-06E1-4BA7-8644-2552CBC34316} 9 | EndProjectSection 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PVRTexLibWrapper", "PVRTexLibWrapper\PVRTexLibWrapper.vcxproj", "{7CC59D82-06E1-4BA7-8644-2552CBC34316}" 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|x64 = Debug|x64 16 | Debug|x86 = Debug|x86 17 | Release|x64 = Release|x64 18 | Release|x86 = Release|x86 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {BAAF1192-884B-4DA2-8C93-E738C2F452A4}.Debug|x64.ActiveCfg = Debug|x64 22 | {BAAF1192-884B-4DA2-8C93-E738C2F452A4}.Debug|x64.Build.0 = Debug|x64 23 | {BAAF1192-884B-4DA2-8C93-E738C2F452A4}.Debug|x86.ActiveCfg = Debug|x86 24 | {BAAF1192-884B-4DA2-8C93-E738C2F452A4}.Debug|x86.Build.0 = Debug|x86 25 | {BAAF1192-884B-4DA2-8C93-E738C2F452A4}.Release|x64.ActiveCfg = Release|x64 26 | {BAAF1192-884B-4DA2-8C93-E738C2F452A4}.Release|x64.Build.0 = Release|x64 27 | {BAAF1192-884B-4DA2-8C93-E738C2F452A4}.Release|x86.ActiveCfg = Release|x86 28 | {BAAF1192-884B-4DA2-8C93-E738C2F452A4}.Release|x86.Build.0 = Release|x86 29 | {7CC59D82-06E1-4BA7-8644-2552CBC34316}.Debug|x64.ActiveCfg = Debug|x64 30 | {7CC59D82-06E1-4BA7-8644-2552CBC34316}.Debug|x64.Build.0 = Debug|x64 31 | {7CC59D82-06E1-4BA7-8644-2552CBC34316}.Debug|x86.ActiveCfg = Debug|Win32 32 | {7CC59D82-06E1-4BA7-8644-2552CBC34316}.Debug|x86.Build.0 = Debug|Win32 33 | {7CC59D82-06E1-4BA7-8644-2552CBC34316}.Release|x64.ActiveCfg = Release|x64 34 | {7CC59D82-06E1-4BA7-8644-2552CBC34316}.Release|x64.Build.0 = Release|x64 35 | {7CC59D82-06E1-4BA7-8644-2552CBC34316}.Release|x86.ActiveCfg = Release|Win32 36 | {7CC59D82-06E1-4BA7-8644-2552CBC34316}.Release|x86.Build.0 = Release|Win32 37 | EndGlobalSection 38 | GlobalSection(SolutionProperties) = preSolution 39 | HideSolutionNode = FALSE 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /PVRTexLibNET/PVRTexLibNET.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace PVRTexLibNET 5 | { 6 | public enum PixelFormat : ulong 7 | { 8 | PVRTCI_2bpp_RGB, 9 | PVRTCI_2bpp_RGBA, 10 | PVRTCI_4bpp_RGB, 11 | PVRTCI_4bpp_RGBA, 12 | PVRTCII_2bpp, 13 | PVRTCII_4bpp, 14 | ETC1, 15 | DXT1, 16 | DXT2, 17 | DXT3, 18 | DXT4, 19 | DXT5, 20 | 21 | //These formats are identical to some DXT formats. 22 | BC1 = DXT1, 23 | BC2 = DXT3, 24 | BC3 = DXT5, 25 | 26 | //These are currently unsupported: 27 | BC4, 28 | BC5, 29 | BC6, 30 | BC7, 31 | 32 | //These are supported 33 | UYVY, 34 | YUY2, 35 | BW1bpp, 36 | SharedExponentR9G9B9E5, 37 | RGBG8888, 38 | GRGB8888, 39 | ETC2_RGB, 40 | ETC2_RGBA, 41 | ETC2_RGB_A1, 42 | EAC_R11, 43 | EAC_RG11, 44 | 45 | RGB565 = 0x5060561626772, 46 | RGBA4444 = 0x404040461626772, 47 | RGBA8888 = 0x808080861626772, 48 | } 49 | 50 | public enum ResizeMode 51 | { 52 | Nearest, 53 | Linear, 54 | Cubic, 55 | } 56 | 57 | public enum VariableType 58 | { 59 | UnsignedByteNorm, 60 | SignedByteNorm, 61 | UnsignedByte, 62 | SignedByte, 63 | UnsignedShortNorm, 64 | SignedShortNorm, 65 | UnsignedShort, 66 | SignedShort, 67 | UnsignedIntegerNorm, 68 | SignedIntegerNorm, 69 | UnsignedInteger, 70 | SignedInteger, 71 | Float, 72 | } 73 | 74 | public enum ColourSpace 75 | { 76 | lRGB, 77 | sRGB 78 | } 79 | 80 | public enum CompressorQuality 81 | { 82 | PVRTCFast = 0, 83 | PVRTCNormal, 84 | PVRTCHigh, 85 | PVRTCBest, 86 | 87 | ETCFast = 0, 88 | ETCFastPerceptual, 89 | ETCMedium, 90 | ETCMediumPerceptual, 91 | ETCSlow, 92 | ETCSlowPerceptual 93 | } 94 | 95 | public class PVRTexture : IDisposable 96 | { 97 | #region Interop 98 | private const string dllName = "PVRTexLibWrapper.dll"; 99 | 100 | [DllImport(dllName, CallingConvention = CallingConvention.Cdecl)] 101 | public static extern IntPtr CreateTexture(IntPtr data, uint u32Width, uint u32Height, uint u32Depth, PixelFormat ptFormat, bool preMultiplied, VariableType eChannelType, ColourSpace eColourspace); 102 | 103 | [DllImport(dllName, CallingConvention = CallingConvention.Cdecl)] 104 | public static extern IntPtr CreateTexture(string filePath); 105 | 106 | [DllImport(dllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] 107 | public static extern bool SaveTexture(IntPtr pPvrTexture, [MarshalAs(UnmanagedType.LPStr)] string filePath); 108 | 109 | [DllImport(dllName, CallingConvention = CallingConvention.Cdecl)] 110 | public static extern void DestroyTexture(IntPtr pPvrTexture); 111 | 112 | [DllImport(dllName, CallingConvention = CallingConvention.Cdecl)] 113 | public static extern bool Resize(IntPtr pPvrTexture, uint u32NewWidth, uint u32NewHeight, uint u32NewDepth, ResizeMode eResizeMode); 114 | 115 | [DllImport(dllName, CallingConvention = CallingConvention.Cdecl)] 116 | public static extern bool GenerateMIPMaps(IntPtr pPvrTexture, ResizeMode eFilterMode, uint uiMIPMapsToDo = int.MaxValue); 117 | 118 | [DllImport(dllName, CallingConvention = CallingConvention.Cdecl)] 119 | public static extern bool Transcode(IntPtr pPvrTexture, PixelFormat ptFormat, VariableType eChannelType, ColourSpace eColourspace, CompressorQuality eQuality = CompressorQuality.PVRTCNormal, bool bDoDither = false); 120 | 121 | [DllImport(dllName, CallingConvention = CallingConvention.Cdecl)] 122 | public static extern uint GetTextureDataSize(IntPtr pPvrTexture, int iMIPLevel = -1); 123 | 124 | [DllImport(dllName, CallingConvention = CallingConvention.Cdecl)] 125 | public static extern void GetTextureData(IntPtr pPvrTexture, IntPtr data, uint dataSize, uint uiMIPLevel = 0); 126 | #endregion Interop 127 | 128 | private IntPtr _pPvrTexture = IntPtr.Zero; 129 | private bool _isDisposed = false; 130 | 131 | public IntPtr PvrTexturePointer { get { return _pPvrTexture; } } 132 | public bool IsDisposed { get {return _isDisposed; } } 133 | 134 | public PVRTexture(string filePath) 135 | { 136 | this._pPvrTexture = CreateTexture(filePath); 137 | } 138 | 139 | public static PVRTexture CreateTexture(T[] data, uint u32Width, uint u32Height, uint u32Depth, PixelFormat ptFormat, bool preMultiplied, VariableType eChannelType, ColourSpace eColourspace) where T : struct 140 | { 141 | var gcHandle = GCHandle.Alloc(data, GCHandleType.Pinned); 142 | var pPvrTexture = CreateTexture(gcHandle.AddrOfPinnedObject(), u32Width, u32Height, u32Depth, ptFormat, preMultiplied, eChannelType, eColourspace); 143 | gcHandle.Free(); 144 | return new PVRTexture(pPvrTexture); 145 | } 146 | 147 | internal PVRTexture(IntPtr pPvrTexture) 148 | { 149 | this._pPvrTexture = pPvrTexture; 150 | } 151 | 152 | ~PVRTexture() 153 | { 154 | Dispose(false); 155 | } 156 | 157 | public bool SaveTexture(string filePath) 158 | { 159 | if (IsDisposed) throw new ObjectDisposedException("_pPvrTexture"); 160 | return SaveTexture(_pPvrTexture, filePath); 161 | } 162 | 163 | public bool Resize(uint u32NewWidth, uint u32NewHeight, uint u32NewDepth, ResizeMode eResizeMode) 164 | { 165 | if (IsDisposed) throw new ObjectDisposedException("_pPvrTexture"); 166 | return Resize(_pPvrTexture, u32NewWidth, u32NewHeight, u32NewDepth, eResizeMode); 167 | } 168 | 169 | public bool GenerateMIPMaps(ResizeMode eFilterMode, uint uiMIPMapsToDo = int.MaxValue) 170 | { 171 | if (IsDisposed) throw new ObjectDisposedException("_pPvrTexture"); 172 | return GenerateMIPMaps(_pPvrTexture, eFilterMode, uiMIPMapsToDo); 173 | } 174 | 175 | public bool Transcode(PixelFormat ptFormat, VariableType eChannelType, ColourSpace eColourspace, CompressorQuality eQuality = CompressorQuality.PVRTCNormal, bool bDoDither = false) 176 | { 177 | if (IsDisposed) throw new ObjectDisposedException("_pPvrTexture"); 178 | return Transcode(_pPvrTexture, ptFormat, eChannelType, eColourspace, eQuality, bDoDither); 179 | } 180 | 181 | public uint GetTextureDataSize(int iMIPLevel = -1) 182 | { 183 | if (IsDisposed) throw new ObjectDisposedException("_pPvrTexture"); 184 | return GetTextureDataSize(_pPvrTexture, iMIPLevel); 185 | } 186 | 187 | public void GetTextureData(T[] data, uint dataSize, uint uiMIPLevel = 0) where T : struct 188 | { 189 | if (IsDisposed) throw new ObjectDisposedException("_pPvrTexture"); 190 | var gcHandle = GCHandle.Alloc(data, GCHandleType.Pinned); 191 | GetTextureData(_pPvrTexture, gcHandle.AddrOfPinnedObject(), dataSize, uiMIPLevel); 192 | gcHandle.Free(); 193 | } 194 | 195 | #region Implement IDisposable & Dispose Pattern 196 | public void Dispose() 197 | { 198 | Dispose(true); 199 | GC.SuppressFinalize(this); 200 | } 201 | 202 | protected virtual void Dispose(bool disposing) 203 | { 204 | if (IsDisposed) return; 205 | 206 | if (disposing) 207 | { 208 | // release other disposable objects 209 | 210 | } 211 | // free resources 212 | DestroyTexture(_pPvrTexture); 213 | _pPvrTexture = IntPtr.Zero; 214 | 215 | _isDisposed = true; 216 | } 217 | #endregion 218 | } 219 | } 220 | -------------------------------------------------------------------------------- /PVRTexLibNET/PVRTexLibNET.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {BAAF1192-884B-4DA2-8C93-E738C2F452A4} 9 | Library 10 | Properties 11 | PVRTexLib 12 | PVRTexLibNET 13 | v4.5 14 | 512 15 | 16 | 17 | 18 | true 19 | bin\x86\Debug\ 20 | DEBUG;TRACE 21 | full 22 | x86 23 | prompt 24 | MinimumRecommendedRules.ruleset 25 | false 26 | 27 | 28 | bin\x86\Release\ 29 | TRACE 30 | true 31 | pdbonly 32 | x86 33 | prompt 34 | MinimumRecommendedRules.ruleset 35 | false 36 | 37 | 38 | true 39 | bin\x64\Debug\ 40 | DEBUG;TRACE 41 | full 42 | x64 43 | prompt 44 | MinimumRecommendedRules.ruleset 45 | false 46 | true 47 | 48 | 49 | bin\x64\Release\ 50 | TRACE 51 | true 52 | pdbonly 53 | x64 54 | prompt 55 | MinimumRecommendedRules.ruleset 56 | false 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | PVRTexLibWrapper.dll 71 | PreserveNewest 72 | 73 | 74 | PVRTexLib.dll 75 | PreserveNewest 76 | 77 | 78 | 79 | 80 | PVRTexLibWrapper.dll 81 | PreserveNewest 82 | 83 | 84 | PVRTexLib.dll 85 | PreserveNewest 86 | 87 | 88 | 89 | 96 | -------------------------------------------------------------------------------- /PVRTexLibNET/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("PVRTexLibNET")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("PVRTexLibNET")] 12 | [assembly: AssemblyCopyright("Copyright © 2014")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("1e426f9f-b341-48e6-a41d-6f913b61bd69")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexLibWrapper.cpp: -------------------------------------------------------------------------------- 1 | // This is the main DLL file. 2 | 3 | #include "stdafx.h" 4 | 5 | #include "PVRTexLibWrapper.h" 6 | #include 7 | #include 8 | 9 | using namespace pvrtexture; 10 | 11 | 12 | extern void* __cdecl CreateTexture(void* data, uint32 u32Width, uint32 u32Height, uint32 u32Depth, PixelType ptFormat, bool preMultiplied, EPVRTVariableType eChannelType, EPVRTColourSpace eColourspace) 13 | { 14 | PVRTextureHeaderV3 pvrHeader; 15 | pvrHeader.u32Version = PVRTEX_CURR_IDENT; 16 | pvrHeader.u32Flags = preMultiplied ? PVRTEX3_PREMULTIPLIED : 0; 17 | pvrHeader.u64PixelFormat = ptFormat.PixelTypeID; 18 | pvrHeader.u32ColourSpace = eColourspace; 19 | pvrHeader.u32ChannelType = eChannelType; 20 | pvrHeader.u32Width = u32Width; 21 | pvrHeader.u32Height = u32Height; 22 | pvrHeader.u32Depth = u32Depth; 23 | pvrHeader.u32NumSurfaces = 1; 24 | pvrHeader.u32NumFaces = 1; 25 | pvrHeader.u32MIPMapCount = 1; 26 | pvrHeader.u32MetaDataSize = 0; 27 | CPVRTexture* pvrTexture = new CPVRTexture(pvrHeader, data); 28 | 29 | return pvrTexture; 30 | } 31 | 32 | extern void* __cdecl CreateTextureFromFile(const char* filePath) 33 | { 34 | CPVRTexture* pvrTexture = new CPVRTexture(filePath); 35 | 36 | return pvrTexture; 37 | } 38 | 39 | extern bool __cdecl SaveTexture(void* pPvrTexture, const char* filePath) 40 | { 41 | CPVRTexture* pvrTexture = (CPVRTexture*)pPvrTexture; 42 | if (pvrTexture == NULL) 43 | return false; 44 | CPVRTString str; 45 | str.append(filePath); 46 | //CPVRTString str2 = PVRTStringGetContainingDirectoryPath(str); 47 | return pvrTexture->saveFile(str); 48 | } 49 | 50 | extern void __cdecl DestroyTexture(void* pPvrTexture) 51 | { 52 | CPVRTexture* pvrTexture = (CPVRTexture*)pPvrTexture; 53 | if (pvrTexture != NULL) 54 | { 55 | delete pvrTexture; 56 | } 57 | } 58 | 59 | extern bool __cdecl Resize(void* pPvrTexture, uint32 u32NewWidth, uint32 u32NewHeight, uint32 u32NewDepth, EResizeMode eResizeMode) 60 | { 61 | CPVRTexture* pvrTexture = (CPVRTexture*)pPvrTexture; 62 | if (pvrTexture == NULL) 63 | return false; 64 | return pvrtexture::Resize(*pvrTexture, u32NewWidth, u32NewHeight, u32NewDepth, eResizeMode); 65 | } 66 | 67 | extern bool __cdecl PremultiplyAlpha(void* pPvrTexture) 68 | { 69 | CPVRTexture* pvrTexture = (CPVRTexture*)pPvrTexture; 70 | if (pvrTexture == NULL) 71 | return false; 72 | return pvrtexture::PreMultiplyAlpha(*pvrTexture); 73 | } 74 | 75 | extern bool __cdecl GenerateMIPMaps(void* pPvrTexture, EResizeMode eFilterMode, uint32 uiMIPMapsToDo) 76 | { 77 | CPVRTexture* pvrTexture = (CPVRTexture*)pPvrTexture; 78 | if (pvrTexture == NULL) 79 | return false; 80 | return pvrtexture::GenerateMIPMaps(*pvrTexture, eFilterMode, uiMIPMapsToDo); 81 | } 82 | 83 | extern bool __cdecl Transcode(void* pPvrTexture, PixelType ptFormat, EPVRTVariableType eChannelType, EPVRTColourSpace eColourspace, ECompressorQuality eQuality, bool bDoDither) 84 | { 85 | CPVRTexture* pvrTexture = (CPVRTexture*)pPvrTexture; 86 | if (pvrTexture == NULL) 87 | return false; 88 | return pvrtexture::Transcode(*pvrTexture, ptFormat, eChannelType, eColourspace, eQuality, bDoDither); 89 | } 90 | 91 | extern uint32 __cdecl GetTextureDataSize(void* pPvrTexture, int32 iMIPLevel) 92 | { 93 | CPVRTexture* pvrTexture = (CPVRTexture*)pPvrTexture; 94 | if (pvrTexture == NULL) 95 | return 0; 96 | return pvrTexture->getDataSize(iMIPLevel); 97 | } 98 | 99 | extern void __cdecl GetTextureData(void* pPvrTexture, void* data, uint32 dataSize, uint32 uiMIPLevel) 100 | { 101 | CPVRTexture* pvrTexture = (CPVRTexture*)pPvrTexture; 102 | if (pvrTexture == NULL) 103 | return; 104 | memcpy(data, pvrTexture->getDataPtr(uiMIPLevel), dataSize); 105 | } -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexLibWrapper.h: -------------------------------------------------------------------------------- 1 | // PVRTexLibC.h 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace pvrtexture; 10 | 11 | extern "C" { 12 | __declspec(dllexport) void* __cdecl CreateTexture(void* data, uint32 u32Width, uint32 u32Height, uint32 u32Depth, PixelType ptFormat, bool preMultiplied, EPVRTVariableType eChannelType, EPVRTColourSpace eColourspace); 13 | 14 | __declspec(dllexport) void* __cdecl CreateTextureFromFile(const char* filePath); 15 | 16 | __declspec(dllexport) bool __cdecl SaveTexture(void* pPvrTexture, const char* filePath); 17 | 18 | __declspec(dllexport) void __cdecl DestroyTexture(void* pPvrTexture); 19 | 20 | __declspec(dllexport) bool __cdecl Resize(void* pPvrTexture, uint32 u32NewWidth, uint32 u32NewHeight, uint32 u32NewDepth, EResizeMode eResizeMode); 21 | 22 | __declspec(dllexport) bool __cdecl PremultiplyAlpha(void* pPvrTexture); 23 | 24 | __declspec(dllexport) bool __cdecl GenerateMIPMaps(void* pPvrTexture, EResizeMode eFilterMode, uint32 uiMIPMapsToDo = PVRTEX_ALLMIPLEVELS); 25 | 26 | __declspec(dllexport) bool __cdecl Transcode(void* pPvrTexture, PixelType ptFormat, EPVRTVariableType eChannelType, EPVRTColourSpace eColourspace, ECompressorQuality eQuality = ePVRTCNormal, bool bDoDither = false); 27 | 28 | __declspec(dllexport) uint32 __cdecl GetTextureDataSize(void* pPvrTexture, int32 iMIPLevel = PVRTEX_ALLMIPLEVELS); 29 | 30 | __declspec(dllexport) void __cdecl GetTextureData(void* pPvrTexture, void* data, uint32 dataSize, uint32 uiMIPLevel = 0); 31 | } 32 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexLibWrapper.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {7CC59D82-06E1-4BA7-8644-2552CBC34316} 23 | v4.5 24 | ManagedCProj 25 | PVRTexLibC 26 | PVRTexLibWrapper 27 | 28 | 29 | 30 | DynamicLibrary 31 | true 32 | false 33 | Unicode 34 | v120 35 | 36 | 37 | DynamicLibrary 38 | true 39 | false 40 | Unicode 41 | v120 42 | 43 | 44 | DynamicLibrary 45 | false 46 | false 47 | Unicode 48 | v120 49 | 50 | 51 | DynamicLibrary 52 | false 53 | false 54 | Unicode 55 | v120 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | $(ProjectDir)source;$(IncludePath) 76 | $(LibraryPath) 77 | bin\x86\$(Configuration)\ 78 | obj\x86\$(Configuration)\ 79 | 80 | 81 | true 82 | $(ProjectDir)source;$(IncludePath) 83 | $(LibraryPath) 84 | bin\$(Platform)\$(Configuration)\ 85 | obj\$(Platform)\$(Configuration)\ 86 | 87 | 88 | false 89 | $(ProjectDir)source;$(IncludePath) 90 | $(LibraryPath) 91 | bin\x86\$(Configuration)\ 92 | obj\x86\$(Configuration)\ 93 | 94 | 95 | false 96 | $(ProjectDir)source;$(IncludePath) 97 | $(LibraryPath) 98 | bin\$(Platform)\$(Configuration)\ 99 | obj\$(Platform)\$(Configuration)\ 100 | 101 | 102 | 103 | Level3 104 | Disabled 105 | WIN32;_DEBUG;%(PreprocessorDefinitions);_WINDLL_IMPORT 106 | Use 107 | false 108 | MultiThreadedDebug 109 | PVRTexTool\Library\Include 110 | 111 | 112 | true 113 | PVRTexTool\Library\Windows_x86_32\PVRTexLib.lib 114 | $(ProjectDir) 115 | 116 | 117 | true 118 | 119 | 120 | 121 | 122 | Level3 123 | Disabled 124 | WIN64;_DEBUG;%(PreprocessorDefinitions);_WINDLL_IMPORT 125 | Use 126 | false 127 | MultiThreadedDebug 128 | PVRTexTool\Library\Include 129 | 130 | 131 | true 132 | PVRTexTool\Library\Windows_x86_64\PVRTexLib.lib 133 | $(ProjectDir) 134 | 135 | 136 | true 137 | 138 | 139 | 140 | 141 | Level3 142 | WIN32;NDEBUG;%(PreprocessorDefinitions);_WINDLL_IMPORT 143 | Use 144 | MultiThreaded 145 | false 146 | PVRTexTool\Library\Include 147 | 148 | 149 | true 150 | PVRTexTool\Library\Windows_x86_32\PVRTexLib.lib 151 | $(ProjectDir) 152 | 153 | 154 | 155 | 156 | Level3 157 | WIN64;NDEBUG;%(PreprocessorDefinitions);_WINDLL_IMPORT 158 | Use 159 | MultiThreaded 160 | false 161 | PVRTexTool\Library\Include 162 | 163 | 164 | true 165 | PVRTexTool\Library\Windows_x86_64\PVRTexLib.lib 166 | $(ProjectDir) 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | Create 183 | Create 184 | Create 185 | Create 186 | 187 | 188 | 189 | 190 | PVRTexLib.dll 191 | PreserveNewest 192 | 193 | 194 | 195 | 196 | PVRTexLib.dll 197 | PreserveNewest 198 | 199 | 200 | 201 | 202 | 203 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexLibWrapper.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Include/PVRTArray.h: -------------------------------------------------------------------------------- 1 | /*!**************************************************************************** 2 | 3 | @file PVRTArray.h 4 | @copyright Copyright (c) Imagination Technologies Limited. 5 | @brief Expanding array template class. Allows appending and direct 6 | access. Mixing access methods should be approached with caution. 7 | 8 | ******************************************************************************/ 9 | #ifndef __PVRTARRAY_H__ 10 | #define __PVRTARRAY_H__ 11 | 12 | #include "PVRTGlobal.h" 13 | #include "PVRTError.h" 14 | 15 | /****************************************************************************** 16 | ** Classes 17 | ******************************************************************************/ 18 | 19 | /*!*************************************************************************** 20 | @class CPVRTArray 21 | @brief Expanding array template class. 22 | *****************************************************************************/ 23 | template 24 | class CPVRTArray 25 | { 26 | public: 27 | /*!*************************************************************************** 28 | @brief Blank constructor. Makes a default sized array. 29 | *****************************************************************************/ 30 | CPVRTArray() : m_uiSize(0), m_uiCapacity(GetDefaultSize()) 31 | { 32 | m_pArray = new T[m_uiCapacity]; 33 | } 34 | 35 | /*!*************************************************************************** 36 | @brief Constructor taking initial size of array in elements. 37 | @param[in] uiSize intial size of array 38 | *****************************************************************************/ 39 | CPVRTArray(const unsigned int uiSize) : m_uiSize(0), m_uiCapacity(uiSize) 40 | { 41 | _ASSERT(uiSize != 0); 42 | m_pArray = new T[uiSize]; 43 | } 44 | 45 | /*!*************************************************************************** 46 | @brief Copy constructor. 47 | @param[in] original the other dynamic array 48 | *****************************************************************************/ 49 | CPVRTArray(const CPVRTArray& original) : m_uiSize(original.m_uiSize), 50 | m_uiCapacity(original.m_uiCapacity) 51 | { 52 | m_pArray = new T[m_uiCapacity]; 53 | for(unsigned int i=0;i= m_uiSize) // Are we adding to the end 112 | uiIndex = Append(addT); 113 | else 114 | { 115 | unsigned int uiNewCapacity = 0; 116 | T* pArray = m_pArray; 117 | 118 | if(m_uiSize >= m_uiCapacity) 119 | { 120 | uiNewCapacity = m_uiCapacity + 10; // Expand the array by 10. 121 | 122 | pArray = new T[uiNewCapacity]; // New Array 123 | 124 | if(!pArray) 125 | return -1; // Failed to allocate memory! 126 | 127 | // Copy the first half to the new array 128 | for(unsigned int i = 0; i < pos; ++i) 129 | { 130 | pArray[i] = m_pArray[i]; 131 | } 132 | } 133 | 134 | // Copy last half to the new array 135 | for(unsigned int i = m_uiSize; i > pos; --i) 136 | { 137 | pArray[i] = m_pArray[i - 1]; 138 | } 139 | 140 | // Insert our new element 141 | pArray[pos] = addT; 142 | uiIndex = pos; 143 | 144 | // Increase our size 145 | ++m_uiSize; 146 | 147 | // Switch pointers and free memory if needed 148 | if(pArray != m_pArray) 149 | { 150 | m_uiCapacity = uiNewCapacity; 151 | delete[] m_pArray; 152 | m_pArray = pArray; 153 | } 154 | } 155 | 156 | return uiIndex; 157 | } 158 | 159 | /*!*************************************************************************** 160 | @brief Appends an element to the end of the array, expanding it 161 | if necessary. 162 | @param[in] addT The element to append 163 | @return The index of the new item. 164 | *****************************************************************************/ 165 | unsigned int Append(const T& addT) 166 | { 167 | unsigned int uiIndex = Append(); 168 | m_pArray[uiIndex] = addT; 169 | return uiIndex; 170 | } 171 | 172 | /*!*************************************************************************** 173 | @brief Creates space for a new item, but doesn't add. Instead 174 | returns the index of the new item. 175 | @return The index of the new item. 176 | *****************************************************************************/ 177 | unsigned int Append() 178 | { 179 | unsigned int uiIndex = m_uiSize; 180 | SetCapacity(m_uiSize+1); 181 | m_uiSize++; 182 | 183 | return uiIndex; 184 | } 185 | 186 | /*!*************************************************************************** 187 | @brief Clears the array. 188 | *****************************************************************************/ 189 | void Clear() 190 | { 191 | m_uiSize = 0U; 192 | } 193 | 194 | /*!*************************************************************************** 195 | @brief Changes the array to the new size. 196 | @param[in] uiSize New size of array 197 | *****************************************************************************/ 198 | EPVRTError Resize(const unsigned int uiSize) 199 | { 200 | EPVRTError err = SetCapacity(uiSize); 201 | 202 | if(err != PVR_SUCCESS) 203 | return err; 204 | 205 | m_uiSize = uiSize; 206 | return PVR_SUCCESS; 207 | } 208 | 209 | /*!*************************************************************************** 210 | @brief Expands array to new capacity. 211 | @param[in] uiSize New capacity of array 212 | *****************************************************************************/ 213 | EPVRTError SetCapacity(const unsigned int uiSize) 214 | { 215 | if(uiSize <= m_uiCapacity) 216 | return PVR_SUCCESS; // nothing to be done 217 | 218 | unsigned int uiNewCapacity; 219 | if(uiSize < m_uiCapacity*2) 220 | { 221 | uiNewCapacity = m_uiCapacity*2; // Ignore the new size. Expand to twice the previous size. 222 | } 223 | else 224 | { 225 | uiNewCapacity = uiSize; 226 | } 227 | 228 | T* pNewArray = new T[uiNewCapacity]; // New Array 229 | if(!pNewArray) 230 | return PVR_FAIL; // Failed to allocate memory! 231 | 232 | // Copy source data to new array 233 | for(unsigned int i = 0; i < m_uiSize; ++i) 234 | { 235 | pNewArray[i] = m_pArray[i]; 236 | } 237 | 238 | // Switch pointers and free memory 239 | m_uiCapacity = uiNewCapacity; 240 | T* pOldArray = m_pArray; 241 | m_pArray = pNewArray; 242 | delete [] pOldArray; 243 | return PVR_SUCCESS; 244 | } 245 | 246 | /*!*************************************************************************** 247 | @fn Copy 248 | @brief A copy function. Will attempt to copy from other CPVRTArrays 249 | if this is possible. 250 | @param[in] other The CPVRTArray needing copied 251 | *****************************************************************************/ 252 | template 253 | void Copy(const CPVRTArray& other) 254 | { 255 | T* pNewArray = new T[other.GetCapacity()]; 256 | if(pNewArray) 257 | { 258 | // Copy data 259 | for(unsigned int i = 0; i < other.GetSize(); i++) 260 | { 261 | pNewArray[i] = other[i]; 262 | } 263 | 264 | // Free current array 265 | if(m_pArray) 266 | delete [] m_pArray; 267 | 268 | // Swap pointers 269 | m_pArray = pNewArray; 270 | 271 | m_uiCapacity = other.GetCapacity(); 272 | m_uiSize = other.GetSize(); 273 | } 274 | } 275 | 276 | /*!*************************************************************************** 277 | @brief Assignment operator. 278 | @param[in] other The CPVRTArray needing copied 279 | *****************************************************************************/ 280 | CPVRTArray& operator=(const CPVRTArray& other) 281 | { 282 | if(&other != this) 283 | Copy(other); 284 | 285 | return *this; 286 | } 287 | 288 | /*!*************************************************************************** 289 | @brief Appends an existing CPVRTArray on to this one. 290 | @param[in] other the array to append. 291 | *****************************************************************************/ 292 | CPVRTArray& operator+=(const CPVRTArray& other) 293 | { 294 | if(&other != this) 295 | { 296 | for(unsigned int uiIndex = 0; uiIndex < other.GetSize(); ++uiIndex) 297 | { 298 | Append(other[uiIndex]); 299 | } 300 | } 301 | 302 | return *this; 303 | } 304 | 305 | /*!*************************************************************************** 306 | @brief Indexed access into array. Note that this has no error 307 | checking whatsoever. 308 | @param[in] uiIndex index of element in array 309 | @return the element indexed 310 | *****************************************************************************/ 311 | T& operator[](const unsigned int uiIndex) 312 | { 313 | _ASSERT(uiIndex < m_uiSize); 314 | return m_pArray[uiIndex]; 315 | } 316 | 317 | /*!*************************************************************************** 318 | @brief Indexed access into array. Note that this has no error checking whatsoever. 319 | @param[in] uiIndex index of element in array 320 | @return The element indexed 321 | *****************************************************************************/ 322 | const T& operator[](const unsigned int uiIndex) const 323 | { 324 | _ASSERT(uiIndex < m_uiSize); 325 | return m_pArray[uiIndex]; 326 | } 327 | 328 | /*!*************************************************************************** 329 | @return Size of array 330 | @brief Gives current size of array/number of elements. 331 | *****************************************************************************/ 332 | unsigned int GetSize() const 333 | { 334 | return m_uiSize; 335 | } 336 | 337 | /*!*************************************************************************** 338 | @brief Gives the default size of array/number of elements. 339 | @return Default size of array 340 | *****************************************************************************/ 341 | static unsigned int GetDefaultSize() 342 | { 343 | return 16U; 344 | } 345 | 346 | /*!*************************************************************************** 347 | @brief Gives current allocated size of array/number of elements. 348 | @return Capacity of array 349 | *****************************************************************************/ 350 | unsigned int GetCapacity() const 351 | { 352 | return m_uiCapacity; 353 | } 354 | 355 | /*!*************************************************************************** 356 | @brief Indicates whether the given object resides inside the array. 357 | @param[in] object The object to check in the array 358 | @return true if object is contained in this array. 359 | *****************************************************************************/ 360 | bool Contains(const T& object) const 361 | { 362 | for(unsigned int uiIndex = 0; uiIndex < m_uiSize; ++uiIndex) 363 | { 364 | if(m_pArray[uiIndex] == object) 365 | return true; 366 | } 367 | return false; 368 | } 369 | 370 | /*!*************************************************************************** 371 | @brief Attempts to find the object in the array and returns a 372 | pointer if it is found, or NULL if not found. The time 373 | taken is O(N). 374 | @param[in] object The object to check in the array 375 | @return Pointer to the found object or NULL. 376 | *****************************************************************************/ 377 | T* Find(const T& object) const 378 | { 379 | for(unsigned int uiIndex = 0; uiIndex < m_uiSize; ++uiIndex) 380 | { 381 | if(m_pArray[uiIndex] == object) 382 | return &m_pArray[uiIndex]; 383 | } 384 | return NULL; 385 | } 386 | 387 | /*!*************************************************************************** 388 | @brief Performs a merge-sort on the array. Pred should be an object that 389 | defines a bool operator(). 390 | @param[in] predicate The object which defines "bool operator()" 391 | *****************************************************************************/ 392 | template 393 | void Sort(Pred predicate) 394 | { 395 | _Sort(0, m_uiSize, predicate); 396 | } 397 | 398 | /*!*************************************************************************** 399 | @brief Removes an element from the array. 400 | @param[in] uiIndex The index to remove 401 | @return success or failure 402 | *****************************************************************************/ 403 | virtual EPVRTError Remove(unsigned int uiIndex) 404 | { 405 | _ASSERT(uiIndex < m_uiSize); 406 | if(m_uiSize == 0) 407 | return PVR_FAIL; 408 | 409 | if(uiIndex == m_uiSize-1) 410 | { 411 | return RemoveLast(); 412 | } 413 | 414 | m_uiSize--; 415 | // Copy the data. memmove will only work for built-in types. 416 | for(unsigned int uiNewIdx = uiIndex; uiNewIdx < m_uiSize; ++uiNewIdx) 417 | { 418 | m_pArray[uiNewIdx] = m_pArray[uiNewIdx+1]; 419 | } 420 | 421 | return PVR_SUCCESS; 422 | } 423 | 424 | /*!*************************************************************************** 425 | @brief Removes the last element. Simply decrements the size value. 426 | @return success or failure 427 | *****************************************************************************/ 428 | virtual EPVRTError RemoveLast() 429 | { 430 | if(m_uiSize > 0) 431 | { 432 | m_uiSize--; 433 | return PVR_SUCCESS; 434 | } 435 | else 436 | { 437 | return PVR_FAIL; 438 | } 439 | } 440 | 441 | protected: 442 | enum eBounds 443 | { 444 | eLowerBounds, 445 | eUpperBounds, 446 | }; 447 | 448 | /*!*************************************************************************** 449 | @brief Internal sort algorithm. 450 | @param[in] first The beginning index of the array 451 | @param[in] last The last index of the array 452 | @param[in] predicate A functor object to perform the comparison 453 | *****************************************************************************/ 454 | template 455 | void _Sort(unsigned int first, unsigned int last, Pred predicate) 456 | { 457 | unsigned int size = last - first; 458 | if(size < 2) 459 | return; 460 | 461 | unsigned int middle = first + size / 2; 462 | _Sort(first, middle, predicate); 463 | _Sort(middle, last, predicate); 464 | _SortMerge(first, middle, last, middle-first, last-middle, predicate); 465 | } 466 | 467 | /*!*************************************************************************** 468 | @brief Internal sort algorithm - in-place merge method. 469 | @param[in] first The beginning index of the array 470 | @param[in] middle The middle index of the array 471 | @param[in] last The last index of the array 472 | @param[in] len1 Length of first half of the array 473 | @param[in] len2 Length of the second half of the array 474 | @param[in] predicate A functor object to perform the comparison 475 | *****************************************************************************/ 476 | template 477 | void _SortMerge(unsigned int first, unsigned int middle, unsigned int last, int len1, int len2, Pred predicate) 478 | { 479 | if(len1 == 0 || len2 == 0) 480 | return; 481 | 482 | if(len1 + len2 == 2) 483 | { 484 | if(predicate(m_pArray[middle], m_pArray[first])) 485 | PVRTswap(m_pArray[first], m_pArray[middle]); 486 | 487 | return; 488 | } 489 | 490 | unsigned int firstCut = first; 491 | unsigned int secondCut = middle; 492 | int dist1 = 0; 493 | int dist2 = 0; 494 | if(len1 > len2) 495 | { 496 | dist1 = len1 / 2; 497 | firstCut += dist1; 498 | secondCut = _SortBounds(middle, last, m_pArray[firstCut], eLowerBounds, predicate); 499 | dist2 += secondCut - middle; 500 | } 501 | else 502 | { 503 | dist2 = len2 / 2; 504 | secondCut += dist2; 505 | firstCut = _SortBounds(first, middle, m_pArray[secondCut], eUpperBounds, predicate); 506 | dist1 += firstCut - first; 507 | } 508 | 509 | unsigned int newMiddle = _SortRotate(firstCut, middle, secondCut); 510 | _SortMerge(first, firstCut, newMiddle, dist1, dist2, predicate); 511 | _SortMerge(newMiddle, secondCut, last, len1-dist1, len2-dist2, predicate); 512 | } 513 | 514 | /*!*************************************************************************** 515 | @brief Internal sort algorithm - returns the bounded index of the range. 516 | @param[in] first The beginning index of the array 517 | @param[in] last The last index of the array 518 | @param[in] v Comparison object 519 | @param[in] bounds Which bound to check (upper or lower) 520 | @param[in] predicate A functor object to perform the comparison 521 | *****************************************************************************/ 522 | template 523 | unsigned int _SortBounds(unsigned int first, unsigned int last, const T& v, eBounds bounds, Pred predicate) 524 | { 525 | int count = last - first, step; 526 | unsigned int idx; 527 | while(count > 0) 528 | { 529 | step = count / 2; 530 | idx = first + step; 531 | if((bounds == eLowerBounds && predicate(m_pArray[idx], v)) || (bounds == eUpperBounds && !predicate(v, m_pArray[idx]))) 532 | { 533 | first = ++idx; 534 | count -= step + 1; 535 | } 536 | else 537 | { 538 | count = step; 539 | } 540 | } 541 | return first; 542 | } 543 | 544 | /*!*************************************************************************** 545 | @brief Internal sort algorithm - rotates the contents of the array such 546 | that the middle becomes the first element. 547 | @param[in] first The beginning index of the array 548 | @param[in] middle The middle index of the array 549 | @param[in] last The last index of the array 550 | *****************************************************************************/ 551 | int _SortRotate(unsigned int first, unsigned int middle, unsigned int last) 552 | { 553 | if(first == middle) 554 | return last; 555 | if(last == middle) 556 | return first; 557 | 558 | unsigned int newFirst = middle; 559 | do 560 | { 561 | PVRTswap(m_pArray[first++], m_pArray[newFirst++]); 562 | if(first == middle) 563 | middle = newFirst; 564 | } while (newFirst != last); 565 | 566 | unsigned int newMiddle = first; 567 | newFirst = middle; 568 | while(newFirst != last) 569 | { 570 | PVRTswap(m_pArray[first++], m_pArray[newFirst++]); 571 | if(first == middle) 572 | middle = newFirst; 573 | else if(newFirst == last) 574 | newFirst = middle; 575 | } 576 | 577 | return newMiddle; 578 | } 579 | 580 | protected: 581 | unsigned int m_uiSize; /*!< Current size of contents of array */ 582 | unsigned int m_uiCapacity; /*!< Currently allocated size of array */ 583 | T *m_pArray; /*!< The actual array itself */ 584 | }; 585 | 586 | // note "this" is required for ISO standard, C++ and gcc complains otherwise 587 | // http://lists.apple.com/archives/Xcode-users//2005/Dec/msg00644.html 588 | 589 | /*!*************************************************************************** 590 | @class CPVRTArrayManagedPointers 591 | @brief Maintains an array of managed pointers. 592 | *****************************************************************************/ 593 | template 594 | class CPVRTArrayManagedPointers : public CPVRTArray 595 | { 596 | public: 597 | /*!*************************************************************************** 598 | @brief Destructor. 599 | *****************************************************************************/ 600 | virtual ~CPVRTArrayManagedPointers() 601 | { 602 | if(this->m_pArray) 603 | { 604 | for(unsigned int i=0;im_uiSize;i++) 605 | { 606 | delete(this->m_pArray[i]); 607 | } 608 | } 609 | } 610 | 611 | /*!*************************************************************************** 612 | @brief Removes an element from the array. 613 | @param[in] uiIndex The index to remove. 614 | @return success or failure 615 | *****************************************************************************/ 616 | virtual EPVRTError Remove(unsigned int uiIndex) 617 | { 618 | _ASSERT(uiIndex < this->m_uiSize); 619 | if(this->m_uiSize == 0) 620 | return PVR_FAIL; 621 | 622 | if(uiIndex == this->m_uiSize-1) 623 | { 624 | return this->RemoveLast(); 625 | } 626 | 627 | unsigned int uiSize = (this->m_uiSize - (uiIndex+1)) * sizeof(T*); 628 | 629 | delete this->m_pArray[uiIndex]; 630 | memmove(this->m_pArray + uiIndex, this->m_pArray + (uiIndex+1), uiSize); 631 | 632 | this->m_uiSize--; 633 | return PVR_SUCCESS; 634 | } 635 | 636 | /*!*************************************************************************** 637 | @brief Removes the last element. Simply decrements the size value. 638 | @return success or failure 639 | *****************************************************************************/ 640 | virtual EPVRTError RemoveLast() 641 | { 642 | if(this->m_uiSize > 0 && this->m_pArray) 643 | { 644 | delete this->m_pArray[this->m_uiSize-1]; 645 | this->m_uiSize--; 646 | return PVR_SUCCESS; 647 | } 648 | else 649 | { 650 | return PVR_FAIL; 651 | } 652 | } 653 | }; 654 | 655 | #endif // __PVRTARRAY_H__ 656 | 657 | /***************************************************************************** 658 | End of file (PVRTArray.h) 659 | *****************************************************************************/ 660 | 661 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Include/PVRTDecompress.h: -------------------------------------------------------------------------------- 1 | /*!**************************************************************************** 2 | 3 | @file PVRTDecompress.h 4 | @copyright Copyright (c) Imagination Technologies Limited. 5 | @brief PVRTC and ETC Texture Decompression. 6 | 7 | ******************************************************************************/ 8 | 9 | #ifndef _PVRTDECOMPRESS_H_ 10 | #define _PVRTDECOMPRESS_H_ 11 | 12 | /*!*********************************************************************** 13 | @brief Decompresses PVRTC to RGBA 8888. 14 | @param[in] pCompressedData The PVRTC texture data to decompress 15 | @param[in] Do2bitMode Signifies whether the data is PVRTC2 or PVRTC4 16 | @param[in] XDim X dimension of the texture 17 | @param[in] YDim Y dimension of the texture 18 | @param[in,out] pResultImage The decompressed texture data 19 | @return Returns the amount of data that was decompressed. 20 | *************************************************************************/ 21 | int PVRTDecompressPVRTC(const void *pCompressedData, 22 | const int Do2bitMode, 23 | const int XDim, 24 | const int YDim, 25 | unsigned char* pResultImage); 26 | 27 | /*!*********************************************************************** 28 | @brief Decompresses ETC to RGBA 8888. 29 | @param[in] pSrcData The ETC texture data to decompress 30 | @param[in] x X dimension of the texture 31 | @param[in] y Y dimension of the texture 32 | @param[in,out] pDestData The decompressed texture data 33 | @param[in] nMode The format of the data 34 | @return The number of bytes of ETC data decompressed 35 | *************************************************************************/ 36 | int PVRTDecompressETC(const void * const pSrcData, 37 | const unsigned int &x, 38 | const unsigned int &y, 39 | void *pDestData, 40 | const int &nMode); 41 | 42 | 43 | #endif /* _PVRTDECOMPRESS_H_ */ 44 | 45 | /***************************************************************************** 46 | End of file (PVRTBoneBatch.h) 47 | *****************************************************************************/ 48 | 49 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Include/PVRTError.h: -------------------------------------------------------------------------------- 1 | /*!**************************************************************************** 2 | 3 | @file PVRTError.h 4 | @copyright Copyright (c) Imagination Technologies Limited. 5 | @brief PVRT error codes. 6 | 7 | ******************************************************************************/ 8 | #ifndef _PVRTERROR_H_ 9 | #define _PVRTERROR_H_ 10 | 11 | #if defined(ANDROID) 12 | #include 13 | #else 14 | #if defined(_WIN32) 15 | #include 16 | #else 17 | #include 18 | #endif 19 | #endif 20 | /*!*************************************************************************** 21 | Macros 22 | *****************************************************************************/ 23 | 24 | /*! Outputs a string to the standard error if built for debugging. */ 25 | #if !defined(PVRTERROR_OUTPUT_DEBUG) 26 | #if defined(_DEBUG) || defined(DEBUG) 27 | #if defined(ANDROID) 28 | #define PVRTERROR_OUTPUT_DEBUG(A) __android_log_print(ANDROID_LOG_INFO, "PVRTools", A); 29 | #elif defined(_WIN32) && !defined(UNDER_CE) 30 | #define PVRTERROR_OUTPUT_DEBUG(A) OutputDebugStringA(A); 31 | #else 32 | #define PVRTERROR_OUTPUT_DEBUG(A) fprintf(stderr,"%s",A); 33 | #endif 34 | #else 35 | #define PVRTERROR_OUTPUT_DEBUG(A) 36 | #endif 37 | #endif 38 | 39 | 40 | /*!*************************************************************************** 41 | Enums 42 | *****************************************************************************/ 43 | /*!*************************************************************************** 44 | @enum EPVRTError 45 | @brief EPVRT error conditions. 46 | *****************************************************************************/ 47 | enum EPVRTError 48 | { 49 | PVR_SUCCESS = 0, /*!< Success! :D */ 50 | PVR_FAIL = 1, /*!< Failed :( */ 51 | PVR_OVERFLOW = 2 /*!< Overflow error :| */ 52 | }; 53 | 54 | /*!*************************************************************************** 55 | @brief Outputs a string to the standard error. 56 | @param[in] format printf style format followed by arguments it requires. 57 | *****************************************************************************/ 58 | void PVRTErrorOutputDebug(char const * const format, ...); 59 | 60 | #endif // _PVRTERROR_H_ 61 | 62 | /***************************************************************************** 63 | End of file (PVRTError.h) 64 | *****************************************************************************/ 65 | 66 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Include/PVRTGlobal.h: -------------------------------------------------------------------------------- 1 | /*!**************************************************************************** 2 | 3 | @file PVRTGlobal.h 4 | @copyright Copyright (c) Imagination Technologies Limited. 5 | @brief Global defines and typedefs for PVRTools. 6 | 7 | ******************************************************************************/ 8 | #ifndef _PVRTGLOBAL_H_ 9 | #define _PVRTGLOBAL_H_ 10 | 11 | /*!*************************************************************************** 12 | Macros 13 | *****************************************************************************/ 14 | #define PVRT_MIN(a,b) (((a) < (b)) ? (a) : (b)) 15 | #define PVRT_MAX(a,b) (((a) > (b)) ? (a) : (b)) 16 | #define PVRT_CLAMP(x, l, h) (PVRT_MIN((h), PVRT_MAX((x), (l)))) 17 | 18 | // avoid warning about unused parameter 19 | #define PVRT_UNREFERENCED_PARAMETER(x) ((void) x) 20 | 21 | #if defined(_WIN32) && !defined(__QT__) && !defined(UNDER_CE) /* Windows desktop */ 22 | #if !defined(_CRTDBG_MAP_ALLOC) 23 | #define _CRTDBG_MAP_ALLOC 24 | #endif 25 | #include 26 | #include 27 | #include 28 | #endif 29 | 30 | #if defined(UNDER_CE) 31 | #include 32 | 33 | #ifndef _ASSERT 34 | #ifdef _DEBUG 35 | #define _ASSERT(X) { (X) ? 0 : DebugBreak(); } 36 | #else 37 | #define _ASSERT(X) 38 | #endif 39 | #endif 40 | 41 | #ifndef _ASSERTE 42 | #ifdef _DEBUG 43 | #define _ASSERTE _ASSERT 44 | #else 45 | #define _ASSERTE(X) 46 | #endif 47 | #endif 48 | #define _RPT0(a,b) 49 | #define _RPT1(a,b,c) 50 | #define _RPT2(a,b,c,d) 51 | #define _RPT3(a,b,c,d,e) 52 | #define _RPT4(a,b,c,d,e,f) 53 | #else 54 | 55 | #if defined(_WIN32) && !defined(__QT__) 56 | 57 | #else 58 | #if defined(__linux__) || defined(__APPLE__) 59 | #ifdef _DEBUG 60 | #include 61 | #ifndef _RPT0 62 | #define _RPT0(a,b) printf(b) 63 | #endif 64 | #ifndef _RPT1 65 | #define _RPT1(a,b,c) printf(b,c) 66 | #endif 67 | #ifndef _ASSERT 68 | #define _ASSERT(a) if (!(a)) ::raise(SIGTRAP) 69 | #endif 70 | #ifndef _ASSERTE 71 | #define _ASSERTE(a) if (!(a)) ::raise(SIGTRAP) 72 | #endif 73 | #else 74 | #ifndef _RPT0 75 | #define _RPT0(a,b)((void)0) 76 | #endif 77 | #ifndef _RPT1 78 | #define _RPT1(a,b,c)((void)0) 79 | #endif 80 | #ifndef _ASSERT 81 | #define _ASSERT(a)((void)0) 82 | #endif 83 | #ifndef _ASSERTE 84 | #define _ASSERTE(a)((void)0) 85 | #endif 86 | #endif 87 | #ifndef _RPT2 88 | #define _RPT2(a,b,c,d)((void)0) 89 | #endif 90 | #ifndef _RPT3 91 | #define _RPT3(a,b,c,d,e)((void)0) 92 | #endif 93 | #ifndef _RPT4 94 | #define _RPT4(a,b,c,d,e,f)((void)0) 95 | #endif 96 | #else 97 | #define _CRT_WARN 0 98 | #define _RPT0(a,b) 99 | #define _RPT1(a,b,c) 100 | #define _RPT2(a,b,c,d) 101 | #define _RPT3(a,b,c,d,e) 102 | #define _RPT4(a,b,c,d,e,f) 103 | #define _ASSERT(X) 104 | #define _ASSERTE(X) 105 | #endif 106 | #endif 107 | #endif 108 | 109 | #include 110 | #include 111 | 112 | #define FREE(X) { if(X) { free(X); (X) = 0; } } 113 | 114 | // This macro is used to check at compile time that types are of a certain size 115 | // If the size does not equal the expected size, this typedefs an array of size 0 116 | // which causes a compile error 117 | #define PVRTSIZEASSERT(T, size) typedef int (sizeof_##T)[sizeof(T) == (size)] 118 | #define PVRTCOMPILEASSERT(T, expr) typedef int (assert_##T)[expr] 119 | 120 | 121 | /**************************************************************************** 122 | ** Integer types 123 | ****************************************************************************/ 124 | 125 | typedef char PVRTchar8; 126 | typedef signed char PVRTint8; 127 | typedef signed short PVRTint16; 128 | typedef signed int PVRTint32; 129 | typedef unsigned char PVRTuint8; 130 | typedef unsigned short PVRTuint16; 131 | typedef unsigned int PVRTuint32; 132 | 133 | typedef float PVRTfloat32; 134 | 135 | #if (defined(__int64) || defined(_WIN32)) 136 | typedef signed __int64 PVRTint64; 137 | typedef unsigned __int64 PVRTuint64; 138 | #elif defined(__GNUC__) 139 | __extension__ typedef signed long long PVRTint64; 140 | __extension__ typedef unsigned long long PVRTuint64; 141 | #else 142 | typedef signed long long PVRTint64; 143 | typedef unsigned long long PVRTuint64; 144 | #endif 145 | 146 | #if __SIZEOF_WCHAR_T__ == 4 || __WCHAR_MAX__ > 0x10000 147 | #define PVRTSIZEOFWCHAR 4 148 | #else 149 | #define PVRTSIZEOFWCHAR 2 150 | #endif 151 | 152 | PVRTSIZEASSERT(PVRTchar8, 1); 153 | PVRTSIZEASSERT(PVRTint8, 1); 154 | PVRTSIZEASSERT(PVRTuint8, 1); 155 | PVRTSIZEASSERT(PVRTint16, 2); 156 | PVRTSIZEASSERT(PVRTuint16, 2); 157 | PVRTSIZEASSERT(PVRTint32, 4); 158 | PVRTSIZEASSERT(PVRTuint32, 4); 159 | PVRTSIZEASSERT(PVRTint64, 8); 160 | PVRTSIZEASSERT(PVRTuint64, 8); 161 | PVRTSIZEASSERT(PVRTfloat32, 4); 162 | 163 | /*!************************************************************************** 164 | @enum ETextureFilter 165 | @brief Enum values for defining texture filtering. 166 | ****************************************************************************/ 167 | enum ETextureFilter 168 | { 169 | eFilter_Nearest, 170 | eFilter_Linear, 171 | eFilter_None, 172 | 173 | eFilter_Size, 174 | eFilter_Default = eFilter_Linear, 175 | eFilter_MipDefault = eFilter_None 176 | }; 177 | 178 | /*!************************************************************************** 179 | @enum ETextureWrap 180 | @brief Enum values for defining texture wrapping. 181 | ****************************************************************************/ 182 | enum ETextureWrap 183 | { 184 | eWrap_Clamp, 185 | eWrap_Repeat, 186 | 187 | eWrap_Size, 188 | eWrap_Default = eWrap_Repeat 189 | }; 190 | 191 | /**************************************************************************** 192 | ** swap template function 193 | ****************************************************************************/ 194 | /*!*************************************************************************** 195 | @brief A swap template function that swaps a and b. 196 | @param[in] a Type a 197 | @param[in] b Type b 198 | *****************************************************************************/ 199 | 200 | template 201 | inline void PVRTswap(T& a, T& b) 202 | { 203 | T temp = a; 204 | a = b; 205 | b = temp; 206 | } 207 | 208 | /*!*************************************************************************** 209 | @brief A clamp template function that clamps val between min and max. 210 | @param[in] val Value to clamp 211 | @param[in] min Minimum legal value 212 | @param[in] max Maximum legal value 213 | *****************************************************************************/ 214 | template 215 | inline T PVRTClamp(const T& val, const T& min, const T& max) 216 | { 217 | if (val > max) 218 | { return max; } 219 | if (val < min) 220 | { return min; } 221 | return val; 222 | } 223 | 224 | /*!*************************************************************************** 225 | @brief Swaps the endianness of pBytes in place. 226 | @param[in] pBytes A number 227 | @param[in] i32ByteNo Number of bytes in pBytes 228 | *****************************************************************************/ 229 | inline void PVRTByteSwap(unsigned char* pBytes, int i32ByteNo) 230 | { 231 | int i = 0, j = i32ByteNo - 1; 232 | 233 | while (i < j) 234 | { PVRTswap(pBytes[i++], pBytes[j--]); } 235 | } 236 | 237 | /*!*************************************************************************** 238 | @brief Converts the endianness of an unsigned int. 239 | @param[in] ui32Long A number 240 | @return ui32Long with its endianness changed 241 | *****************************************************************************/ 242 | inline unsigned int PVRTByteSwap32(unsigned int ui32Long) 243 | { 244 | return ((ui32Long & 0x000000FF) << 24) + ((ui32Long & 0x0000FF00) << 8) + ((ui32Long & 0x00FF0000) >> 8) + ((ui32Long & 0xFF000000) >> 24); 245 | } 246 | 247 | /*!*************************************************************************** 248 | @brief Converts the endianness of a unsigned short. 249 | @param[in] ui16Short A number 250 | @return ui16Short with its endianness changed 251 | *****************************************************************************/ 252 | inline unsigned short PVRTByteSwap16(unsigned short ui16Short) 253 | { 254 | return (ui16Short >> 8) | (ui16Short << 8); 255 | } 256 | 257 | /*!*************************************************************************** 258 | @brief Returns true if the platform the code is ran on is little endian. 259 | @return True if the platform the code is ran on is little endian 260 | *****************************************************************************/ 261 | inline bool PVRTIsLittleEndian() 262 | { 263 | static bool bLittleEndian; 264 | static bool bIsInit = false; 265 | 266 | if (!bIsInit) 267 | { 268 | short int word = 0x0001; 269 | char* byte = (char*) &word; 270 | bLittleEndian = byte[0] ? true : false; 271 | bIsInit = true; 272 | } 273 | 274 | return bLittleEndian; 275 | } 276 | 277 | 278 | /*!*************************************************************************** 279 | @brief Minimum of a, b. In case of tie, a is returned. 280 | @return Returns b if a > b, otherwise a 281 | *****************************************************************************/ 282 | template 283 | inline const T& PVRTMin(const T& a, const T& b) 284 | { 285 | return a > b ? b : a; 286 | } 287 | 288 | /*!*************************************************************************** 289 | @brief Maximum of a, b. In case of tie, a is returned. 290 | @return Returns b if a < b. otherwise a 291 | *****************************************************************************/ 292 | template 293 | inline const T& PVRTMax(const T& a, const T& b) 294 | { 295 | return a < b ? b : a; 296 | } 297 | 298 | 299 | #endif // _PVRTGLOBAL_H_ 300 | 301 | /***************************************************************************** 302 | End of file (Tools.h) 303 | *****************************************************************************/ 304 | 305 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Include/PVRTMap.h: -------------------------------------------------------------------------------- 1 | /*!**************************************************************************** 2 | 3 | @file PVRTMap.h 4 | @copyright Copyright (c) Imagination Technologies Limited. 5 | @brief A simple and easy-to-use implementation of a map. 6 | 7 | ******************************************************************************/ 8 | #ifndef __PVRTMAP_H__ 9 | #define __PVRTMAP_H__ 10 | 11 | #include "PVRTArray.h" 12 | 13 | /*!*************************************************************************** 14 | @class CPVRTMap 15 | @brief Expanding map template class. 16 | @details A simple and easy-to-use implementation of a map. 17 | *****************************************************************************/ 18 | template 19 | class CPVRTMap 20 | { 21 | public: 22 | 23 | /*!*********************************************************************** 24 | @brief Constructor for a CPVRTMap. 25 | @return A new CPVRTMap. 26 | *************************************************************************/ 27 | CPVRTMap() : m_Keys(), m_Data(), m_uiSize(0) 28 | {} 29 | 30 | /*!*********************************************************************** 31 | @brief Destructor for a CPVRTMap. 32 | *************************************************************************/ 33 | ~CPVRTMap() 34 | { 35 | //Clear the map, that's enough - the CPVRTArray members will tidy everything else up. 36 | Clear(); 37 | } 38 | 39 | EPVRTError Reserve(const PVRTuint32 uiSize) 40 | { 41 | //Sets the capacity of each member array to the requested size. The array used will only expand. 42 | //Returns the most serious error from either method. 43 | return PVRT_MAX(m_Keys.SetCapacity(uiSize),m_Data.SetCapacity(uiSize)); 44 | } 45 | 46 | /*!*********************************************************************** 47 | @brief Returns the number of meaningful members in the map. 48 | @return Number of meaningful members in the map. 49 | *************************************************************************/ 50 | PVRTuint32 GetSize() const 51 | { 52 | //Return the size. 53 | return m_uiSize; 54 | } 55 | 56 | /*!*********************************************************************** 57 | @brief Gets the position of a particular key/data within the map. 58 | If the return value is exactly equal to the value of 59 | GetSize() then the item has not been found. 60 | @param[in] key Key type 61 | @return The index value for a mapped item. 62 | *************************************************************************/ 63 | PVRTuint32 GetIndexOf(const KeyType key) const 64 | { 65 | //Loop through all the valid keys. 66 | for (PVRTuint32 i=0; i=m_uiSize) 91 | return NULL; 92 | 93 | return &(m_Data[uiIndex]); 94 | } 95 | 96 | /*!*********************************************************************** 97 | @brief If a mapping already exists for 'key' then it will return 98 | the associated data. If no mapping currently exists, a new 99 | element is created in place. 100 | @param[in] key Key type 101 | @return Data that is mapped to 'key'. 102 | *************************************************************************/ 103 | DataType& operator[] (const KeyType key) 104 | { 105 | //Get the index of the key. 106 | PVRTuint32 uiIndex = GetIndexOf(key); 107 | 108 | //Check the index is valid 109 | if (uiIndex != m_uiSize) 110 | { 111 | //Return mapped data if the index is valid. 112 | return m_Data[uiIndex]; 113 | } 114 | else 115 | { 116 | //Append the key to the Keys array. 117 | m_Keys.Append(key); 118 | 119 | //Create a new DataType. 120 | DataType sNewData; 121 | 122 | //Append the new pointer to the Data array. 123 | m_Data.Append(sNewData); 124 | 125 | //Increment the size of meaningful data. 126 | ++m_uiSize; 127 | 128 | //Return the contents of pNewData. 129 | return m_Data[m_Keys.GetSize()-1]; 130 | } 131 | } 132 | 133 | /*!*********************************************************************** 134 | @brief Removes an element from the map if it exists. 135 | @param[in] key Key type 136 | @return Returns PVR_FAIL if item doesn't exist. 137 | Otherwise returns PVR_SUCCESS. 138 | *************************************************************************/ 139 | EPVRTError Remove(const KeyType key) 140 | { 141 | //Finds the index of the key. 142 | PVRTuint32 uiIndex=GetIndexOf(key); 143 | 144 | //If the key is invalid, fail. 145 | if (uiIndex==m_uiSize) 146 | { 147 | //Return failure. 148 | return PVR_FAIL; 149 | } 150 | 151 | //Decrement the size of the map to ignore the last element in each array. 152 | m_uiSize--; 153 | 154 | //Copy the last key over the deleted key. There are now two copies of one element, 155 | //but the one at the end of the array is ignored. 156 | m_Keys[uiIndex] = m_Keys[m_uiSize]; m_Keys.RemoveLast(); 157 | 158 | //Copy the last data over the deleted data in the same way as the keys. 159 | m_Data[uiIndex] = m_Data[m_uiSize]; m_Data.RemoveLast(); 160 | 161 | //Return success. 162 | return PVR_SUCCESS; 163 | } 164 | 165 | /*!*********************************************************************** 166 | @brief Clears the Map of all data values. 167 | *************************************************************************/ 168 | void Clear() 169 | { 170 | //Set the size to 0. 171 | m_uiSize=0; 172 | m_Keys.Clear(); 173 | m_Data.Clear(); 174 | } 175 | 176 | /*!*********************************************************************** 177 | @brief Checks whether or not data exists for the specified key. 178 | @param[in] key Key type 179 | @return Whether data exists for the specified key or not. 180 | *************************************************************************/ 181 | bool Exists(const KeyType key) const 182 | { 183 | //Checks for a valid index for key, if not, returns false. 184 | return (GetIndexOf(key) != m_uiSize); 185 | } 186 | 187 | private: 188 | 189 | 190 | CPVRTArray m_Keys; /*!< Array of all the keys. Indices match m_Data. */ 191 | 192 | CPVRTArray m_Data; /*!< Array of pointers to all the allocated data. */ 193 | 194 | PVRTuint32 m_uiSize; /*!< The number of meaningful members in the map. */ 195 | }; 196 | 197 | #endif // __PVRTMAP_H__ 198 | 199 | /***************************************************************************** 200 | End of file (PVRTMap.h) 201 | *****************************************************************************/ 202 | 203 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Include/PVRTString.h: -------------------------------------------------------------------------------- 1 | /*!**************************************************************************** 2 | 3 | @file PVRTString.h 4 | @copyright Copyright (c) Imagination Technologies Limited. 5 | @brief A string class that can be used as drop-in replacement for 6 | std::string on platforms/compilers that don't provide a full C++ 7 | standard library. 8 | 9 | ******************************************************************************/ 10 | #ifndef _PVRTSTRING_H_ 11 | #define _PVRTSTRING_H_ 12 | 13 | #include 14 | #define _USING_PVRTSTRING_ 15 | 16 | /*!*************************************************************************** 17 | @class CPVRTString 18 | @brief A string class. 19 | *****************************************************************************/ 20 | 21 | #if defined(_WINDLL_EXPORT) 22 | class __declspec(dllexport) CPVRTString 23 | #elif defined(_WINDLL_IMPORT) 24 | class __declspec(dllimport) CPVRTString 25 | #else 26 | class CPVRTString 27 | #endif 28 | { 29 | 30 | private: 31 | 32 | // Checking printf and scanf format strings 33 | #if defined(_CC_GNU_) || defined(__GNUG__) || defined(__GNUC__) 34 | #define FX_PRINTF(fmt,arg) __attribute__((format(printf,fmt,arg))) 35 | #define FX_SCANF(fmt,arg) __attribute__((format(scanf,fmt,arg))) 36 | #else 37 | #define FX_PRINTF(fmt,arg) 38 | #define FX_SCANF(fmt,arg) 39 | #endif 40 | 41 | public: 42 | typedef size_t size_type; 43 | typedef char value_type; 44 | typedef char& reference; 45 | typedef const char& const_reference; 46 | 47 | static const size_type npos; 48 | 49 | 50 | 51 | 52 | /*!*********************************************************************** 53 | @brief CPVRTString constructor. 54 | @param[in] _Ptr A string 55 | @param[in] _Count Length of _Ptr 56 | ************************************************************************/ 57 | CPVRTString(const char* _Ptr, size_t _Count = npos); 58 | 59 | /*!*********************************************************************** 60 | @brief CPVRTString constructor. 61 | @param[in] _Right A string 62 | @param[in] _Roff Offset into _Right 63 | @param[in] _Count Number of chars from _Right to assign to the new string 64 | ************************************************************************/ 65 | CPVRTString(const CPVRTString& _Right, size_t _Roff = 0, size_t _Count = npos); 66 | 67 | /*!*********************************************************************** 68 | @brief CPVRTString constructor. 69 | @param[in] _Count Length of new string 70 | @param[in] _Ch A char to fill it with 71 | *************************************************************************/ 72 | CPVRTString(size_t _Count, const char _Ch); 73 | 74 | /*!*********************************************************************** 75 | @brief Constructor. 76 | @param[in] _Ch A char 77 | *************************************************************************/ 78 | CPVRTString(const char _Ch); 79 | 80 | /*!*********************************************************************** 81 | @brief Constructor. 82 | ************************************************************************/ 83 | CPVRTString(); 84 | 85 | /*!*********************************************************************** 86 | @brief Destructor. 87 | ************************************************************************/ 88 | virtual ~CPVRTString(); 89 | 90 | /*!*********************************************************************** 91 | @brief Appends a string. 92 | @param[in] _Ptr A string 93 | @return Updated string 94 | *************************************************************************/ 95 | CPVRTString& append(const char* _Ptr); 96 | 97 | /*!*********************************************************************** 98 | @brief Appends a string of length _Count. 99 | @param[in] _Ptr A string 100 | @param[in] _Count String length 101 | @return Updated string 102 | *************************************************************************/ 103 | CPVRTString& append(const char* _Ptr, size_t _Count); 104 | 105 | /*!*********************************************************************** 106 | @brief Appends a string. 107 | @param[in] _Str A string 108 | @return Updated string 109 | *************************************************************************/ 110 | CPVRTString& append(const CPVRTString& _Str); 111 | 112 | /*!*********************************************************************** 113 | @brief Appends _Count letters of _Str from _Off in _Str. 114 | @param[in] _Str A string 115 | @param[in] _Off A position in string 116 | @param[in] _Count Number of letters to append 117 | @return Updated string 118 | *************************************************************************/ 119 | CPVRTString& append(const CPVRTString& _Str, size_t _Off, size_t _Count); 120 | 121 | /*!*********************************************************************** 122 | @brief Appends _Ch _Count times. 123 | @param[in] _Ch A char 124 | @param[in] _Count Number of times to append _Ch 125 | @return Updated string 126 | *************************************************************************/ 127 | CPVRTString& append(size_t _Count, const char _Ch); 128 | 129 | //template CPVRTString& append(InputIterator _First, InputIterator _Last); 130 | 131 | /*!*********************************************************************** 132 | @brief Assigns the string to the string _Ptr. 133 | @param[in] _Ptr A string 134 | @return Updated string 135 | *************************************************************************/ 136 | CPVRTString& assign(const char* _Ptr); 137 | 138 | /*!*********************************************************************** 139 | @brief Assigns the string to the string _Ptr. 140 | @param[in] _Ptr A string 141 | @param[in] _Count Length of _Ptr 142 | @return Updated string 143 | *************************************************************************/ 144 | CPVRTString& assign(const char* _Ptr, size_t _Count); 145 | 146 | /*!*********************************************************************** 147 | @brief Assigns the string to the string _Str. 148 | @param[in] _Str A string 149 | @return Updated string 150 | *************************************************************************/ 151 | CPVRTString& assign(const CPVRTString& _Str); 152 | 153 | /*!*********************************************************************** 154 | @brief Assigns the string to _Count characters in string _Str starting at _Off. 155 | @param[in] _Str A string 156 | @param[in] _Off First char to start assignment from 157 | @param[in] _Count Length of _Str 158 | @return Updated string 159 | *************************************************************************/ 160 | CPVRTString& assign(const CPVRTString& _Str, size_t _Off, size_t _Count=npos); 161 | 162 | /*!*********************************************************************** 163 | @brief Assigns the string to _Count copies of _Ch. 164 | @param[in] _Ch A string 165 | @param[in] _Count Number of times to repeat _Ch 166 | @return Updated string 167 | *************************************************************************/ 168 | CPVRTString& assign(size_t _Count, char _Ch); 169 | 170 | //template CPVRTString& assign(InputIterator _First, InputIterator _Last); 171 | 172 | //const_reference at(size_t _Off) const; 173 | //reference at(size_t _Off); 174 | 175 | // const_iterator begin() const; 176 | // iterator begin(); 177 | 178 | /*!*********************************************************************** 179 | @brief Returns a const char* pointer of the string. 180 | @return const char* pointer of the string 181 | *************************************************************************/ 182 | const char* c_str() const; 183 | 184 | /*!*********************************************************************** 185 | @brief Returns the size of the character array reserved. 186 | @return The size of the character array reserved 187 | *************************************************************************/ 188 | size_t capacity() const; 189 | 190 | /*!*********************************************************************** 191 | @brief Clears the string. 192 | *************************************************************************/ 193 | void clear(); 194 | 195 | /*!*********************************************************************** 196 | @brief Compares the string with _Str. 197 | @param[in] _Str A string to compare with 198 | @return 0 if the strings match 199 | *************************************************************************/ 200 | int compare(const CPVRTString& _Str) const; 201 | 202 | /*!*********************************************************************** 203 | @brief Compares the string with _Str. 204 | @param[in] _Pos1 Position to start comparing from 205 | @param[in] _Num1 Number of chars to compare 206 | @param[in] _Str A string to compare with 207 | @return 0 if the strings match 208 | *************************************************************************/ 209 | int compare(size_t _Pos1, size_t _Num1, const CPVRTString& _Str) const; 210 | 211 | /*!*********************************************************************** 212 | @brief Compares the string with _Str. 213 | @param[in] _Pos1 Position to start comparing from 214 | @param[in] _Num1 Number of chars to compare 215 | @param[in] _Str A string to compare with 216 | @param[in] _Off Position in _Str to compare from 217 | @param[in] _Count Number of chars in _Str to compare with 218 | @return 0 if the strings match 219 | *************************************************************************/ 220 | int compare(size_t _Pos1, size_t _Num1, const CPVRTString& _Str, size_t _Off, size_t _Count) const; 221 | 222 | /*!*********************************************************************** 223 | @brief Compares the string with _Ptr. 224 | @param[in] _Ptr A string to compare with 225 | @return 0 if the strings match 226 | *************************************************************************/ 227 | int compare(const char* _Ptr) const; 228 | 229 | /*!*********************************************************************** 230 | @brief Compares the string with _Ptr. 231 | @param[in] _Pos1 Position to start comparing from 232 | @param[in] _Num1 Number of chars to compare 233 | @param[in] _Ptr A string to compare with 234 | @return 0 if the strings match 235 | *************************************************************************/ 236 | int compare(size_t _Pos1, size_t _Num1, const char* _Ptr) const; 237 | 238 | /*!*********************************************************************** 239 | @brief Compares the string with _Str. 240 | @param[in] _Pos1 Position to start comparing from 241 | @param[in] _Num1 Number of chars to compare 242 | @param[in] _Ptr A string to compare with 243 | @param[in] _Count Number of chars to compare 244 | @return 0 if the strings match 245 | *************************************************************************/ 246 | int compare(size_t _Pos1, size_t _Num1, const char* _Ptr, size_t _Count) const; 247 | 248 | /*!*********************************************************************** 249 | @brief Less than operator. 250 | @param[in] _Str A string to compare with 251 | @return True on success 252 | *************************************************************************/ 253 | bool operator<(const CPVRTString & _Str) const; 254 | 255 | /*!*********************************************************************** 256 | @brief == Operator. 257 | @param[in] _Str A string to compare with 258 | @return True if they match 259 | *************************************************************************/ 260 | bool operator==(const CPVRTString& _Str) const; 261 | 262 | /*!*********************************************************************** 263 | @brief == Operator. 264 | @param[in] _Ptr A string to compare with 265 | @return True if they match 266 | *************************************************************************/ 267 | bool operator==(const char* const _Ptr) const; 268 | 269 | /*!*********************************************************************** 270 | @brief != Operator. 271 | @param[in] _Str A string to compare with 272 | @return True if they don't match 273 | *************************************************************************/ 274 | bool operator!=(const CPVRTString& _Str) const; 275 | 276 | /*!*********************************************************************** 277 | @brief != Operator. 278 | @param[in] _Ptr A string to compare with 279 | @return True if they don't match 280 | *************************************************************************/ 281 | bool operator!=(const char* const _Ptr) const; 282 | 283 | /*!*********************************************************************** 284 | @fn copy 285 | @param[in,out] _Ptr A string to copy to 286 | @param[in] _Count Size of _Ptr 287 | @param[in] _Off Position to start copying from 288 | @return Number of bytes copied 289 | @brief Copies the string to _Ptr. 290 | *************************************************************************/ 291 | size_t copy(char* _Ptr, size_t _Count, size_t _Off = 0) const; 292 | 293 | /*!*********************************************************************** 294 | @fn data 295 | @return A const char* version of the string 296 | @brief Returns a const char* version of the string. 297 | *************************************************************************/ 298 | const char* data( ) const; 299 | 300 | /*!*********************************************************************** 301 | @fn empty 302 | @return True if the string is empty 303 | @brief Returns true if the string is empty. 304 | *************************************************************************/ 305 | bool empty() const; 306 | 307 | // const_iterator end() const; 308 | // iterator end(); 309 | 310 | //iterator erase(iterator _First, iterator _Last); 311 | //iterator erase(iterator _It); 312 | 313 | /*!*********************************************************************** 314 | @brief Erases a portion of the string. 315 | @param[in] _Pos The position to start erasing from 316 | @param[in] _Count Number of chars to erase 317 | @return An updated string 318 | *************************************************************************/ 319 | CPVRTString& erase(size_t _Pos = 0, size_t _Count = npos); 320 | 321 | /*!*********************************************************************** 322 | @brief Erases a portion of the string. 323 | @param[in] _src Character to search 324 | @param[in] _subDes Character to substitute for 325 | @param[in] _all Substitute all 326 | @return An updated string 327 | *************************************************************************/ 328 | CPVRTString& substitute(char _src,char _subDes, bool _all = true); 329 | 330 | /*!*********************************************************************** 331 | @brief Erases a portion of the string. 332 | @param[in] _src Character to search 333 | @param[in] _subDes Character to substitute for 334 | @param[in] _all Substitute all 335 | @return An updated string 336 | *************************************************************************/ 337 | CPVRTString& substitute(const char* _src, const char* _subDes, bool _all = true); 338 | 339 | //size_t find(char _Ch, size_t _Off = 0) const; 340 | //size_t find(const char* _Ptr, size_t _Off = 0) const; 341 | 342 | /*!*********************************************************************** 343 | @brief Finds a substring within this string. 344 | @param[in] _Ptr String to search. 345 | @param[in] _Off Offset to search from. 346 | @param[in] _Count Number of characters in this string. 347 | @return Position of the first matched string. 348 | *************************************************************************/ 349 | size_t find(const char* _Ptr, size_t _Off, size_t _Count) const; 350 | 351 | /*!*********************************************************************** 352 | @brief Finds a substring within this string. 353 | @param[in] _Str String to search. 354 | @param[in] _Off Offset to search from. 355 | @return Position of the first matched string. 356 | *************************************************************************/ 357 | size_t find(const CPVRTString& _Str, size_t _Off = 0) const; 358 | 359 | /*!*********************************************************************** 360 | @brief Returns the position of the first char that is not _Ch. 361 | @param[in] _Ch A char 362 | @param[in] _Off Start position of the find 363 | @return Position of the first char that is not _Ch 364 | *************************************************************************/ 365 | size_t find_first_not_of(char _Ch, size_t _Off = 0) const; 366 | 367 | /*!*********************************************************************** 368 | @brief Returns the position of the first char that is not in _Ptr. 369 | @param[in] _Ptr A string 370 | @param[in] _Off Start position of the find 371 | @return Position of the first char that is not in _Ptr 372 | *************************************************************************/ 373 | size_t find_first_not_of(const char* _Ptr, size_t _Off = 0) const; 374 | 375 | /*!*********************************************************************** 376 | @brief Returns the position of the first char that is not in _Ptr. 377 | @param[in] _Ptr A string 378 | @param[in] _Off Start position of the find 379 | @param[in] _Count Number of chars in _Ptr 380 | @return Position of the first char that is not in _Ptr 381 | *************************************************************************/ 382 | size_t find_first_not_of(const char* _Ptr, size_t _Off, size_t _Count) const; 383 | 384 | /*!*********************************************************************** 385 | @brief Returns the position of the first char that is not in _Str. 386 | @param[in] _Str A string 387 | @param[in] _Off Start position of the find 388 | @return Position of the first char that is not in _Str 389 | *************************************************************************/ 390 | size_t find_first_not_of(const CPVRTString& _Str, size_t _Off = 0) const; 391 | 392 | /*!*********************************************************************** 393 | @brief Returns the position of the first char that is _Ch. 394 | @param[in] _Ch A char 395 | @param[in] _Off Start position of the find 396 | @return Position of the first char that is _Ch 397 | *************************************************************************/ 398 | size_t find_first_of(char _Ch, size_t _Off = 0) const; 399 | 400 | /*!*********************************************************************** 401 | @brief Returns the position of the first char that matches a char in _Ptr. 402 | @param[in] _Ptr A string 403 | @param[in] _Off Start position of the find 404 | @return Position of the first char that matches a char in _Ptr 405 | *************************************************************************/ 406 | size_t find_first_of(const char* _Ptr, size_t _Off = 0) const; 407 | 408 | /*!*********************************************************************** 409 | @brief Returns the position of the first char that matches a char in _Ptr. 410 | @param[in] _Ptr A string 411 | @param[in] _Off Start position of the find 412 | @param[in] _Count Size of _Ptr 413 | @return Position of the first char that matches a char in _Ptr 414 | *************************************************************************/ 415 | size_t find_first_of(const char* _Ptr, size_t _Off, size_t _Count) const; 416 | 417 | /*!*********************************************************************** 418 | @brief Returns the position of the first char that matches all chars in _Ptr. 419 | @param[in] _Ptr A string 420 | @param[in] _Off Start position of the find 421 | @param[in] _Count Size of _Ptr 422 | @return Position of the first char that matches a char in _Ptr 423 | *************************************************************************/ 424 | size_t find_first_ofn(const char* _Ptr, size_t _Off, size_t _Count) const; 425 | 426 | 427 | /*!*********************************************************************** 428 | @brief Returns the position of the first char that matches a char in _Str. 429 | @param[in] _Str A string 430 | @param[in] _Off Start position of the find 431 | @return Position of the first char that matches a char in _Str 432 | *************************************************************************/ 433 | size_t find_first_of(const CPVRTString& _Str, size_t _Off = 0) const; 434 | 435 | /*!*********************************************************************** 436 | @brief Returns the position of the last char that is not _Ch. 437 | @param[in] _Ch A char 438 | @param[in] _Off Start position of the find 439 | @return Position of the last char that is not _Ch 440 | *************************************************************************/ 441 | size_t find_last_not_of(char _Ch, size_t _Off = 0) const; 442 | 443 | /*!*********************************************************************** 444 | @brief Returns the position of the last char that is not in _Ptr. 445 | @param[in] _Ptr A string 446 | @param[in] _Off Start position of the find 447 | @return Position of the last char that is not in _Ptr 448 | *************************************************************************/ 449 | size_t find_last_not_of(const char* _Ptr, size_t _Off = 0) const; 450 | 451 | /*!*********************************************************************** 452 | @brief Returns the position of the last char that is not in _Ptr. 453 | @param[in] _Ptr A string 454 | @param[in] _Off Start position of the find 455 | @param[in] _Count Length of _Ptr 456 | @return Position of the last char that is not in _Ptr 457 | *************************************************************************/ 458 | size_t find_last_not_of(const char* _Ptr, size_t _Off, size_t _Count) const; 459 | 460 | /*!*********************************************************************** 461 | @brief Returns the position of the last char that is not in _Str. 462 | @param[in] _Str A string 463 | @param[in] _Off Start position of the find 464 | @return Position of the last char that is not in _Str 465 | *************************************************************************/ 466 | size_t find_last_not_of(const CPVRTString& _Str, size_t _Off = 0) const; 467 | 468 | /*!*********************************************************************** 469 | @brief Returns the position of the last char that is _Ch. 470 | @param[in] _Ch A char 471 | @param[in] _Off Start position of the find 472 | @return Position of the last char that is _Ch 473 | *************************************************************************/ 474 | size_t find_last_of(char _Ch, size_t _Off = 0) const; 475 | 476 | /*!*********************************************************************** 477 | @brief Returns the position of the last char that is in _Ptr. 478 | @param[in] _Ptr A string 479 | @param[in] _Off Start position of the find 480 | @return Position of the last char that is in _Ptr 481 | *************************************************************************/ 482 | size_t find_last_of(const char* _Ptr, size_t _Off = 0) const; 483 | 484 | /*!*********************************************************************** 485 | @brief Returns the position of the last char that is in _Ptr. 486 | @param[in] _Ptr A string 487 | @param[in] _Off Start position of the find 488 | @param[in] _Count Length of _Ptr 489 | @return Position of the last char that is in _Ptr 490 | *************************************************************************/ 491 | size_t find_last_of(const char* _Ptr, size_t _Off, size_t _Count) const; 492 | 493 | /*!*********************************************************************** 494 | @brief Returns the position of the last char that is in _Str. 495 | @param[in] _Str A string 496 | @param[in] _Off Start position of the find 497 | @return Position of the last char that is in _Str 498 | *************************************************************************/ 499 | size_t find_last_of(const CPVRTString& _Str, size_t _Off = 0) const; 500 | 501 | /*!*********************************************************************** 502 | @brief Returns the number of occurances of _Ch in the parent string. 503 | @param[in] _Ch A char 504 | @param[in] _Off Start position of the find 505 | @return Number of occurances of _Ch in the parent string. 506 | *************************************************************************/ 507 | size_t find_number_of(char _Ch, size_t _Off = 0) const; 508 | 509 | /*!*********************************************************************** 510 | @brief Returns the number of occurances of _Ptr in the parent string. 511 | @param[in] _Ptr A string 512 | @param[in] _Off Start position of the find 513 | @return Number of occurances of _Ptr in the parent string. 514 | *************************************************************************/ 515 | size_t find_number_of(const char* _Ptr, size_t _Off = 0) const; 516 | 517 | /*!*********************************************************************** 518 | @brief Returns the number of occurances of _Ptr in the parent string. 519 | @param[in] _Ptr A string 520 | @param[in] _Off Start position of the find 521 | @param[in] _Count Size of _Ptr 522 | @return Number of occurances of _Ptr in the parent string. 523 | *************************************************************************/ 524 | size_t find_number_of(const char* _Ptr, size_t _Off, size_t _Count) const; 525 | 526 | /*!*********************************************************************** 527 | @brief Returns the number of occurances of _Str in the parent string. 528 | @param[in] _Str A string 529 | @param[in] _Off Start position of the find 530 | @return Number of occurances of _Str in the parent string. 531 | *************************************************************************/ 532 | size_t find_number_of(const CPVRTString& _Str, size_t _Off = 0) const; 533 | 534 | /*!*********************************************************************** 535 | @brief Returns the next occurance of _Ch in the parent string 536 | after or at _Off. If not found, returns the length of the string. 537 | @param[in] _Ch A char 538 | @param[in] _Off Start position of the find 539 | @return Next occurance of _Ch in the parent string. 540 | *************************************************************************/ 541 | int find_next_occurance_of(char _Ch, size_t _Off = 0) const; 542 | 543 | /*!*********************************************************************** 544 | @brief Returns the next occurance of _Ptr in the parent string 545 | after or at _Off. If not found, returns the length of the string. 546 | @param[in] _Ptr A string 547 | @param[in] _Off Start position of the find 548 | @return Next occurance of _Ptr in the parent string. 549 | *************************************************************************/ 550 | int find_next_occurance_of(const char* _Ptr, size_t _Off = 0) const; 551 | 552 | /*!*********************************************************************** 553 | @brief Returns the next occurance of _Ptr in the parent string 554 | after or at _Off. If not found, returns the length of the string. 555 | @param[in] _Ptr A string 556 | @param[in] _Off Start position of the find 557 | @param[in] _Count Size of _Ptr 558 | @return Next occurance of _Ptr in the parent string. 559 | *************************************************************************/ 560 | int find_next_occurance_of(const char* _Ptr, size_t _Off, size_t _Count) const; 561 | 562 | /*!*********************************************************************** 563 | @brief Returns the next occurance of _Str in the parent string 564 | after or at _Off. If not found, returns the length of the string. 565 | @param[in] _Str A string 566 | @param[in] _Off Start position of the find 567 | @return Next occurance of _Str in the parent string. 568 | *************************************************************************/ 569 | int find_next_occurance_of(const CPVRTString& _Str, size_t _Off = 0) const; 570 | 571 | /*!*********************************************************************** 572 | @brief Returns the previous occurance of _Ch in the parent string. 573 | before _Off. If not found, returns -1. 574 | @param[in] _Ch A char 575 | @param[in] _Off Start position of the find 576 | @return Previous occurance of _Ch in the parent string. 577 | *************************************************************************/ 578 | int find_previous_occurance_of(char _Ch, size_t _Off = 0) const; 579 | 580 | /*!*********************************************************************** 581 | @brief Returns the previous occurance of _Ptr in the parent string. 582 | before _Off. If not found, returns -1. 583 | @param[in] _Ptr A string 584 | @param[in] _Off Start position of the find 585 | @return Previous occurance of _Ptr in the parent string. 586 | *************************************************************************/ 587 | int find_previous_occurance_of(const char* _Ptr, size_t _Off = 0) const; 588 | 589 | /*!*********************************************************************** 590 | @brief Returns the previous occurance of _Ptr in the parent string. 591 | before _Off. If not found, returns -1. 592 | @param[in] _Ptr A string 593 | @param[in] _Off Start position of the find 594 | @param[in] _Count Size of _Ptr 595 | @return Previous occurance of _Ptr in the parent string. 596 | *************************************************************************/ 597 | int find_previous_occurance_of(const char* _Ptr, size_t _Off, size_t _Count) const; 598 | 599 | /*!*********************************************************************** 600 | @brief Returns the previous occurance of _Str in the parent string. 601 | before _Off. If not found, returns -1. 602 | @param[in] _Str A string 603 | @param[in] _Off Start position of the find 604 | @return Previous occurance of _Str in the parent string. 605 | *************************************************************************/ 606 | int find_previous_occurance_of(const CPVRTString& _Str, size_t _Off = 0) const; 607 | 608 | /*!*********************************************************************** 609 | @fn left 610 | @param[in] iSize number of characters to return (excluding null character) 611 | @return The leftmost 'iSize' characters of the string. 612 | @brief Returns the leftmost characters of the string (excluding 613 | the null character) in a new CPVRTString. If iSize is 614 | larger than the string, a copy of the original string is returned. 615 | *************************************************************************/ 616 | CPVRTString left(size_t iSize) const; 617 | 618 | /*!*********************************************************************** 619 | @fn right 620 | @param[in] iSize number of characters to return (excluding null character) 621 | @return The rightmost 'iSize' characters of the string. 622 | @brief Returns the rightmost characters of the string (excluding 623 | the null character) in a new CPVRTString. If iSize is 624 | larger than the string, a copy of the original string is returned. 625 | *************************************************************************/ 626 | CPVRTString right(size_t iSize) const; 627 | 628 | //allocator_type get_allocator( ) const; 629 | 630 | //CPVRTString& insert(size_t _P0, const char* _Ptr); 631 | //CPVRTString& insert(size_t _P0, const char* _Ptr, size_t _Count); 632 | //CPVRTString& insert(size_t _P0, const CPVRTString& _Str); 633 | //CPVRTString& insert(size_t _P0, const CPVRTString& _Str, size_t _Off, size_t _Count); 634 | //CPVRTString& insert(size_t _P0, size_t _Count, char _Ch); 635 | //iterator insert(iterator _It, char _Ch = char()); 636 | //template void insert(iterator _It, InputIterator _First, InputIterator _Last); 637 | //void insert(iterator _It, size_t _Count, char _Ch); 638 | 639 | /*!*********************************************************************** 640 | @fn length 641 | @return Length of the string 642 | @brief Returns the length of the string. 643 | *************************************************************************/ 644 | size_t length() const; 645 | 646 | /*!*********************************************************************** 647 | @fn max_size 648 | @return The maximum number of chars that the string can contain 649 | @brief Returns the maximum number of chars that the string can contain. 650 | *************************************************************************/ 651 | size_t max_size() const; 652 | 653 | /*!*********************************************************************** 654 | @fn push_back 655 | @param[in] _Ch A char to append 656 | @brief Appends _Ch to the string. 657 | *************************************************************************/ 658 | void push_back(char _Ch); 659 | 660 | // const_reverse_iterator rbegin() const; 661 | // reverse_iterator rbegin(); 662 | 663 | // const_reverse_iterator rend() const; 664 | // reverse_iterator rend(); 665 | 666 | //CPVRTString& replace(size_t _Pos1, size_t _Num1, const char* _Ptr); 667 | //CPVRTString& replace(size_t _Pos1, size_t _Num1, const CPVRTString& _Str); 668 | //CPVRTString& replace(size_t _Pos1, size_t _Num1, const char* _Ptr, size_t _Num2); 669 | //CPVRTString& replace(size_t _Pos1, size_t _Num1, const CPVRTString& _Str, size_t _Pos2, size_t _Num2); 670 | //CPVRTString& replace(size_t _Pos1, size_t _Num1, size_t _Count, char _Ch); 671 | 672 | //CPVRTString& replace(iterator _First0, iterator _Last0, const char* _Ptr); 673 | //CPVRTString& replace(iterator _First0, iterator _Last0, const CPVRTString& _Str); 674 | //CPVRTString& replace(iterator _First0, iterator _Last0, const char* _Ptr, size_t _Num2); 675 | //CPVRTString& replace(iterator _First0, iterator _Last0, size_t _Num2, char _Ch); 676 | //template CPVRTString& replace(iterator _First0, iterator _Last0, InputIterator _First, InputIterator _Last); 677 | 678 | /*!*********************************************************************** 679 | @fn reserve 680 | @param[in] _Count Size of string to reserve 681 | @brief Reserves space for _Count number of chars. 682 | *************************************************************************/ 683 | void reserve(size_t _Count = 0); 684 | 685 | /*!*********************************************************************** 686 | @fn resize 687 | @param[in] _Count Size of string to resize to 688 | @param[in] _Ch Character to use to fill any additional space 689 | @brief Resizes the string to _Count in length. 690 | *************************************************************************/ 691 | void resize(size_t _Count, char _Ch = char()); 692 | 693 | //size_t rfind(char _Ch, size_t _Off = npos) const; 694 | //size_t rfind(const char* _Ptr, size_t _Off = npos) const; 695 | //size_t rfind(const char* _Ptr, size_t _Off = npos, size_t _Count) const; 696 | //size_t rfind(const CPVRTString& _Str, size_t _Off = npos) const; 697 | 698 | /*!*********************************************************************** 699 | @fn size 700 | @return Size of the string 701 | @brief Returns the size of the string. 702 | *************************************************************************/ 703 | size_t size() const; 704 | 705 | /*!*********************************************************************** 706 | @fn substr 707 | @param[in] _Off Start of the substring 708 | @param[in] _Count Length of the substring 709 | @return A substring of the string 710 | @brief Returns the size of the string. 711 | *************************************************************************/ 712 | CPVRTString substr(size_t _Off = 0, size_t _Count = npos) const; 713 | 714 | /*!*********************************************************************** 715 | @fn swap 716 | @param[in] _Str A string to swap with 717 | @brief Swaps the contents of the string with _Str. 718 | *************************************************************************/ 719 | void swap(CPVRTString& _Str); 720 | 721 | /*!*********************************************************************** 722 | @fn toLower 723 | @return An updated string 724 | @brief Converts the string to lower case. 725 | *************************************************************************/ 726 | CPVRTString& toLower(); 727 | 728 | /*!*********************************************************************** 729 | @fn toUpper 730 | @return An updated string 731 | @brief Converts the string to upper case. 732 | *************************************************************************/ 733 | CPVRTString& toUpper(); 734 | 735 | /*!*********************************************************************** 736 | @fn format 737 | @param[in] pFormat A string containing the formating 738 | @return A formatted string 739 | @brief Return the formatted string. 740 | ************************************************************************/ 741 | CPVRTString format(const char *pFormat, ...); 742 | 743 | #ifndef UNDER_CE 744 | /*!*********************************************************************** 745 | @fn formatPositional 746 | @param[in] pFormat A string containing the formatting. 747 | Positional modifiers may be used. 748 | @return A formatted string 749 | @brief Return the formatted string. 750 | ************************************************************************/ 751 | CPVRTString formatPositional(const char *pFormat, ...); 752 | #endif 753 | 754 | /*!*********************************************************************** 755 | @brief += Operator. 756 | @param[in] _Ch A char 757 | @return An updated string 758 | *************************************************************************/ 759 | CPVRTString& operator+=(char _Ch); 760 | 761 | /*!*********************************************************************** 762 | @brief += Operator. 763 | @param[in] _Ptr A string 764 | @return An updated string 765 | *************************************************************************/ 766 | CPVRTString& operator+=(const char* _Ptr); 767 | 768 | /*!*********************************************************************** 769 | @brief += Operator. 770 | @param[in] _Right A string 771 | @return An updated string 772 | *************************************************************************/ 773 | CPVRTString& operator+=(const CPVRTString& _Right); 774 | 775 | /*!*********************************************************************** 776 | @brief = Operator. 777 | @param[in] _Ch A char 778 | @return An updated string 779 | *************************************************************************/ 780 | CPVRTString& operator=(char _Ch); 781 | 782 | /*!*********************************************************************** 783 | @brief = Operator. 784 | @param[in] _Ptr A string 785 | @return An updated string 786 | *************************************************************************/ 787 | CPVRTString& operator=(const char* _Ptr); 788 | 789 | /*!*********************************************************************** 790 | @brief = Operator. 791 | @param[in] _Right A string 792 | @return An updated string 793 | *************************************************************************/ 794 | CPVRTString& operator=(const CPVRTString& _Right); 795 | 796 | /*!*********************************************************************** 797 | @brief [] Operator. 798 | @param[in] _Off An index into the string 799 | @return A character 800 | *************************************************************************/ 801 | const_reference operator[](size_t _Off) const; 802 | 803 | /*!*********************************************************************** 804 | @brief [] Operator. 805 | @param[in] _Off An index into the string 806 | @return A character 807 | *************************************************************************/ 808 | reference operator[](size_t _Off); 809 | 810 | /*!*********************************************************************** 811 | @brief + Operator. 812 | @param[in] _Left A string 813 | @param[in] _Right A string 814 | @return An updated string 815 | *************************************************************************/ 816 | friend CPVRTString operator+ (const CPVRTString& _Left, const CPVRTString& _Right); 817 | 818 | /*!*********************************************************************** 819 | @brief + Operator. 820 | @param[in] _Left A string 821 | @param[in] _Right A string 822 | @return An updated string 823 | *************************************************************************/ 824 | friend CPVRTString operator+ (const CPVRTString& _Left, const char* _Right); 825 | 826 | /*!*********************************************************************** 827 | @brief + Operator. 828 | @param[in] _Left A string 829 | @param[in] _Right A string 830 | @return An updated string 831 | *************************************************************************/ 832 | friend CPVRTString operator+ (const CPVRTString& _Left, const char _Right); 833 | 834 | /*!*********************************************************************** 835 | @brief + Operator. 836 | @param[in] _Left A string 837 | @param[in] _Right A string 838 | @return An updated string 839 | *************************************************************************/ 840 | friend CPVRTString operator+ (const char* _Left, const CPVRTString& _Right); 841 | 842 | 843 | /*!*********************************************************************** 844 | @brief + Operator. 845 | @param[in] _Left A string 846 | @param[in] _Right A string 847 | @return An updated string 848 | *************************************************************************/ 849 | friend CPVRTString operator+ (const char _Left, const CPVRTString& _Right); 850 | 851 | protected: 852 | char* m_pString; 853 | size_t m_Size; 854 | size_t m_Capacity; 855 | }; 856 | 857 | /************************************************************************* 858 | * MISCELLANEOUS UTILITY FUNCTIONS 859 | *************************************************************************/ 860 | /*!*********************************************************************** 861 | @fn PVRTStringGetFileExtension 862 | @param[in] strFilePath A string 863 | @return Extension 864 | @brief Extracts the file extension from a file path. 865 | Returns an empty CPVRTString if no extension is found. 866 | ************************************************************************/ 867 | CPVRTString PVRTStringGetFileExtension(const CPVRTString& strFilePath); 868 | 869 | /*!*********************************************************************** 870 | @fn PVRTStringGetContainingDirectoryPath 871 | @param[in] strFilePath A string 872 | @return Directory 873 | @brief Extracts the directory portion from a file path. 874 | ************************************************************************/ 875 | CPVRTString PVRTStringGetContainingDirectoryPath(const CPVRTString& strFilePath); 876 | 877 | /*!*********************************************************************** 878 | @fn PVRTStringGetFileName 879 | @param[in] strFilePath A string 880 | @return FileName 881 | @brief Extracts the name and extension portion from a file path. 882 | ************************************************************************/ 883 | CPVRTString PVRTStringGetFileName(const CPVRTString& strFilePath); 884 | 885 | /*!*********************************************************************** 886 | @fn PVRTStringStripWhiteSpaceFromStartOf 887 | @param[in] strLine A string 888 | @return Result of the white space stripping 889 | @brief Strips white space characters from the beginning of a CPVRTString. 890 | ************************************************************************/ 891 | CPVRTString PVRTStringStripWhiteSpaceFromStartOf(const CPVRTString& strLine); 892 | 893 | /*!*********************************************************************** 894 | @fn PVRTStringStripWhiteSpaceFromEndOf 895 | @param[in] strLine A string 896 | @return Result of the white space stripping 897 | @brief Strips white space characters from the end of a CPVRTString. 898 | ************************************************************************/ 899 | CPVRTString PVRTStringStripWhiteSpaceFromEndOf(const CPVRTString& strLine); 900 | 901 | /*!*********************************************************************** 902 | @fn PVRTStringFromFormattedStr 903 | @param[in] pFormat A string containing the formating 904 | @return A formatted string 905 | @brief Creates a formatted string. 906 | ************************************************************************/ 907 | CPVRTString PVRTStringFromFormattedStr(const char *pFormat, ...); 908 | 909 | #ifndef UNDER_CE 910 | /*!*********************************************************************** 911 | @Function PVRTStringFromFormattedStrPositional 912 | @Input pFormat A string containing the formatting 913 | with optional positional qualifiers 914 | @Returns A formatted string 915 | @Description Creates a formatted string 916 | ************************************************************************/ 917 | CPVRTString PVRTStringFromFormattedStrPositional(const char *pFormat, ...); 918 | #endif 919 | 920 | #endif // _PVRTSTRING_H_ 921 | 922 | /***************************************************************************** 923 | End of file (PVRTString.h) 924 | *****************************************************************************/ 925 | 926 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Include/PVRTTexture.h: -------------------------------------------------------------------------------- 1 | /*!**************************************************************************** 2 | 3 | @file PVRTTexture.h 4 | @copyright Copyright (c) Imagination Technologies Limited. 5 | @brief Texture loading. 6 | 7 | ******************************************************************************/ 8 | #ifndef _PVRTTEXTURE_H_ 9 | #define _PVRTTEXTURE_H_ 10 | 11 | #include "PVRTGlobal.h" 12 | 13 | /***************************************************************************** 14 | * Texture related constants and enumerations. 15 | *****************************************************************************/ 16 | // V3 Header Identifiers. 17 | const PVRTuint32 PVRTEX3_IDENT = 0x03525650; // 'P''V''R'3 18 | const PVRTuint32 PVRTEX3_IDENT_REV = 0x50565203; 19 | // If endianness is backwards then PVR3 will read as 3RVP, hence why it is written as an int. 20 | 21 | //Current version texture identifiers 22 | const PVRTuint32 PVRTEX_CURR_IDENT = PVRTEX3_IDENT; 23 | const PVRTuint32 PVRTEX_CURR_IDENT_REV = PVRTEX3_IDENT_REV; 24 | 25 | // PVR Header file flags. Condition if true. If false, opposite is true unless specified. 26 | const PVRTuint32 PVRTEX3_FILE_COMPRESSED = (1<<0); // Texture has been file compressed using PVRTexLib (currently unused) 27 | const PVRTuint32 PVRTEX3_PREMULTIPLIED = (1<<1); // Texture has been premultiplied by alpha value. 28 | 29 | // Mip Map level specifier constants. Other levels are specified by 1,2...n 30 | const PVRTint32 PVRTEX_TOPMIPLEVEL = 0; 31 | const PVRTint32 PVRTEX_ALLMIPLEVELS = -1; //This is a special number used simply to return a total of all MIP levels when dealing with data sizes. 32 | 33 | //values for each meta data type that we know about. Texture arrays hinge on each surface being identical in all but content, including meta data. 34 | //If the meta data varies even slightly then a new texture should be used. It is possible to write your own extension to get around this however. 35 | enum EPVRTMetaData 36 | { 37 | ePVRTMetaDataTextureAtlasCoords=0, 38 | ePVRTMetaDataBumpData, 39 | ePVRTMetaDataCubeMapOrder, 40 | ePVRTMetaDataTextureOrientation, 41 | ePVRTMetaDataBorderData, 42 | ePVRTMetaDataPadding, 43 | ePVRTMetaDataNumMetaDataTypes 44 | }; 45 | 46 | enum EPVRTAxis 47 | { 48 | ePVRTAxisX = 0, 49 | ePVRTAxisY = 1, 50 | ePVRTAxisZ = 2 51 | }; 52 | 53 | enum EPVRTOrientation 54 | { 55 | ePVRTOrientLeft = 1< 630 | class CPVRTMap; 631 | 632 | 633 | /*!*********************************************************************** 634 | @fn PVRTGetBitsPerPixel 635 | @param[in] u64PixelFormat A PVR Pixel Format ID. 636 | @return const PVRTuint32 Number of bits per pixel. 637 | @brief Returns the number of bits per pixel in a PVR Pixel Format 638 | identifier. 639 | *************************************************************************/ 640 | PVRTuint32 PVRTGetBitsPerPixel(PVRTuint64 u64PixelFormat); 641 | 642 | /*!*********************************************************************** 643 | @fn PVRTGetFormatMinDims 644 | @param[in] u64PixelFormat A PVR Pixel Format ID. 645 | @param[in,out] minX Returns the minimum width. 646 | @param[in,out] minY Returns the minimum height. 647 | @param[in,out] minZ Returns the minimum depth. 648 | @brief Gets the minimum dimensions (x,y,z) for a given pixel format. 649 | *************************************************************************/ 650 | void PVRTGetFormatMinDims(PVRTuint64 u64PixelFormat, PVRTuint32 &minX, PVRTuint32 &minY, PVRTuint32 &minZ); 651 | 652 | /*!*********************************************************************** 653 | @fn PVRTConvertOldTextureHeaderToV3 654 | @param[in] LegacyHeader Legacy header for conversion. 655 | @param[in,out] NewHeader New header to output into. 656 | @param[in,out] pMetaData MetaData Map to output into. 657 | @brief Converts a legacy texture header (V1 or V2) to a current 658 | generation header (V3). 659 | *************************************************************************/ 660 | void PVRTConvertOldTextureHeaderToV3(const PVR_Texture_Header* LegacyHeader, PVRTextureHeaderV3& NewHeader, CPVRTMap >* pMetaData); 661 | 662 | /*!*********************************************************************** 663 | @fn PVRTMapLegacyTextureEnumToNewFormat 664 | @param[in] OldFormat Legacy Enumeration Value 665 | @param[in,out] newType New PixelType identifier. 666 | @param[in,out] newCSpace New ColourSpace 667 | @param[in,out] newChanType New Channel Type 668 | @param[in,out] isPreMult Whether format is pre-multiplied 669 | @brief Maps a legacy enumeration value to the new PVR3 style format. 670 | *************************************************************************/ 671 | void PVRTMapLegacyTextureEnumToNewFormat(PVRTPixelType OldFormat, PVRTuint64& newType, EPVRTColourSpace& newCSpace, EPVRTVariableType& newChanType, bool& isPreMult); 672 | 673 | /*!*************************************************************************** 674 | @fn PVRTTextureLoadTiled 675 | @param[in,out] pDst Texture to place the tiled data 676 | @param[in] nWidthDst Width of destination texture 677 | @param[in] nHeightDst Height of destination texture 678 | @param[in] pSrc Texture to tile 679 | @param[in] nWidthSrc Width of source texture 680 | @param[in] nHeightSrc Height of source texture 681 | @param[in] nElementSize Bytes per pixel 682 | @param[in] bTwiddled True if the data is twiddled 683 | @brief Needed by PVRTTextureTile() in the various PVRTTextureAPIs. 684 | *****************************************************************************/ 685 | void PVRTTextureLoadTiled( 686 | PVRTuint8 * const pDst, 687 | const unsigned int nWidthDst, 688 | const unsigned int nHeightDst, 689 | const PVRTuint8 * const pSrc, 690 | const unsigned int nWidthSrc, 691 | const unsigned int nHeightSrc, 692 | const unsigned int nElementSize, 693 | const bool bTwiddled); 694 | 695 | 696 | /*!*************************************************************************** 697 | @fn PVRTTextureTwiddle 698 | @param[out] a Twiddled value 699 | @param[in] u Coordinate axis 0 700 | @param[in] v Coordinate axis 1 701 | @brief Combine a 2D coordinate into a twiddled value. 702 | *****************************************************************************/ 703 | void PVRTTextureTwiddle(unsigned int &a, const unsigned int u, const unsigned int v); 704 | 705 | /*!*************************************************************************** 706 | @fn PVRTTextureDeTwiddle 707 | @param[out] u Coordinate axis 0 708 | @param[out] v Coordinate axis 1 709 | @param[in] a Twiddled value 710 | @brief Extract 2D coordinates from a twiddled value. 711 | *****************************************************************************/ 712 | void PVRTTextureDeTwiddle(unsigned int &u, unsigned int &v, const unsigned int a); 713 | 714 | /*!*********************************************************************** 715 | @fn PVRTGetTextureDataSize 716 | @param[in] sTextureHeader Specifies the texture header. 717 | @param[in] iMipLevel Specifies a mip level to check, 'PVRTEX_ALLMIPLEVELS' 718 | can be passed to get the size of all MIP levels. 719 | @param[in] bAllSurfaces Size of all surfaces is calculated if true, 720 | only a single surface if false. 721 | @param[in] bAllFaces Size of all faces is calculated if true, 722 | only a single face if false. 723 | @return PVRTuint32 Size in BYTES of the specified texture area. 724 | @brief Gets the size in BYTES of the texture, given various input 725 | parameters. User can retrieve the size of either all 726 | surfaces or a single surface, all faces or a single face and 727 | all MIP-Maps or a single specified MIP level. 728 | *************************************************************************/ 729 | PVRTuint32 PVRTGetTextureDataSize(PVRTextureHeaderV3 sTextureHeader, PVRTint32 iMipLevel=PVRTEX_ALLMIPLEVELS, bool bAllSurfaces = true, bool bAllFaces = true); 730 | 731 | #endif /* _PVRTTEXTURE_H_ */ 732 | 733 | /***************************************************************************** 734 | End of file (PVRTTexture.h) 735 | *****************************************************************************/ 736 | 737 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Include/PVRTexture.h: -------------------------------------------------------------------------------- 1 | /*!*********************************************************************** 2 | 3 | @file PVRTexture.h 4 | @copyright Copyright (c) Imagination Technologies Limited. 5 | @brief Contains methods concerning basic CPVRTexture creation, saving 6 | and data duplication. This is the main class for PVRTexLib. 7 | 8 | *************************************************************************/ 9 | 10 | /*****************************************************************************/ 11 | /*! @mainpage PVRTexLib 12 | ****************************************************************************** 13 | 14 | @section overview Overview 15 | ***************************** 16 | 17 | PVRTexLib is a library for the management of textures. It occupies the @ref pvrtexture 18 | namespace and allows users to access the PVRTexTool functionality in a library, 19 | for easy integration with existing tool chains. 20 | 21 | PVRTexLib contains the facility to: 22 | \li Load and save PVR files. 23 | \li Transcode to and from many different texture formats. 24 | \li Perform a variety of pre-process techniques on decompressed pixel data. 25 | \li Provide information about a texture file loaded by the library. 26 | 27 | @section pvrtools PVRTools 28 | ***************************** 29 | A number of header files from the PowerVR SDK Tools libraries are present in PVRTexLib: 30 | \li PVRTGlobal.h 31 | \li PVRTError.h 32 | \li PVRTArray.h 33 | \li PVRTMap.h 34 | \li PVRTString.h 35 | \li PVRTTexture.h 36 | 37 | These header files are included in the PVRTexLib package so that separate installation 38 | of the tools libraries is not required. If PowerVR Graphics SDK Tools are installed, 39 | documentation for the these files can be found in the ‘Tools’ folder 40 | in the PowerVR Insider SDK directory. 41 | 42 | */ 43 | 44 | #ifndef _PVRTEXTURE_H 45 | #define _PVRTEXTURE_H 46 | 47 | #include "PVRTextureDefines.h" 48 | #include "PVRTextureHeader.h" 49 | #include "PVRTString.h" 50 | 51 | namespace pvrtexture 52 | { 53 | /*!*********************************************************************** 54 | @class CPVRTexture 55 | @brief A full public texture container format, with support for custom 56 | meta-data, and complete, optimised, resource loading code into PVRTools. 57 | *************************************************************************/ 58 | class PVR_DLL CPVRTexture : public CPVRTextureHeader 59 | { 60 | public: 61 | // Construction methods for a texture. 62 | 63 | /*!*********************************************************************** 64 | @brief Creates a new empty texture 65 | @return A new CPVRTexture. 66 | *************************************************************************/ 67 | CPVRTexture(); 68 | 69 | /*!*********************************************************************** 70 | @brief Creates a new texture based on a texture header, 71 | pre-allocating the correct amount of memory. If data is 72 | supplied, it will be copied into memory. 73 | @param[in] sHeader Texture header 74 | @param[in] pData Texture data 75 | @return A new CPVRTexture. 76 | *************************************************************************/ 77 | CPVRTexture(const CPVRTextureHeader& sHeader, const void* pData=NULL); 78 | 79 | /*!*********************************************************************** 80 | @brief Creates a new texture from a filepath. 81 | @param[in] szFilePath File path to existing texture 82 | @return A new CPVRTexture. 83 | *************************************************************************/ 84 | CPVRTexture(const char* szFilePath); 85 | 86 | /*!*********************************************************************** 87 | @brief Creates a new texture from a pointer that includes a header 88 | structure, meta data and texture data as laid out in a file. 89 | This functionality is primarily for user-defined file loading. 90 | Header may be any version of pvr. 91 | @param[in] pTexture Pointer to texture data 92 | @return A new CPVRTexture. 93 | *************************************************************************/ 94 | CPVRTexture( const void* pTexture ); 95 | 96 | /*!*********************************************************************** 97 | @brief Creates a new texture as a copy of another. 98 | @param[in] texture Texture to copy 99 | @return A new CPVRTexture 100 | *************************************************************************/ 101 | CPVRTexture(const CPVRTexture& texture); 102 | 103 | /*!*********************************************************************** 104 | @brief Deconstructor for CPVRTextures. 105 | *************************************************************************/ 106 | ~CPVRTexture(); 107 | 108 | /*!*********************************************************************** 109 | @brief Will copy the contents and information of another texture into this one. 110 | @param[in] rhs Texture to copy 111 | @return This texture. 112 | *************************************************************************/ 113 | CPVRTexture& operator=(const CPVRTexture& rhs); 114 | 115 | // Texture accessor functions - others are inherited from CPVRTextureHeader. 116 | 117 | /*!*********************************************************************** 118 | @brief Returns a pointer into the texture's data. 119 | @details It is possible to specify an offset to specific array members, 120 | faces and MIP Map levels. 121 | @param[in] uiMIPLevel Offset to MIP Map levels 122 | @param[in] uiArrayMember Offset to array members 123 | @param[in] uiFaceNumber Offset to face numbers 124 | @return Pointer to a location in the texture. 125 | *************************************************************************/ 126 | void* getDataPtr(uint32 uiMIPLevel = 0, uint32 uiArrayMember = 0, uint32 uiFaceNumber = 0) const; 127 | 128 | /*!*********************************************************************** 129 | @brief Gets the header for this texture, allowing you to create a new 130 | texture based on this one with some changes. Useful for passing 131 | information about a texture without passing all of its data. 132 | @return Returns the header only for this texture. 133 | *************************************************************************/ 134 | const CPVRTextureHeader& getHeader() const; 135 | 136 | // File io. 137 | 138 | /*!*********************************************************************** 139 | @brief When writing the texture out to a PVR file, it is often 140 | desirable to pad the meta data so that the start of the 141 | texture data aligns to a given boundary. 142 | @details This function pads to a boundary value equal to "uiPadding". 143 | For example setting uiPadding=8 will align the start of the 144 | texture data to an 8 byte boundary. 145 | Note - this should be called immediately before saving as 146 | the value is worked out based on the current meta data size. 147 | @param[in] uiPadding Padding boundary value 148 | *************************************************************************/ 149 | void addPaddingMetaData( uint32 uiPadding ); 150 | 151 | /*!*********************************************************************** 152 | @brief Writes out to a file, given a filename and path. 153 | @details File type will be determined by the extension present in the string. 154 | If no extension is present, PVR format will be selected. 155 | Unsupported formats will result in failure. 156 | @param[in] filepath File path to write to 157 | @return True if the method succeeds. 158 | *************************************************************************/ 159 | bool saveFile(const CPVRTString& filepath) const; 160 | 161 | /*!*********************************************************************** 162 | @brief Writes out to a file, stripping any extensions specified 163 | and appending .pvr. This function is for legacy support only 164 | and saves out to PVR Version 2 file. The target api must be 165 | specified in order to save to this format. 166 | @param[in] filepath File path to write to 167 | @param[in] eApi Target API 168 | @return True if the method succeeds. 169 | *************************************************************************/ 170 | bool saveFileLegacyPVR(const CPVRTString& filepath, ELegacyApi eApi) const; 171 | 172 | /*!*********************************************************************** 173 | @brief Saves an ASTC File. 174 | @param[in] filepath File path to write to 175 | @return True if the method succeeds. 176 | *************************************************************************/ 177 | bool saveASTCFile(const CPVRTString& filepath) const; 178 | 179 | private: 180 | size_t m_stDataSize; //!< Size of the texture data. 181 | uint8* m_pTextureData; //!< Pointer to texture data. 182 | 183 | // Private IO functions 184 | 185 | /*!*********************************************************************** 186 | @brief Loads a PVR file. 187 | @param[in] pTextureFile PVR texture file 188 | @return True if the method succeeds. 189 | *************************************************************************/ 190 | bool privateLoadPVRFile(FILE* pTextureFile); 191 | 192 | /*!*********************************************************************** 193 | @brief Saves a PVR File. 194 | @param[in] pTextureFile PVR texture file 195 | @return True if the method succeeds. 196 | *************************************************************************/ 197 | bool privateSavePVRFile(FILE* pTextureFile) const; 198 | 199 | /*!*********************************************************************** 200 | @brief Loads a KTX file. 201 | @param[in] pTextureFile KTX texture file 202 | @return True if the method succeeds. 203 | *************************************************************************/ 204 | bool privateLoadKTXFile(FILE* pTextureFile); 205 | 206 | /*!*********************************************************************** 207 | @brief Saves a KTX File. 208 | @param[in] pTextureFile KTX texture file 209 | @return True if the method succeeds. 210 | *************************************************************************/ 211 | bool privateSaveKTXFile(FILE* pTextureFile) const; 212 | 213 | /*!*********************************************************************** 214 | @brief Loads a DDS file. 215 | @param[in] pTextureFile DDS texture file 216 | @return True if the method succeeds. 217 | *************************************************************************/ 218 | bool privateLoadDDSFile(FILE* pTextureFile); 219 | 220 | /*!*********************************************************************** 221 | @brief Saves a DDS File. 222 | @param[in] pTextureFile DDS texture file 223 | @return True if the method succeeds. 224 | *************************************************************************/ 225 | bool privateSaveDDSFile(FILE* pTextureFile) const; 226 | 227 | /*!*********************************************************************** 228 | @brief Loads an ASTC file. 229 | @param[in] pTextureFile ASTC texture file 230 | @return True if the method succeeds. 231 | *************************************************************************/ 232 | bool privateLoadASTCFile(FILE* pTextureFile); 233 | 234 | /*!*********************************************************************** 235 | @brief Saves an ASTC file. 236 | @param[in] pTextureFile ASTC texture file 237 | @return True if the method succeeds. 238 | *************************************************************************/ 239 | bool privateSaveASTCFile(FILE* pTextureFile) const; 240 | 241 | //Legacy IO 242 | 243 | /*!*********************************************************************** 244 | @brief Saves a .h File. Legacy operator 245 | @param[in] pTextureFile PVR texture file 246 | @param[in] filename File path to write to 247 | @return True if the method succeeds. 248 | *************************************************************************/ 249 | bool privateSaveCHeaderFile(FILE* pTextureFile, CPVRTString filename) const; 250 | 251 | /*!*********************************************************************** 252 | @brief Saves a legacy PVR File - Uses version 2 file format. 253 | @param[in] pTextureFile PVR texture file 254 | @param[in] eApi Target API 255 | @return True if the method succeeds. 256 | *************************************************************************/ 257 | bool privateSaveLegacyPVRFile(FILE* pTextureFile, ELegacyApi eApi) const; 258 | }; 259 | }; 260 | 261 | #endif //_PVRTEXTURE_H 262 | 263 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Include/PVRTextureDefines.h: -------------------------------------------------------------------------------- 1 | /*!*********************************************************************** 2 | 3 | @file PVRTextureDefines.h 4 | @copyright Copyright (c) Imagination Technologies Limited. 5 | @brief Method, template and type defines for PVRTexture. 6 | 7 | *************************************************************************/ 8 | 9 | #ifndef _PVRTEXTURE_DEFINES_H 10 | #define _PVRTEXTURE_DEFINES_H 11 | 12 | //To use the PVRTexLib .dll on Windows, you need to define _WINDLL_IMPORT 13 | #ifndef PVR_DLL 14 | #if defined(_WINDLL_EXPORT) 15 | #define PVR_DLL __declspec(dllexport) 16 | //Forward declaration of various classes/structs used by this library. This exports their interfaces for DLLs. 17 | struct PVR_DLL PVRTextureHeaderV3; 18 | struct PVR_DLL MetaDataBlock; 19 | template 20 | class PVR_DLL CPVRTMap; 21 | template 22 | class PVR_DLL CPVRTArray; 23 | class PVR_DLL CPVRTString; 24 | #elif defined(_WINDLL_IMPORT) 25 | #define PVR_DLL __declspec(dllimport) 26 | //Forward declaration of various classes/structs used by this library. This imports their interfaces for DLLs. 27 | struct PVR_DLL PVRTextureHeaderV3; 28 | struct PVR_DLL MetaDataBlock; 29 | template 30 | class PVR_DLL CPVRTMap; 31 | template 32 | class PVR_DLL CPVRTArray; 33 | class PVR_DLL CPVRTString; 34 | #else 35 | 36 | /*!*********************************************************************** 37 | @def PVR_DLL 38 | @brief Required to use PVRTexLib.dll on Windows. 39 | *************************************************************************/ 40 | #define PVR_DLL 41 | #endif 42 | #endif 43 | 44 | #include "PVRTTexture.h" 45 | 46 | /*!*********************************************************************** 47 | @namespace pvrtexture 48 | @brief PVRTexture namespace. Contains methods and classes for PVRTexLib. 49 | *************************************************************************/ 50 | namespace pvrtexture 51 | { 52 | // Type defines for standard variable sizes. 53 | 54 | typedef signed char int8; //!< Signed 8 bit integer 55 | typedef signed short int16; //!< Signed 16 bit integer 56 | typedef signed int int32; //!< Signed 32 bit integer 57 | typedef signed long long int64; //!< Signed 64 bit integer 58 | typedef unsigned char uint8; //!< Unsigned 8 bit integer 59 | typedef unsigned short uint16; //!< Unsigned 16 bit integer 60 | typedef unsigned int uint32; //!< Unsigned 32 bit integer 61 | typedef unsigned long long uint64; //!< Unsigned 64 bit integer 62 | 63 | // Texture related constants and enumerations. 64 | 65 | /*!*********************************************************************** 66 | @enum ECompressorQuality 67 | @brief Quality level to compress the texture with. Currently valid with 68 | ETC and PVRTC formats. 69 | *************************************************************************/ 70 | enum ECompressorQuality 71 | { 72 | ePVRTCFastest=0, //!< PVRTC fastest 73 | ePVRTCFast, //!< PVRTC fast 74 | ePVRTCNormal, //!< PVRTC normal 75 | ePVRTCHigh, //!< PVRTC high 76 | ePVRTCBest, //!< PVRTC best 77 | eNumPVRTCModes, //!< Number of PVRTC modes 78 | 79 | eETCFast=0, //!< ETC fast 80 | eETCFastPerceptual, //!< ETC fast perceptual 81 | eETCSlow, //!< ETC slow 82 | eETCSlowPerceptual, //!< ETC slow perceptual 83 | eNumETCModes, //!< Number of ETC modes 84 | 85 | eASTCVeryFast=0, //!< ASTC very fast 86 | eASTCFast, //!< ASTC fast 87 | eASTCMedium, //!< ASTC medium 88 | eASTCThorough, //!< ASTC thorough 89 | eASTCExhaustive, //!< ASTC exhaustive 90 | eNumASTCModes //!< Number of ASTC modes 91 | }; 92 | 93 | /*!*********************************************************************** 94 | @enum EResizeMode 95 | @brief Texture resize mode 96 | *************************************************************************/ 97 | enum EResizeMode 98 | { 99 | eResizeNearest, //!< Nearest filtering 100 | eResizeLinear, //!< Linear filtering 101 | eResizeCubic, //!< Cubic filtering, uses Catmull-Rom splines. 102 | eNumResizeModes //!< Number of resize modes 103 | }; 104 | 105 | /*!*********************************************************************** 106 | @enum ELegacyApi 107 | @brief Legacy API enum. 108 | *************************************************************************/ 109 | enum ELegacyApi 110 | { 111 | eOGLES=1, //!< OpenGL ES 1.x 112 | eOGLES2, //!< OpenGL ES 2.0 113 | eD3DM, //!< Direct 3D M 114 | eOGL, //!< Open GL 115 | eDX9, //!< DirextX 9 116 | eDX10, //!< DirectX 10 117 | eOVG, //!< Open VG 118 | eMGL, //!< MGL 119 | }; 120 | 121 | // Useful macros. 122 | /*!*************************************************************************** 123 | @def TEXOFFSET2D 124 | @brief 2D texture offset 125 | *****************************************************************************/ 126 | #define TEXOFFSET2D(x,y,width) ( ((x)+(y)*(width)) ) 127 | 128 | /*!*************************************************************************** 129 | @def TEXOFFSET3D 130 | @brief 3D texture offset 131 | *****************************************************************************/ 132 | #define TEXOFFSET3D(x,y,z,width,height) ( ((x)+(y)*(width)+(z)*(width)*(height)) ) 133 | 134 | /*!*************************************************************************** 135 | @typedef MetaDataMap 136 | @brief Useful typedef for generating maps of MetaData blocks. 137 | *****************************************************************************/ 138 | typedef CPVRTMap > MetaDataMap; 139 | }; 140 | #endif //_PVRTEXTURE_DEFINES_H 141 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Include/PVRTextureFormat.h: -------------------------------------------------------------------------------- 1 | #ifndef _PVRT_PIXEL_FORMAT_H 2 | #define _PVRT_PIXEL_FORMAT_H 3 | 4 | #include "PVRTextureDefines.h" 5 | #include "PVRTString.h" 6 | 7 | namespace pvrtexture 8 | { 9 | //Channel Names 10 | enum EChannelName 11 | { 12 | eNoChannel, 13 | eRed, 14 | eGreen, 15 | eBlue, 16 | eAlpha, 17 | eLuminance, 18 | eIntensity, 19 | eUnspecified, 20 | eNumChannels 21 | }; 22 | 23 | //PixelType union 24 | union PVR_DLL PixelType 25 | { 26 | /*!*********************************************************************** 27 | @Function PixelType 28 | @Return A new PixelType 29 | @Description Creates an empty pixeltype. 30 | *************************************************************************/ 31 | PixelType(); 32 | 33 | /*!*********************************************************************** 34 | @Function PixelType 35 | @Input Type 36 | @Return A new PixelType 37 | @Description Initialises a new pixel type from a 64 bit integer value. 38 | *************************************************************************/ 39 | PixelType(uint64 Type); 40 | 41 | /*!*********************************************************************** 42 | @Function PixelType 43 | @Input C1Name 44 | @Input C2Name 45 | @Input C3Name 46 | @Input C4Name 47 | @Input C1Bits 48 | @Input C2Bits 49 | @Input C3Bits 50 | @Input C4Bits 51 | @Return A new PixelType 52 | @Description Takes up to 4 characters (CnName) and 4 values (CnBits) 53 | to create a new PixelType. Any unused channels should be set to 0. 54 | For example: PixelType('r','g','b',0,8,8,8,0); 55 | *************************************************************************/ 56 | PixelType(uint8 C1Name, uint8 C2Name, uint8 C3Name, uint8 C4Name, uint8 C1Bits, uint8 C2Bits, uint8 C3Bits, uint8 C4Bits); 57 | 58 | struct PVR_DLL LowHigh 59 | { 60 | uint32 Low; 61 | uint32 High; 62 | } Part; 63 | 64 | uint64 PixelTypeID; 65 | uint8 PixelTypeChar[8]; 66 | }; 67 | 68 | static const PixelType PVRStandard8PixelType = PixelType('r','g','b','a',8,8,8,8); 69 | static const PixelType PVRStandard16PixelType = PixelType('r','g','b','a',16,16,16,16); 70 | static const PixelType PVRStandard32PixelType = PixelType('r','g','b','a',32,32,32,32); 71 | } 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Include/PVRTextureHeader.h: -------------------------------------------------------------------------------- 1 | /*!*********************************************************************** 2 | 3 | @file PVRTextureHeader.h 4 | @copyright Copyright (c) Imagination Technologies Limited. 5 | @brief Texture header methods. 6 | @details Includes pixel and channel type methods, size retrieval and 7 | dimension manipulation. As well as set and get methods for 8 | BumpMaps, Meta Data and cube map order. 9 | 10 | *************************************************************************/ 11 | 12 | #ifndef _PVRTEXTURE_HEADER_H 13 | #define _PVRTEXTURE_HEADER_H 14 | 15 | #include "PVRTextureDefines.h" 16 | #include "PVRTextureFormat.h" 17 | #include "PVRTString.h" 18 | #include "PVRTMap.h" 19 | 20 | namespace pvrtexture 21 | { 22 | /*!*********************************************************************** 23 | @class CPVRTextureHeader 24 | @brief Wrapper class for PVRTextureHeaderV3, adds 'smart' accessor functions. 25 | *************************************************************************/ 26 | class PVR_DLL CPVRTextureHeader 27 | { 28 | protected: 29 | PVRTextureHeaderV3 m_sHeader; //!< Texture header as laid out in a file. 30 | CPVRTMap > m_MetaData; //!< Map of all the meta data stored for a texture. 31 | 32 | public: 33 | // Construction methods for a texture header. 34 | /*!*********************************************************************** 35 | @brief Default constructor for a CPVRTextureHeader. Returns an empty header. 36 | @return A new texture header. 37 | *************************************************************************/ 38 | CPVRTextureHeader(); 39 | 40 | /*!*********************************************************************** 41 | @brief Creates a new texture header from a PVRTextureHeaderV3, 42 | and appends Meta data if any is supplied. 43 | @param[in] fileHeader PVRTextureHeaderV3 44 | @param[in] metaDataCount Number of Meta data blocks to add 45 | @param[in] metaData Pointer to meta data block 46 | @return A new texture header. 47 | *************************************************************************/ 48 | CPVRTextureHeader( PVRTextureHeaderV3 fileHeader, 49 | uint32 metaDataCount=0, 50 | MetaDataBlock* metaData=NULL); 51 | 52 | /*!*********************************************************************** 53 | @brief Creates a new texture header based on individual header 54 | variables. 55 | @param[in] u64PixelFormat PixelFormat 56 | @param[in] u32Height Texture height 57 | @param[in] u32Width Texture width 58 | @param[in] u32Depth Texture depth 59 | @param[in] u32NumMipMaps Number of MIP Maps 60 | @param[in] u32NumArrayMembers Number of array members 61 | @param[in] u32NumFaces Number of faces 62 | @param[in] eColourSpace Colour space 63 | @param[in] eChannelType Channel type 64 | @param[in] bPreMultiplied Whether or not the texture's colour has been 65 | pre-multiplied by the alpha values 66 | @return A new texture header. 67 | *************************************************************************/ 68 | CPVRTextureHeader( uint64 u64PixelFormat, 69 | uint32 u32Height=1, 70 | uint32 u32Width=1, 71 | uint32 u32Depth=1, 72 | uint32 u32NumMipMaps=1, 73 | uint32 u32NumArrayMembers=1, 74 | uint32 u32NumFaces=1, 75 | EPVRTColourSpace eColourSpace=ePVRTCSpacelRGB, 76 | EPVRTVariableType eChannelType=ePVRTVarTypeUnsignedByteNorm, 77 | bool bPreMultiplied=false); 78 | 79 | /*!*********************************************************************** 80 | @brief Deconstructor for CPVRTextureHeader. 81 | *************************************************************************/ 82 | ~CPVRTextureHeader(); 83 | 84 | /*!*********************************************************************** 85 | @brief Will copy the contents and information of another header into this one. 86 | @param[in] rhs Header to copy. 87 | @return This header. 88 | *************************************************************************/ 89 | CPVRTextureHeader& operator=(const CPVRTextureHeader& rhs); 90 | 91 | // Accessor Methods for a texture's properties - getters. 92 | 93 | /*!*********************************************************************** 94 | @brief Gets the file header structure. 95 | @return The file header. 96 | *************************************************************************/ 97 | PVRTextureHeaderV3 getFileHeader() const; 98 | 99 | /*!*********************************************************************** 100 | @brief Gets the 64-bit pixel type ID of the texture. 101 | @return 64-bit pixel type ID. 102 | *************************************************************************/ 103 | PixelType getPixelType() const; 104 | 105 | /*!*********************************************************************** 106 | @brief Gets the bits per pixel of the texture format. 107 | @return Number of bits per pixel. 108 | *************************************************************************/ 109 | uint32 getBitsPerPixel() const; 110 | 111 | /*!*********************************************************************** 112 | @brief Returns the colour space of the texture. 113 | @return enum representing colour space. 114 | *************************************************************************/ 115 | EPVRTColourSpace getColourSpace() const; 116 | 117 | /*!*********************************************************************** 118 | @brief Returns the variable type that the texture's data is stored in. 119 | @return enum representing the type of the texture. 120 | *************************************************************************/ 121 | EPVRTVariableType getChannelType() const; 122 | 123 | /*!*********************************************************************** 124 | @brief Gets the width of the user specified MIP-Map 125 | level for the texture 126 | @param[in] uiMipLevel MIP level that user is interested in. 127 | @return Width of the specified MIP-Map level. 128 | *************************************************************************/ 129 | uint32 getWidth(uint32 uiMipLevel=PVRTEX_TOPMIPLEVEL) const; 130 | 131 | /*!*********************************************************************** 132 | @brief Gets the height of the user specified MIP-Map 133 | level for the texture 134 | @param[in] uiMipLevel MIP level that user is interested in. 135 | @return Height of the specified MIP-Map level. 136 | *************************************************************************/ 137 | uint32 getHeight(uint32 uiMipLevel=PVRTEX_TOPMIPLEVEL) const; 138 | 139 | /*!*********************************************************************** 140 | @brief Gets the depth of the user specified MIP-Map 141 | level for the texture 142 | @param[in] uiMipLevel MIP level that user is interested in. 143 | @return Depth of the specified MIP-Map level. 144 | *************************************************************************/ 145 | uint32 getDepth(uint32 uiMipLevel=PVRTEX_TOPMIPLEVEL) const; 146 | 147 | /*!*********************************************************************** 148 | @brief Gets the size in PIXELS of the texture, given various input 149 | parameters. User can retrieve the total size of either all 150 | surfaces or a single surface, all faces or a single face and 151 | all MIP-Maps or a single specified MIP level. All of these 152 | @param[in] iMipLevel Specifies a MIP level to check, 153 | 'PVRTEX_ALLMIPLEVELS' can be passed to get 154 | the size of all MIP levels. 155 | @param[in] bAllSurfaces Size of all surfaces is calculated if true, 156 | only a single surface if false. 157 | @param[in] bAllFaces Size of all faces is calculated if true, 158 | only a single face if false. 159 | @return Size in PIXELS of the specified texture area. 160 | *************************************************************************/ 161 | uint32 getTextureSize(int32 iMipLevel=PVRTEX_ALLMIPLEVELS, bool bAllSurfaces = true, bool bAllFaces = true) const; 162 | 163 | /*!*********************************************************************** 164 | @brief Gets the size in BYTES of the texture, given various input 165 | parameters. User can retrieve the size of either all 166 | surfaces or a single surface, all faces or a single face 167 | and all MIP-Maps or a single specified MIP level. 168 | @param[in] iMipLevel Specifies a mip level to check, 169 | 'PVRTEX_ALLMIPLEVELS' can be passed to get 170 | the size of all MIP levels. 171 | @param[in] bAllSurfaces Size of all surfaces is calculated if true, 172 | only a single surface if false. 173 | @param[in] bAllFaces Size of all faces is calculated if true, 174 | only a single face if false. 175 | @return Size in BYTES of the specified texture area. 176 | *************************************************************************/ 177 | uint32 getDataSize(int32 iMipLevel=PVRTEX_ALLMIPLEVELS, bool bAllSurfaces = true, bool bAllFaces = true) const; 178 | 179 | /*!*********************************************************************** 180 | @brief Gets the number of array members stored in this texture. 181 | @return Number of array members in this texture. 182 | *************************************************************************/ 183 | uint32 getNumArrayMembers() const; 184 | 185 | /*!*********************************************************************** 186 | @brief Gets the number of MIP-Map levels stored in this texture. 187 | @return Number of MIP-Map levels in this texture. 188 | *************************************************************************/ 189 | uint32 getNumMIPLevels() const; 190 | 191 | /*!*********************************************************************** 192 | @brief Gets the number of faces stored in this texture. 193 | @return Number of faces in this texture. 194 | *************************************************************************/ 195 | uint32 getNumFaces() const; 196 | 197 | /*!*********************************************************************** 198 | @brief Gets the data orientation for this texture. 199 | @param[in] axis EPVRTAxis type specifying the axis to examine. 200 | @return Enum orientation of the axis. 201 | *************************************************************************/ 202 | EPVRTOrientation getOrientation(EPVRTAxis axis) const; 203 | 204 | /*!*********************************************************************** 205 | @brief Returns whether or not the texture is compressed using 206 | PVRTexLib's FILE compression - this is independent of 207 | any texture compression. 208 | @return True if it is file compressed. 209 | *************************************************************************/ 210 | bool isFileCompressed() const; 211 | 212 | /*!*********************************************************************** 213 | @brief Returns whether or not the texture's colour has been 214 | pre-multiplied by the alpha values. 215 | @return True if texture is premultiplied. 216 | *************************************************************************/ 217 | bool isPreMultiplied() const; 218 | 219 | /*!*********************************************************************** 220 | @brief Returns the total size of the meta data stored in the header. 221 | This includes the size of all information stored in all MetaDataBlocks. 222 | @return Size, in bytes, of the meta data stored in the header. 223 | *************************************************************************/ 224 | uint32 getMetaDataSize() const; 225 | 226 | /*!*********************************************************************** 227 | @brief Gets the OpenGL equivalent values of internal format, format 228 | and type for this texture. This will return any supported 229 | OpenGL texture values, it is up to the user to decide if 230 | these are valid for their current platform. 231 | @param[in,out] internalformat Internal format 232 | @param[in,out] format Format 233 | @param[in,out] type Type 234 | *************************************************************************/ 235 | void getOGLFormat(uint32& internalformat, uint32& format, uint32& type) const; 236 | 237 | /*!*********************************************************************** 238 | @brief Gets the OpenGLES equivalent values of internal format, 239 | format and type for this texture. This will return any 240 | supported OpenGLES texture values, it is up to the user 241 | to decide if these are valid for their current platform. 242 | @param[in,out] internalformat Internal format 243 | @param[in,out] format Format 244 | @param[in,out] type Type 245 | *************************************************************************/ 246 | void getOGLESFormat(uint32& internalformat, uint32& format, uint32& type) const; 247 | 248 | /*!*********************************************************************** 249 | @brief Gets the D3DFormat (up to DirectX 9 and Direct 3D Mobile) 250 | equivalent values for this texture. This will return any 251 | supported D3D texture formats, it is up to the user to 252 | decide if this is valid for their current platform. 253 | @return D3D format, represented by an uint32. 254 | *************************************************************************/ 255 | uint32 getD3DFormat() const; 256 | 257 | /*!*********************************************************************** 258 | @brief Gets the DXGIFormat (DirectX 10 onward) equivalent values 259 | for this texture. This will return any supported DX texture 260 | formats, it is up to the user to decide if this is valid 261 | for their current platform. 262 | @return GXGIFormat, represented by a uint32. 263 | *************************************************************************/ 264 | uint32 getDXGIFormat() const; 265 | 266 | // Accessor Methods for a texture's properties - setters. 267 | 268 | /*!*********************************************************************** 269 | @brief Sets the pixel format for this texture. 270 | @param[in] uPixelFormat The format of the pixel. 271 | *************************************************************************/ 272 | void setPixelFormat(PixelType uPixelFormat); 273 | 274 | /*!*********************************************************************** 275 | @brief Sets the colour space for this texture. Default is lRGB. 276 | @param[in] eColourSpace A colour space enum. 277 | *************************************************************************/ 278 | void setColourSpace(EPVRTColourSpace eColourSpace); 279 | 280 | /*!*********************************************************************** 281 | @brief Sets the variable type for the channels in this texture. 282 | @param[in] eVarType A variable type enum. 283 | *************************************************************************/ 284 | void setChannelType(EPVRTVariableType eVarType); 285 | 286 | /*!*********************************************************************** 287 | @brief Sets the format of the texture to PVRTexLib's internal 288 | representation of the OGL format. 289 | @param[in,out] internalformat Internal format 290 | @param[in,out] format Format 291 | @param[in,out] type Type 292 | @return True if successful. 293 | *************************************************************************/ 294 | bool setOGLFormat(const uint32& internalformat, const uint32& format, const uint32& type); 295 | 296 | /*!*********************************************************************** 297 | @brief Sets the format of the texture to PVRTexLib's internal 298 | representation of the OGLES format. 299 | @param[in,out] internalformat Internal format 300 | @param[in,out] format Format 301 | @param[in,out] type Type 302 | @return True if successful. 303 | *************************************************************************/ 304 | bool setOGLESFormat(const uint32& internalformat, const uint32& format, const uint32& type); 305 | 306 | /*!*********************************************************************** 307 | @brief Sets the format of the texture to PVRTexLib's internal 308 | representation of the D3D format. 309 | @return True if successful. 310 | *************************************************************************/ 311 | bool setD3DFormat(const uint32& DWORD_D3D_FORMAT); 312 | 313 | /*!*********************************************************************** 314 | @brief Sets the format of the texture to PVRTexLib's internal 315 | representation of the DXGI format. 316 | @return True if successful. 317 | *************************************************************************/ 318 | bool setDXGIFormat(const uint32& DWORD_DXGI_FORMAT); 319 | 320 | /*!*********************************************************************** 321 | @brief Sets the width. 322 | @param[in] newWidth The new width. 323 | *************************************************************************/ 324 | void setWidth(uint32 newWidth); 325 | 326 | /*!*********************************************************************** 327 | @brief Sets the height. 328 | @param[in] newHeight The new height. 329 | *************************************************************************/ 330 | void setHeight(uint32 newHeight); 331 | 332 | /*!*********************************************************************** 333 | @brief Sets the depth. 334 | @param[in] newDepth The new depth. 335 | *************************************************************************/ 336 | void setDepth(uint32 newDepth); 337 | 338 | /*!*********************************************************************** 339 | @brief Sets the depth. 340 | @param[in] newNumMembers The new number of members in this array. 341 | *************************************************************************/ 342 | void setNumArrayMembers(uint32 newNumMembers); 343 | 344 | /*!*********************************************************************** 345 | @brief Sets the number of MIP-Map levels in this texture. 346 | @param[in] newNumMIPLevels New number of MIP-Map levels. 347 | *************************************************************************/ 348 | void setNumMIPLevels(uint32 newNumMIPLevels); 349 | 350 | /*!*********************************************************************** 351 | @brief Sets the number of faces stored in this texture. 352 | @param[in] newNumFaces New number of faces for this texture. 353 | *************************************************************************/ 354 | void setNumFaces(uint32 newNumFaces); 355 | 356 | /*!*********************************************************************** 357 | @brief Sets the data orientation for a given axis in this texture. 358 | @param[in] eAxisOrientation Enum specifying axis and orientation. 359 | *************************************************************************/ 360 | void setOrientation(EPVRTOrientation eAxisOrientation); 361 | 362 | /*!*********************************************************************** 363 | @brief Sets whether or not the texture is compressed using 364 | PVRTexLib's FILE compression - this is independent of 365 | any texture compression. Currently unsupported. 366 | @param[in] isFileCompressed Sets file compression to true/false. 367 | *************************************************************************/ 368 | void setIsFileCompressed(bool isFileCompressed); 369 | 370 | /*!*********************************************************************** 371 | @brief Sets whether or not the texture's colour has been 372 | pre-multiplied by the alpha values. 373 | @return isPreMultiplied Sets if texture is premultiplied. 374 | *************************************************************************/ 375 | void setIsPreMultiplied(bool isPreMultiplied); 376 | 377 | // Meta Data functions - Getters. 378 | 379 | /*!*********************************************************************** 380 | @brief Returns whether the texture is a bump map or not. 381 | @return True if the texture is a bump map. 382 | *************************************************************************/ 383 | bool isBumpMap() const; 384 | 385 | /*!*********************************************************************** 386 | @brief Gets the bump map scaling value for this texture. 387 | @details If the texture is not a bump map, 0.0f is returned. If the 388 | texture is a bump map but no meta data is stored to 389 | specify its scale, then 1.0f is returned. 390 | @return Returns the bump map scale value as a float. 391 | *************************************************************************/ 392 | float getBumpMapScale() const; 393 | 394 | /*!*********************************************************************** 395 | @brief Gets the bump map channel order relative to rgba. 396 | @details For example, an RGB texture with bumps mapped to XYZ returns 397 | 'xyz'. A BGR texture with bumps in the order ZYX will also 398 | return 'xyz' as the mapping is the same: R=X, G=Y, B=Z. 399 | If the letter 'h' is present in the string, it means that 400 | the height map has been stored here. 401 | Other characters are possible if the bump map was created 402 | manually, but PVRTexLib will ignore these characters. They 403 | are returned simply for completeness. 404 | @return Bump map order relative to rgba. 405 | *************************************************************************/ 406 | CPVRTString getBumpMapOrder() const; 407 | 408 | /*!*********************************************************************** 409 | @brief Works out the number of possible texture atlas members in 410 | the texture based on the w/h/d and the data size. 411 | @return The number of sub textures defined by meta data. 412 | *************************************************************************/ 413 | int getNumTextureAtlasMembers() const; 414 | 415 | /*!*********************************************************************** 416 | @brief Returns a pointer to the texture atlas data. 417 | @return A pointer directly to the texture atlas data. 418 | *************************************************************************/ 419 | const float* getTextureAtlasData() const; 420 | 421 | /*!*********************************************************************** 422 | @brief Gets the cube map face order. 423 | @details Returned string will be in the form "ZzXxYy" with capitals 424 | representing positive and small letters representing 425 | negative. I.e. Z=Z-Positive, z=Z-Negative. 426 | @return Cube map order string. 427 | *************************************************************************/ 428 | CPVRTString getCubeMapOrder() const; 429 | 430 | /*!*********************************************************************** 431 | @brief Obtains the border size in each dimension for this texture. 432 | @param[in] uiBorderWidth Border width 433 | @param[in] uiBorderHeight Border height 434 | @param[in] uiBorderDepth Border depth 435 | *************************************************************************/ 436 | void getBorder(uint32& uiBorderWidth, uint32& uiBorderHeight, uint32& uiBorderDepth) const; 437 | 438 | /*!*********************************************************************** 439 | @brief Returns a block of meta data from the texture. If the meta 440 | data doesn't exist, a block with data size 0 will be returned. 441 | @param[in] DevFOURCC Four character descriptor representing the 442 | creator of the meta data 443 | @param[in] u32Key Key value representing the type of meta 444 | data stored 445 | @return A copy of the meta data from the texture. 446 | *************************************************************************/ 447 | MetaDataBlock getMetaData(uint32 DevFOURCC, uint32 u32Key) const; 448 | 449 | /*!*********************************************************************** 450 | @brief Returns whether or not the specified meta data exists as 451 | part of this texture header. 452 | @param[in] DevFOURCC Four character descriptor representing the 453 | creator of the meta data 454 | @param[in] u32Key Key value representing the type of meta 455 | data stored 456 | @return True if the specified meta data bock exists 457 | *************************************************************************/ 458 | bool hasMetaData(uint32 DevFOURCC, uint32 u32Key) const; 459 | 460 | /*!*********************************************************************** 461 | @brief A pointer directly to the Meta Data Map, to allow users to read out data. 462 | @return A direct pointer to the MetaData map. 463 | *************************************************************************/ 464 | const MetaDataMap* getMetaDataMap() const; 465 | 466 | // Meta Data functions - Setters. 467 | 468 | /*!*********************************************************************** 469 | @brief Sets a texture's bump map data. 470 | @param[in] bumpScale Floating point "height" value to scale the bump map. 471 | @param[in] bumpOrder Up to 4 character string, with values x,y,z,h in 472 | some combination. Not all values need to be present. 473 | Denotes channel order; x,y,z refer to the 474 | corresponding axes, h indicates presence of the 475 | original height map. It is possible to have only some 476 | of these values rather than all. For example if 'h' 477 | is present alone it will be considered a height map. 478 | The values should be presented in RGBA order, regardless 479 | of the texture format, so a zyxh order in a bgra texture 480 | should still be passed as 'xyzh'. Capitals are allowed. 481 | Any character stored here that is not one of x,y,z,h 482 | or a NULL character will be ignored when PVRTexLib 483 | reads the data, but will be preserved. This is useful 484 | if you wish to define a custom data channel for instance. 485 | In these instances PVRTexLib will assume it is simply 486 | colour data. 487 | *************************************************************************/ 488 | void setBumpMap(float bumpScale, CPVRTString bumpOrder="xyz"); 489 | 490 | /*!*********************************************************************** 491 | @brief Sets the texture atlas coordinate meta data for later display. 492 | It is up to the user to make sure that this texture atlas 493 | data actually makes sense in the context of the header. It is 494 | suggested that the "generateTextureAtlas" method in the tools 495 | is used to create a texture atlas, manually setting one up is 496 | possible but should be done with care. 497 | @param[in] pAtlasData Pointer to an array of atlas data. 498 | @param[in] dataSize Number of floats that the data pointer contains. 499 | *************************************************************************/ 500 | void setTextureAtlas(float* pAtlasData, uint32 dataSize); 501 | 502 | /*!*********************************************************************** 503 | @brief Sets a texture's bump map data. 504 | @param[in] cubeMapOrder Up to 6 character string, with values 505 | x,X,y,Y,z,Z in some combination. Not all 506 | values need to be present. Denotes face 507 | order; Capitals refer to positive axis 508 | positions and small letters refer to 509 | negative axis positions. E.g. x=X-Negative, 510 | X=X-Positive. It is possible to have only 511 | some of these values rather than all, as 512 | long as they are NULL terminated. 513 | NB: Values past the 6th character are not read. 514 | *************************************************************************/ 515 | void setCubeMapOrder(CPVRTString cubeMapOrder="XxYyZz"); 516 | 517 | /*!*********************************************************************** 518 | @brief Sets a texture's border size data. This value is subtracted 519 | from the current texture height/width/depth to get the valid 520 | texture data. 521 | @param[in] uiBorderWidth Border width 522 | @param[in] uiBorderHeight Border height 523 | @param[in] uiBorderDepth Border depth 524 | *************************************************************************/ 525 | void setBorder(uint32 uiBorderWidth, uint32 uiBorderHeight, uint32 uiBorderDepth); 526 | 527 | /*!*********************************************************************** 528 | @brief Adds an arbitrary piece of meta data. 529 | @param[in] MetaBlock Meta data block to be added. 530 | *************************************************************************/ 531 | void addMetaData(const MetaDataBlock& MetaBlock); 532 | 533 | /*!*********************************************************************** 534 | @brief Removes a specified piece of meta data, if it exists. 535 | @param[in] DevFOURCC Four character descriptor representing the 536 | creator of the meta data 537 | @param[in] u32Key Key value representing the type of meta 538 | data stored 539 | *************************************************************************/ 540 | void removeMetaData(const uint32& DevFOURCC, const uint32& u32Key); 541 | }; 542 | }; 543 | 544 | #endif 545 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Include/PVRTextureUtilities.h: -------------------------------------------------------------------------------- 1 | /*!*********************************************************************** 2 | 3 | @file PVRTextureUtilities.h 4 | @copyright Copyright (c) Imagination Technologies Limited. 5 | @brief This is the main PVRTexLib header file. This header contains 6 | a utility function for transcoding textures, as well as 7 | pre-processor utilities such as; resizing, rotating, channel 8 | copying and MIPMap manipulation. 9 | 10 | *************************************************************************/ 11 | 12 | #ifndef _PVRTEXTURE_UTILITIES_H 13 | #define _PVRTEXTURE_UTILITIES_H 14 | 15 | #include "PVRTextureFormat.h" 16 | #include "PVRTexture.h" 17 | 18 | namespace pvrtexture 19 | { 20 | /*!*********************************************************************** 21 | @brief Resizes the texture to new specified dimensions. Filtering 22 | mode is specified with "eResizeMode". 23 | @param[in] sTexture Texture to resize 24 | @param[in] u32NewWidth New width 25 | @param[in] u32NewHeight New height 26 | @param[in] u32NewDepth New depth 27 | @param[in] eResizeMode Filtering mode 28 | @return True if the method succeeds. 29 | *************************************************************************/ 30 | bool PVR_DLL Resize(CPVRTexture& sTexture, const uint32& u32NewWidth, const uint32& u32NewHeight, const uint32& u32NewDepth, const EResizeMode eResizeMode); 31 | 32 | /*!*********************************************************************** 33 | @brief Resizes the canvas of a texture to new specified dimensions. Filtering 34 | mode is specified with "eResizeMode". 35 | @details Offset area is filled with transparent black colour. 36 | @param[in] sTexture Texture 37 | @param[in] u32NewWidth New width 38 | @param[in] u32NewHeight New height 39 | @param[in] u32NewDepth New depth 40 | @param[in] i32XOffset X Offset value from the top left corner 41 | @param[in] i32YOffset Y Offset value from the top left corner 42 | @param[in] i32ZOffset Z Offset value from the top left corner 43 | @return True if the method succeeds. 44 | *************************************************************************/ 45 | bool PVR_DLL ResizeCanvas(CPVRTexture& sTexture, const uint32& u32NewWidth, const uint32& u32NewHeight, const uint32& u32NewDepth, const int32& i32XOffset, const int32& i32YOffset, const int32& i32ZOffset); 46 | 47 | /*!*********************************************************************** 48 | @brief Rotates a texture by 90 degrees around the given axis. bForward controls direction of rotation. 49 | @param[in] sTexture Texture to rotate 50 | @param[in] eRotationAxis Rotation axis 51 | @param[in] bForward Direction of rotation; 1 = clockwise, 0 = anti-clockwise 52 | @return True if the method succeeds or not. 53 | *************************************************************************/ 54 | bool PVR_DLL Rotate90(CPVRTexture& sTexture, const EPVRTAxis eRotationAxis, const bool bForward); 55 | 56 | /*!*********************************************************************** 57 | @brief Flips a texture in a given direction. 58 | @param[in] sTexture Texture to flip 59 | @param[in] eFlipDirection Flip direction 60 | @return True if the method succeeds. 61 | *************************************************************************/ 62 | bool PVR_DLL Flip(CPVRTexture& sTexture, const EPVRTAxis eFlipDirection); 63 | 64 | /*!*********************************************************************** 65 | @brief Adds a user specified border to the texture. 66 | @param[in] sTexture Texture 67 | @param[in] uiBorderX X border 68 | @param[in] uiBorderY Y border 69 | @param[in] uiBorderZ Z border 70 | @return True if the method succeeds. 71 | *************************************************************************/ 72 | bool PVR_DLL Border(CPVRTexture& sTexture, uint32 uiBorderX, uint32 uiBorderY, uint32 uiBorderZ); 73 | 74 | /*!*********************************************************************** 75 | @brief Pre-multiplies a texture's colours by its alpha values. 76 | @param[in] sTexture Texture to premultiply 77 | @return True if the method succeeds. 78 | *************************************************************************/ 79 | bool PVR_DLL PreMultiplyAlpha(CPVRTexture& sTexture); 80 | 81 | /*!*********************************************************************** 82 | @brief Allows a texture's colours to run into any fully transparent areas. 83 | @param[in] sTexture Texture 84 | @return True if the method succeeds. 85 | *************************************************************************/ 86 | bool PVR_DLL Bleed(CPVRTexture& sTexture); 87 | 88 | /*!*********************************************************************** 89 | @brief Sets the specified number of channels to values specified in pValues. 90 | @param[in] sTexture Texture 91 | @param[in] uiNumChannelSets Number of channels to set 92 | @param[in] eChannels Channels to set 93 | @param[in] pValues uint32 values to set channels to 94 | @return True if the method succeeds. 95 | *************************************************************************/ 96 | bool PVR_DLL SetChannels(CPVRTexture& sTexture, uint32 uiNumChannelSets, EChannelName *eChannels, uint32 *pValues); 97 | 98 | /*!*********************************************************************** 99 | @brief Sets the specified number of channels to values specified in float pValues. 100 | @param[in] sTexture Texture 101 | @param[in] uiNumChannelSets Number of channels to set 102 | @param[in] eChannels Channels to set 103 | @param[in] pValues float values to set channels to 104 | @return True if the method succeeds. 105 | *************************************************************************/ 106 | bool PVR_DLL SetChannelsFloat(CPVRTexture& sTexture, uint32 uiNumChannelSets, EChannelName *eChannels, float *pValues); 107 | 108 | /*!*********************************************************************** 109 | @brief Copies the specified channels from sTextureSource into sTexture. 110 | @details sTextureSource is not modified so it is possible to use the 111 | same texture as both input and output. When using the same 112 | texture as source and destination, channels are preserved 113 | between swaps (e.g. copying Red to Green and then Green to Red 114 | will result in the two channels trading places correctly). 115 | Channels in eChannels are set to the value of the channels 116 | in eChannelSource. 117 | @param[in] sTexture Destination texture to copy channels to 118 | @param[in] sTextureSource Source texture to copy channels from 119 | @param[in] uiNumChannelCopies Number of channels to copy 120 | @param[in] eChannels Channels to set 121 | @param[in] eChannelsSource Source channels to copy from 122 | @return True if the method succeeds. 123 | *************************************************************************/ 124 | bool PVR_DLL CopyChannels(CPVRTexture& sTexture, const CPVRTexture& sTextureSource, uint32 uiNumChannelCopies, EChannelName *eChannels, EChannelName *eChannelsSource); 125 | 126 | /*!*********************************************************************** 127 | @brief Generates a Normal Map from a given height map. 128 | @details Assumes the red channel has the height values. 129 | By default outputs to red/green/blue = x/y/z, 130 | this can be overridden by specifying a channel 131 | order in sChannelOrder. The channels specified 132 | will output to red/green/blue/alpha in that order. 133 | So "xyzh" maps x to red, y to green, z to blue 134 | and h to alpha. 'h' is used to specify that the 135 | original height map data should be preserved in 136 | the given channel. 137 | @param[in] sTexture Texture 138 | @param[in] fScale Scale factor 139 | @param[in] sChannelOrder Channel order 140 | @return True if the method succeeds. 141 | *************************************************************************/ 142 | bool PVR_DLL GenerateNormalMap(CPVRTexture& sTexture, const float fScale, CPVRTString sChannelOrder); 143 | 144 | /*!*********************************************************************** 145 | @brief Generates MIPMaps for a source texture. Default is to 146 | create a complete MIPMap chain, however this can be 147 | overridden with uiMIPMapsToDo. 148 | @param[in] sTexture Texture 149 | @param[in] eFilterMode Filter mode 150 | @param[in] uiMIPMapsToDo Level of MIPMap chain to create 151 | @return True if the method succeeds. 152 | *************************************************************************/ 153 | bool PVR_DLL GenerateMIPMaps(CPVRTexture& sTexture, const EResizeMode eFilterMode, const uint32 uiMIPMapsToDo=PVRTEX_ALLMIPLEVELS); 154 | 155 | /*!*********************************************************************** 156 | @brief Colours a texture's MIPMap levels with artificial colours 157 | for debugging. MIP levels are coloured in the following order: 158 | Red, Green, Blue, Cyan, Magenta and Yellow 159 | in a repeating pattern. 160 | @param[in] sTexture Texture 161 | @return True if the method succeeds. 162 | *************************************************************************/ 163 | bool PVR_DLL ColourMIPMaps(CPVRTexture& sTexture); 164 | 165 | /*!*********************************************************************** 166 | @brief Transcodes a texture from its original format into a newly specified format. 167 | Will either quantise or dither to lower precisions based on bDoDither. 168 | uiQuality specifies the quality for PVRTC and ETC compression. 169 | @param[in] sTexture Texture 170 | @param[in] ptFormat Pixel format type 171 | @param[in] eChannelType Channel type 172 | @param[in] eColourspace Colour space 173 | @param[in] eQuality Quality for PVRTC and ETC compression 174 | @param[in] bDoDither Dither the texture to lower precisions 175 | @return True if the method succeeds. 176 | *************************************************************************/ 177 | bool PVR_DLL Transcode(CPVRTexture& sTexture, const PixelType ptFormat, const EPVRTVariableType eChannelType, const EPVRTColourSpace eColourspace, const ECompressorQuality eQuality=ePVRTCNormal, const bool bDoDither=false); 178 | }; 179 | #endif //_PVRTEXTURE_UTILTIES_H 180 | 181 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Include/PVRTextureVersion.h: -------------------------------------------------------------------------------- 1 | #ifndef PVRTEXLIBVERSION_H 2 | #define PVRTEXLIBVERSION_H 3 | #define PVRTLMAJORVERSION 4 4 | #define PVRTLMINORVERSION 17 5 | #define PVRTLSUBVERSION 0 6 | #define PVRTLSTRINGVERSION "4.17.0" 7 | #endif 8 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Linux_x86_32/libPVRTexLib.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infiniteflight/PVRTexLibNET/adf43979a44029cad24f0d6888337c41dee9458a/PVRTexLibWrapper/PVRTexTool/Library/Linux_x86_32/libPVRTexLib.so -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Linux_x86_64/libPVRTexLib.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infiniteflight/PVRTexLibNET/adf43979a44029cad24f0d6888337c41dee9458a/PVRTexLibWrapper/PVRTexTool/Library/Linux_x86_64/libPVRTexLib.so -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/OSX_x86/libPVRTexLib.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infiniteflight/PVRTexLibNET/adf43979a44029cad24f0d6888337c41dee9458a/PVRTexLibWrapper/PVRTexTool/Library/OSX_x86/libPVRTexLib.dylib -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Windows_x86_32/PVRTexLib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infiniteflight/PVRTexLibNET/adf43979a44029cad24f0d6888337c41dee9458a/PVRTexLibWrapper/PVRTexTool/Library/Windows_x86_32/PVRTexLib.dll -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Windows_x86_32/PVRTexLib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infiniteflight/PVRTexLibNET/adf43979a44029cad24f0d6888337c41dee9458a/PVRTexLibWrapper/PVRTexTool/Library/Windows_x86_32/PVRTexLib.lib -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Windows_x86_64/PVRTexLib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infiniteflight/PVRTexLibNET/adf43979a44029cad24f0d6888337c41dee9458a/PVRTexLibWrapper/PVRTexTool/Library/Windows_x86_64/PVRTexLib.dll -------------------------------------------------------------------------------- /PVRTexLibWrapper/PVRTexTool/Library/Windows_x86_64/PVRTexLib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infiniteflight/PVRTexLibNET/adf43979a44029cad24f0d6888337c41dee9458a/PVRTexLibWrapper/PVRTexTool/Library/Windows_x86_64/PVRTexLib.lib -------------------------------------------------------------------------------- /PVRTexLibWrapper/Stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // PVRTexLibC.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/Stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, 3 | // but are changed infrequently 4 | 5 | #pragma once 6 | 7 | 8 | -------------------------------------------------------------------------------- /PVRTexLibWrapper/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by app.rc 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PVRTexLibNET [![Build status](https://ci.appveyor.com/api/projects/status/f42ue1h35bv93vbs?svg=true)](https://ci.appveyor.com/project/prollin/pvrtexlibnet) 2 | Simple C# wrapper around PVRTexLib from Imagination Technologies 3 | 4 | 5 | 6 | 7 | --------------------------------------------------------------------------------