using System;
using System.Runtime.CompilerServices;
namespace BansheeEngine
{
///
/// Base class for all textures. Contains a set of pixels of certain dimensions that can be used for rendering
/// or read/written directly.
///
public class Texture : Resource
{
///
/// Returns the pixel format for the texture surface.
///
public PixelFormat PixelFormat
{
get
{
PixelFormat value;
Internal_GetPixelFormat(mCachedPtr, out value);
return value;
}
}
///
/// Returns a value that signals the engine in what way is the texture expected to be used.
///
public TextureUsage Usage
{
get
{
TextureUsage value;
Internal_GetUsage(mCachedPtr, out value);
return value;
}
}
///
/// Width of the texture in pixels.
///
public int Width
{
get
{
int value;
Internal_GetWidth(mCachedPtr, out value);
return value;
}
}
///
/// Height of the texture in pixels.
///
public int Height
{
get
{
int value;
Internal_GetHeight(mCachedPtr, out value);
return value;
}
}
///
/// Determines does the texture contain gamma corrected data. If true then the GPU will automatically convert
/// the pixels to linear space before reading from the texture, and convert them to gamma space when writing
/// to the texture.
///
public bool GammaCorrection
{
get
{
bool value;
Internal_GetGammaCorrection(mCachedPtr, out value);
return value;
}
}
///
/// Number of samples per pixel. Zero or one mean no multisampling will be used.
///
public int SampleCount
{
get
{
int value;
Internal_GetSampleCount(mCachedPtr, out value);
return value;
}
}
///
/// Returns how many mipmap levels does the texture contain.
///
public int MipmapCount
{
get
{
int value;
Internal_GetMipmapCount(mCachedPtr, out value);
return value;
}
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_GetPixelFormat(IntPtr thisPtr, out PixelFormat value);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_GetUsage(IntPtr thisPtr, out TextureUsage value);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_GetWidth(IntPtr thisPtr, out int value);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_GetHeight(IntPtr thisPtr, out int value);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_GetGammaCorrection(IntPtr thisPtr, out bool value);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_GetSampleCount(IntPtr thisPtr, out int value);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_GetMipmapCount(IntPtr thisPtr, out int value);
}
///
/// Flags that describe how is a texture used.
///
public enum TextureUsage // Note: Must match C++ enum TextureUsage
{
///
/// A regular texture that is not often or ever updated from the CPU.
///
Default = 0x1,
///
/// A regular texture that is often updated by the CPU.
///
Dynamic = 0x2,
///
/// Texture that can be rendered to by the GPU.
///
Render = 0x200,
///
/// Texture used as a depth/stencil buffer by the GPU.
///
DepthStencil = 0x400,
///
/// Texture that allows load/store operations from the GPU program.
///
LoadStore = 0x800,
///
/// Ensures all texture data will also be cached in system memory so it can be read by the CPU.
///
CPUCached = 0x1000
}
}