Texture.cs 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using System.Runtime.CompilerServices;
  5. namespace BansheeEngine
  6. {
  7. /** @addtogroup Rendering
  8. * @{
  9. */
  10. public partial class Texture
  11. {
  12. /// <summary>
  13. /// Creates a new blank 2D texture.
  14. /// </summary>
  15. /// <param name="width">Width of the texture in pixels.</param>
  16. /// <param name="height">Height of the texture in pixels.</param>
  17. /// <param name="format">Format of the pixels.</param>
  18. /// <param name="usage">Describes planned texture use.</param>
  19. /// <param name="numSamples">If higher than 1, texture containing multiple samples per pixel is created.</param>
  20. /// <param name="hasMipmaps">Should the texture allocate memory for the entire mip-map chain or only the top level.
  21. /// </param>
  22. /// <param name="gammaCorrection">If true the texture data is assumed to have be gamma corrected and will be
  23. /// converted back to linear space when sampled on GPU, and converted to gamma space
  24. /// before being written by the GPU.</param>
  25. public static Texture Create2D(uint width, uint height, PixelFormat format = PixelFormat.RGBA8,
  26. TextureUsage usage = TextureUsage.Default, uint numSamples = 1, bool hasMipmaps = false,
  27. bool gammaCorrection = false)
  28. {
  29. Texture texture = new Texture(true);
  30. Internal_create(texture, format, width, height, 1, TextureType.Texture2D, usage, numSamples,
  31. hasMipmaps, gammaCorrection);
  32. return texture;
  33. }
  34. /// <summary>
  35. /// Creates a new blank 3D texture.
  36. /// </summary>
  37. /// <param name="width">Width of the texture in pixels.</param>
  38. /// <param name="height">Height of the texture in pixels.</param>
  39. /// <param name="depth">Depth of the texture in pixels.</param>
  40. /// <param name="format">Format of the pixels.</param>
  41. /// <param name="usage">Describes planned texture use.</param>
  42. /// <param name="hasMipmaps">Should the texture allocate memory for the entire mip-map chain or only the top level.
  43. /// </param>
  44. public static Texture Create3D(uint width, uint height, uint depth, PixelFormat format = PixelFormat.RGBA8,
  45. TextureUsage usage = TextureUsage.Default, bool hasMipmaps = false)
  46. {
  47. Texture texture = new Texture(true);
  48. Internal_create(texture, format, width, height, depth, TextureType.Texture3D, usage, 1,
  49. hasMipmaps, false);
  50. return texture;
  51. }
  52. /// <summary>
  53. /// Creates a new blank cubemap texture.
  54. /// </summary>
  55. /// <param name="size">Width & height of a single cubemap face in pixels.</param>
  56. /// <param name="format">Format of the pixels.</param>
  57. /// <param name="usage">Describes planned texture use.</param>
  58. /// <param name="hasMipmaps">Should the texture allocate memory for the entire mip-map chain or only the top level.
  59. /// </param>
  60. /// <param name="gammaCorrection">If true the texture data is assumed to have be gamma corrected and will be
  61. /// converted back to linear space when sampled on GPU, and converted to gamma space
  62. /// before being written by the GPU.</param>
  63. public static Texture CreateCube(uint size, PixelFormat format = PixelFormat.RGBA8,
  64. TextureUsage usage = TextureUsage.Default, bool hasMipmaps = false, bool gammaCorrection = false)
  65. {
  66. Texture texture = new Texture(true);
  67. Internal_create(texture, format, size, size, 1, TextureType.TextureCube, usage, 1,
  68. hasMipmaps, gammaCorrection);
  69. return texture;
  70. }
  71. }
  72. /// <summary>
  73. /// Indices for the faces of a cube texture.
  74. /// </summary>
  75. public enum CubeFace
  76. {
  77. PositiveX = 0,
  78. NegativeX = 1,
  79. PositiveY = 2,
  80. NegativeY = 3,
  81. PositiveZ = 4,
  82. NegativeZ = 5,
  83. }
  84. /** @} */
  85. }