Texture2D.cs 1.7 KB

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