Texture.generated.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using System.Runtime.InteropServices;
  4. namespace BansheeEngine
  5. {
  6. /** @addtogroup Rendering
  7. * @{
  8. */
  9. /// <summary>
  10. /// Abstract class representing a texture. Specific render systems have their own Texture implementations. Internally
  11. /// represented as one or more surfaces with pixels in a certain number of dimensions, backed by a hardware buffer.
  12. /// </summary>
  13. [ShowInInspector]
  14. public partial class Texture : Resource
  15. {
  16. private Texture(bool __dummy0) { }
  17. protected Texture() { }
  18. private Texture(PixelFormat format, uint width, uint height, uint depth, TextureType texType, TextureUsage usage, uint numSamples, bool hasMipmaps, bool gammaCorrection)
  19. {
  20. Internal_create(this, format, width, height, depth, texType, usage, numSamples, hasMipmaps, gammaCorrection);
  21. }
  22. /// <summary>Returns a reference wrapper for this resource.</summary>
  23. public RRef<Texture> Ref
  24. {
  25. get { return Internal_GetRef(mCachedPtr); }
  26. }
  27. /// <summary>Returns the pixel format for the texture surface.</summary>
  28. [ShowInInspector]
  29. [NativeWrapper]
  30. public PixelFormat PixelFormat
  31. {
  32. get { return Internal_getPixelFormat(mCachedPtr); }
  33. }
  34. /// <summary>Returns a value that signals the engine in what way is the texture expected to be used.</summary>
  35. [ShowInInspector]
  36. [NativeWrapper]
  37. public TextureUsage Usage
  38. {
  39. get { return Internal_getUsage(mCachedPtr); }
  40. }
  41. /// <summary>Gets the type of texture.</summary>
  42. [ShowInInspector]
  43. [NativeWrapper]
  44. public TextureType Type
  45. {
  46. get { return Internal_getType(mCachedPtr); }
  47. }
  48. /// <summary>Returns the width of the texture.</summary>
  49. [ShowInInspector]
  50. [NativeWrapper]
  51. public uint Width
  52. {
  53. get { return Internal_getWidth(mCachedPtr); }
  54. }
  55. /// <summary>Returns the height of the texture.</summary>
  56. [ShowInInspector]
  57. [NativeWrapper]
  58. public uint Height
  59. {
  60. get { return Internal_getHeight(mCachedPtr); }
  61. }
  62. /// <summary>Returns the depth of the texture (only applicable for 3D textures).</summary>
  63. [ShowInInspector]
  64. [NativeWrapper]
  65. public uint Depth
  66. {
  67. get { return Internal_getDepth(mCachedPtr); }
  68. }
  69. /// <summary>
  70. /// Determines does the texture contain gamma corrected data. If true then the GPU will automatically convert the pixels
  71. /// to linear space before reading from the texture, and convert them to gamma space when writing to the texture.
  72. /// </summary>
  73. [ShowInInspector]
  74. [NativeWrapper]
  75. public bool GammaSpace
  76. {
  77. get { return Internal_getGammaCorrection(mCachedPtr); }
  78. }
  79. /// <summary>Gets the number of samples used for multisampling (0 or 1 if multisampling is not used).</summary>
  80. [ShowInInspector]
  81. [NativeWrapper]
  82. public uint SampleCount
  83. {
  84. get { return Internal_getSampleCount(mCachedPtr); }
  85. }
  86. /// <summary>
  87. /// Gets the number of mipmaps to be used for this texture. This number excludes the top level map (which is always
  88. /// assumed to be present).
  89. /// </summary>
  90. [ShowInInspector]
  91. [NativeWrapper]
  92. public uint MipMapCount
  93. {
  94. get { return Internal_getMipmapCount(mCachedPtr); }
  95. }
  96. /// <summary>Returns a reference wrapper for this resource.</summary>
  97. public static implicit operator RRef<Texture>(Texture x)
  98. { return Internal_GetRef(x.mCachedPtr); }
  99. /// <summary>
  100. /// Returns pixels for the specified mip level & face. Pixels will be read from system memory, which means the texture
  101. /// has to be created with TextureUsage.CPUCached. If the texture was updated from the GPU the pixels retrieved from this
  102. /// method will not reflect that, and you should use GetGPUPixels instead.
  103. /// </summary>
  104. /// <param name="mipLevel">Mip level to retrieve pixels for. Top level (0) is the highest quality.</param>
  105. /// <param name="face">
  106. /// Face to read the pixels from. Cubemap textures have six faces whose face indices are as specified in the CubeFace
  107. /// enum. Array textures can have an arbitrary number of faces (if it's a cubemap array it has to be a multiple of 6).
  108. /// </param>
  109. /// <returns>A set of pixels for the specified mip level.</returns>
  110. public PixelData GetPixels(uint face = 0, uint mipLevel = 0)
  111. {
  112. return Internal_getPixels(mCachedPtr, face, mipLevel);
  113. }
  114. /// <summary>
  115. /// Reads texture pixels directly from the GPU. This is similar to GetPixels but the texture doesn't need to be created
  116. /// with TextureUsage.CPUCached, and the data will contain any updates performed by the GPU. This method can be
  117. /// potentially slow as it introduces a CPU-GPU synchronization point. Additionally this method is asynchronous which
  118. /// means the data is not available immediately.
  119. /// </summary>
  120. /// <param name="mipLevel">Mip level to retrieve pixels for. Top level (0) is the highest quality.</param>
  121. /// <param name="face">
  122. /// Face to read the pixels from. Cubemap textures have six faces whose face indices are as specified in the CubeFace
  123. /// enum. Array textures can have an arbitrary number of faces (if it's a cubemap array it has to be a multiple of 6).
  124. /// </param>
  125. /// <returns>AsyncOp object that will contain a PixelData object when the operation completes.</returns>
  126. public AsyncOp GetGPUPixels(uint face = 0, uint mipLevel = 0)
  127. {
  128. return Internal_getGPUPixels(mCachedPtr, face, mipLevel);
  129. }
  130. /// <summary>Sets pixels for the specified mip level and face.</summary>
  131. /// <param name="data">
  132. /// Pixels to assign to the specified mip level. Pixel data must match the mip level size and texture pixel format.
  133. /// </param>
  134. /// <param name="mipLevel">Mip level to set pixels for. Top level (0) is the highest quality.</param>
  135. /// <param name="face">
  136. /// Face to write the pixels to. Cubemap textures have six faces whose face indices are as specified in the CubeFace
  137. /// enum. Array textures can have an arbitrary number of faces (if it's a cubemap array it has to be a multiple of 6).
  138. /// </param>
  139. public void SetPixels(PixelData data, uint face = 0, uint mipLevel = 0)
  140. {
  141. Internal_setPixels(mCachedPtr, data, face, mipLevel);
  142. }
  143. /// <summary>Sets pixels for the specified mip level and face.</summary>
  144. /// <param name="colors">
  145. /// Pixels to assign to the specified mip level. Size of the array must match the mip level dimensions. Data is expected
  146. /// to be laid out row by row. Pixels will be automatically converted to the valid pixel format.
  147. /// </param>
  148. /// <param name="mipLevel">Mip level to set pixels for. Top level (0) is the highest quality.</param>
  149. /// <param name="face">
  150. /// Face to write the pixels to. Cubemap textures have six faces whose face indices are as specified in the CubeFace
  151. /// enum. Array textures can have an arbitrary number of faces (if it's a cubemap array it has to be a multiple of 6).
  152. /// </param>
  153. public void SetPixels(Color[] colors, uint face = 0, uint mipLevel = 0)
  154. {
  155. Internal_setPixelsArray(mCachedPtr, colors, face, mipLevel);
  156. }
  157. [MethodImpl(MethodImplOptions.InternalCall)]
  158. private static extern RRef<Texture> Internal_GetRef(IntPtr thisPtr);
  159. [MethodImpl(MethodImplOptions.InternalCall)]
  160. private static extern void Internal_create(Texture managedInstance, PixelFormat format, uint width, uint height, uint depth, TextureType texType, TextureUsage usage, uint numSamples, bool hasMipmaps, bool gammaCorrection);
  161. [MethodImpl(MethodImplOptions.InternalCall)]
  162. private static extern PixelFormat Internal_getPixelFormat(IntPtr thisPtr);
  163. [MethodImpl(MethodImplOptions.InternalCall)]
  164. private static extern TextureUsage Internal_getUsage(IntPtr thisPtr);
  165. [MethodImpl(MethodImplOptions.InternalCall)]
  166. private static extern TextureType Internal_getType(IntPtr thisPtr);
  167. [MethodImpl(MethodImplOptions.InternalCall)]
  168. private static extern uint Internal_getWidth(IntPtr thisPtr);
  169. [MethodImpl(MethodImplOptions.InternalCall)]
  170. private static extern uint Internal_getHeight(IntPtr thisPtr);
  171. [MethodImpl(MethodImplOptions.InternalCall)]
  172. private static extern uint Internal_getDepth(IntPtr thisPtr);
  173. [MethodImpl(MethodImplOptions.InternalCall)]
  174. private static extern bool Internal_getGammaCorrection(IntPtr thisPtr);
  175. [MethodImpl(MethodImplOptions.InternalCall)]
  176. private static extern uint Internal_getSampleCount(IntPtr thisPtr);
  177. [MethodImpl(MethodImplOptions.InternalCall)]
  178. private static extern uint Internal_getMipmapCount(IntPtr thisPtr);
  179. [MethodImpl(MethodImplOptions.InternalCall)]
  180. private static extern PixelData Internal_getPixels(IntPtr thisPtr, uint face, uint mipLevel);
  181. [MethodImpl(MethodImplOptions.InternalCall)]
  182. private static extern AsyncOp Internal_getGPUPixels(IntPtr thisPtr, uint face, uint mipLevel);
  183. [MethodImpl(MethodImplOptions.InternalCall)]
  184. private static extern void Internal_setPixels(IntPtr thisPtr, PixelData data, uint face, uint mipLevel);
  185. [MethodImpl(MethodImplOptions.InternalCall)]
  186. private static extern void Internal_setPixelsArray(IntPtr thisPtr, Color[] colors, uint face, uint mipLevel);
  187. }
  188. /** @} */
  189. }