Class PieUtils
- Namespace
- Pie
- Assembly
- Pie.dll
Various handy utilities you may use when developing with Pie.
public static class PieUtils
- Inheritance
-
PieUtils
- Inherited Members
Methods
Assert(bool, string)
Assert even in release mode.
public static void Assert(bool condition, string message)
Parameters
Exceptions
- PieException
Thrown if the assertion fails.
BitsPerPixel(Format)
Gets the bits per pixel of the given format. (For example, R8G8B8A8_UNorm would be 32-bits).
public static int BitsPerPixel(this Format format)
Parameters
formatFormat
Returns
Exceptions
CalculateMipLevels(int, int, int)
Calculate the total number of mipmap levels (including the most detailed mip) from the given width, height, and depth.
public static int CalculateMipLevels(int width, int height, int depth)
Parameters
widthintThe width of the texture.
heightintThe height of the texture.
depthintThe depth of the texture.
Returns
- int
The number of mip levels.
Remarks
For the result to be accurate, you should use the width and height of the most detailed mip level.
Combine<T>(params T[][])
Combine multiple textures into one array. Pie texture functions only support a single byte array, however certain texture types (array textures, cubemaps) require you to have multiple of these byte arrays. This function performs a fast block copy of the arrays into a single array.
public static T[] Combine<T>(params T[][] data) where T : unmanaged
Parameters
dataT[][]The data arrays to combine.
Returns
- T[]
The combined data.
Type Parameters
TThe data type.
CopyToUnmanaged<T>(nint, int, uint, T)
Copy the given data to a section in unmanaged memory (useful for copying data to a mapped buffer in a safe context.)
public static void CopyToUnmanaged<T>(nint unmanagedPtr, int offsetInBytes, uint sizeInBytes, T data) where T : unmanaged
Parameters
unmanagedPtrnintThe pointer to unmanaged memory.
offsetInBytesintThe offset in bytes.
sizeInBytesuintThe size of the data in bytes.
dataTThe data itself.
Type Parameters
TAny unmanaged type.
CopyToUnmanaged<T>(nint, int, uint, T[])
Copy the given data to a section in unmanaged memory (useful for copying data to a mapped buffer in a safe context.)
public static void CopyToUnmanaged<T>(nint unmanagedPtr, int offsetInBytes, uint dataLengthInBytes, T[] data) where T : unmanaged
Parameters
unmanagedPtrnintThe pointer to unmanaged memory.
offsetInBytesintThe offset in bytes.
dataLengthInBytesuintThe data length in bytes.
dataT[]The data itself.
Type Parameters
TAny unmanaged type.
CopyToUnmanaged<T>(nint, int, T)
Copy the given data to a section in unmanaged memory (useful for copying data to a mapped buffer in a safe context.)
public static void CopyToUnmanaged<T>(nint unmanagedPtr, int offsetInBytes, T data) where T : unmanaged
Parameters
unmanagedPtrnintThe pointer to unmanaged memory.
offsetInBytesintThe offset in bytes.
dataTThe data itself.
Type Parameters
TAny unmanaged type.
CopyToUnmanaged<T>(nint, int, T[])
Copy the given data to a section in unmanaged memory (useful for copying data to a mapped buffer in a safe context.)
public static void CopyToUnmanaged<T>(nint unmanagedPtr, int offsetInBytes, T[] data) where T : unmanaged
Parameters
unmanagedPtrnintThe pointer to unmanaged memory.
offsetInBytesintThe offset in bytes.
dataT[]The data itself.
Type Parameters
TAny unmanaged type.
Normalize(Color)
Normalize a Color for use in a shader.
public static Vector4 Normalize(this Color color)
Parameters
colorColorThe color to normalize.
Returns
- Vector4
The normalized color.