Texture3D.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. namespace BansheeEngine
  4. {
  5. public sealed class Texture3D : Texture
  6. {
  7. public int Depth
  8. {
  9. get
  10. {
  11. int value;
  12. Internal_GetDepth(mCachedPtr, out value);
  13. return value;
  14. }
  15. }
  16. // For internal use by the runtime
  17. private Texture3D()
  18. { }
  19. public Texture3D(PixelFormat format, int width, int height, int depth, TextureUsage usage = TextureUsage.Default,
  20. bool hasMipmaps = false, bool gammaCorrection = false)
  21. {
  22. Internal_CreateInstance(this, format, width, height, depth, usage, hasMipmaps, gammaCorrection);
  23. }
  24. public PixelData GetPixels(int mipLevel = 0)
  25. {
  26. return Internal_GetPixels(mCachedPtr, mipLevel);
  27. }
  28. public void SetPixels(PixelData data, int mipLevel = 0)
  29. {
  30. Internal_SetPixels(mCachedPtr, data, mipLevel);
  31. }
  32. public AsyncOp GetGPUPixels(int mipLevel = 0)
  33. {
  34. return Internal_GetGPUPixels(mCachedPtr, mipLevel);
  35. }
  36. [MethodImpl(MethodImplOptions.InternalCall)]
  37. private static extern void Internal_CreateInstance(Texture3D instance, PixelFormat format, int width,
  38. int height, int depth, TextureUsage usage, bool hasMipmaps, bool gammaCorrection);
  39. [MethodImpl(MethodImplOptions.InternalCall)]
  40. private static extern void Internal_GetDepth(IntPtr thisPtr, out int value);
  41. [MethodImpl(MethodImplOptions.InternalCall)]
  42. private static extern PixelData Internal_GetPixels(IntPtr thisPtr, int mipLevel);
  43. [MethodImpl(MethodImplOptions.InternalCall)]
  44. private static extern AsyncOp Internal_GetGPUPixels(IntPtr thisPtr, int mipLevel);
  45. [MethodImpl(MethodImplOptions.InternalCall)]
  46. private static extern void Internal_SetPixels(IntPtr thisPtr, PixelData data, int mipLevel);
  47. }
  48. }