Texture2D.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. // WARNING - AUTOGENERATED - DO NOT EDIT
  2. //
  3. // Generated using `sharpie urho`
  4. //
  5. // Texture2D.cs
  6. //
  7. // Copyright 2015 Xamarin Inc. All rights reserved.
  8. using System;
  9. using System.Runtime.InteropServices;
  10. using System.Collections.Generic;
  11. using Urho.Urho2D;
  12. using Urho.Gui;
  13. using Urho.Resources;
  14. using Urho.IO;
  15. using Urho.Navigation;
  16. using Urho.Network;
  17. namespace Urho.Urho2D
  18. {
  19. /// <summary>
  20. /// 2D texture resource.
  21. /// </summary>
  22. public unsafe partial class Texture2D : Texture
  23. {
  24. unsafe partial void OnTexture2DCreated ();
  25. [Preserve]
  26. public Texture2D (IntPtr handle) : base (handle)
  27. {
  28. OnTexture2DCreated ();
  29. }
  30. [Preserve]
  31. protected Texture2D (UrhoObjectFlag emptyFlag) : base (emptyFlag)
  32. {
  33. OnTexture2DCreated ();
  34. }
  35. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  36. internal static extern int Texture2D_GetType (IntPtr handle);
  37. private StringHash UrhoGetType ()
  38. {
  39. Runtime.ValidateRefCounted (this);
  40. return new StringHash (Texture2D_GetType (handle));
  41. }
  42. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  43. internal static extern IntPtr Texture2D_GetTypeName (IntPtr handle);
  44. private string GetTypeName ()
  45. {
  46. Runtime.ValidateRefCounted (this);
  47. return Marshal.PtrToStringAnsi (Texture2D_GetTypeName (handle));
  48. }
  49. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  50. internal static extern int Texture2D_GetTypeStatic ();
  51. private static StringHash GetTypeStatic ()
  52. {
  53. Runtime.Validate (typeof(Texture2D));
  54. return new StringHash (Texture2D_GetTypeStatic ());
  55. }
  56. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  57. internal static extern IntPtr Texture2D_GetTypeNameStatic ();
  58. private static string GetTypeNameStatic ()
  59. {
  60. Runtime.Validate (typeof(Texture2D));
  61. return Marshal.PtrToStringAnsi (Texture2D_GetTypeNameStatic ());
  62. }
  63. [Preserve]
  64. public Texture2D () : this (Application.CurrentContext)
  65. {
  66. }
  67. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  68. internal static extern IntPtr Texture2D_Texture2D (IntPtr context);
  69. [Preserve]
  70. public Texture2D (Context context) : base (UrhoObjectFlag.Empty)
  71. {
  72. Runtime.Validate (typeof(Texture2D));
  73. handle = Texture2D_Texture2D ((object)context == null ? IntPtr.Zero : context.Handle);
  74. Runtime.RegisterObject (this);
  75. OnTexture2DCreated ();
  76. }
  77. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  78. internal static extern void Texture2D_RegisterObject (IntPtr context);
  79. /// <summary>
  80. /// Register object factory.
  81. /// </summary>
  82. public static void RegisterObject (Context context)
  83. {
  84. Runtime.Validate (typeof(Texture2D));
  85. Texture2D_RegisterObject ((object)context == null ? IntPtr.Zero : context.Handle);
  86. }
  87. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  88. internal static extern bool Texture2D_BeginLoad_File (IntPtr handle, IntPtr source);
  89. /// <summary>
  90. /// Load resource from stream. May be called from a worker thread. Return true if successful.
  91. /// </summary>
  92. public override bool BeginLoad (File source)
  93. {
  94. Runtime.ValidateRefCounted (this);
  95. return Texture2D_BeginLoad_File (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  96. }
  97. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  98. internal static extern bool Texture2D_BeginLoad_MemoryBuffer (IntPtr handle, IntPtr source);
  99. /// <summary>
  100. /// Load resource from stream. May be called from a worker thread. Return true if successful.
  101. /// </summary>
  102. public override bool BeginLoad (MemoryBuffer source)
  103. {
  104. Runtime.ValidateRefCounted (this);
  105. return Texture2D_BeginLoad_MemoryBuffer (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  106. }
  107. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  108. internal static extern bool Texture2D_EndLoad (IntPtr handle);
  109. /// <summary>
  110. /// Finish resource loading. Always called from the main thread. Return true if successful.
  111. /// </summary>
  112. public override bool EndLoad ()
  113. {
  114. Runtime.ValidateRefCounted (this);
  115. return Texture2D_EndLoad (handle);
  116. }
  117. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  118. internal static extern void Texture2D_Release (IntPtr handle);
  119. /// <summary>
  120. /// Release the texture.
  121. /// </summary>
  122. public void Release ()
  123. {
  124. Runtime.ValidateRefCounted (this);
  125. Texture2D_Release (handle);
  126. }
  127. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  128. internal static extern void Texture2D_SetCustomTarget (IntPtr handle, uint target);
  129. /// <summary>
  130. /// Set custom target (for example - EOS)
  131. /// </summary>
  132. public void SetCustomTarget (uint target)
  133. {
  134. Runtime.ValidateRefCounted (this);
  135. Texture2D_SetCustomTarget (handle, target);
  136. }
  137. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  138. internal static extern bool Texture2D_SetSize (IntPtr handle, int width, int height, uint format, TextureUsage usage, int multiSample, bool autoResolve);
  139. /// <summary>
  140. /// Set size, format, usage and multisampling parameters for rendertargets. Zero size will follow application window size. Return true if successful.
  141. /// Autoresolve true means the multisampled texture will be automatically resolved to 1-sample after being rendered to and before being sampled as a texture.
  142. /// Autoresolve false means the multisampled texture will be read as individual samples in the shader and is not supported on Direct3D9.
  143. /// </summary>
  144. public bool SetSize (int width, int height, uint format, TextureUsage usage = TextureUsage.Static, int multiSample = 1, bool autoResolve = true)
  145. {
  146. Runtime.ValidateRefCounted (this);
  147. return Texture2D_SetSize (handle, width, height, format, usage, multiSample, autoResolve);
  148. }
  149. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  150. internal static extern bool Texture2D_SetData (IntPtr handle, uint level, int x, int y, int width, int height, void* data);
  151. /// <summary>
  152. /// Set data either partially or fully on a mip level. Return true if successful.
  153. /// </summary>
  154. public bool SetData (uint level, int x, int y, int width, int height, void* data)
  155. {
  156. Runtime.ValidateRefCounted (this);
  157. return Texture2D_SetData (handle, level, x, y, width, height, data);
  158. }
  159. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  160. internal static extern bool Texture2D_SetData0 (IntPtr handle, IntPtr image, bool useAlpha);
  161. /// <summary>
  162. /// Set data from an image. Return true if successful. Optionally make a single channel image alpha-only.
  163. /// </summary>
  164. public bool SetData (Image image, bool useAlpha = false)
  165. {
  166. Runtime.ValidateRefCounted (this);
  167. return Texture2D_SetData0 (handle, (object)image == null ? IntPtr.Zero : image.Handle, useAlpha);
  168. }
  169. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  170. internal static extern bool Texture2D_GetData (IntPtr handle, uint level, IntPtr dest);
  171. /// <summary>
  172. /// Get data from a mip level. The destination buffer must be big enough. Return true if successful.
  173. /// </summary>
  174. public bool GetData (uint level, IntPtr dest)
  175. {
  176. Runtime.ValidateRefCounted (this);
  177. return Texture2D_GetData (handle, level, dest);
  178. }
  179. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  180. internal static extern bool Texture2D_GetImage (IntPtr handle, IntPtr image);
  181. /// <summary>
  182. /// Get image data from zero mip level. Only RGB and RGBA textures are supported.
  183. /// </summary>
  184. public bool GetImage (Image image)
  185. {
  186. Runtime.ValidateRefCounted (this);
  187. return Texture2D_GetImage (handle, (object)image == null ? IntPtr.Zero : image.Handle);
  188. }
  189. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  190. internal static extern IntPtr Texture2D_GetImage1 (IntPtr handle);
  191. /// <summary>
  192. /// Get image data from zero mip level. Only RGB and RGBA textures are supported.
  193. /// </summary>
  194. private Image GetImage ()
  195. {
  196. Runtime.ValidateRefCounted (this);
  197. return Runtime.LookupRefCounted<Image> (Texture2D_GetImage1 (handle));
  198. }
  199. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  200. internal static extern IntPtr Texture2D_GetRenderSurface (IntPtr handle);
  201. /// <summary>
  202. /// Return render surface.
  203. /// </summary>
  204. private RenderSurface GetRenderSurface ()
  205. {
  206. Runtime.ValidateRefCounted (this);
  207. return Runtime.LookupRefCounted<RenderSurface> (Texture2D_GetRenderSurface (handle));
  208. }
  209. public override StringHash Type {
  210. get {
  211. return UrhoGetType ();
  212. }
  213. }
  214. public override string TypeName {
  215. get {
  216. return GetTypeName ();
  217. }
  218. }
  219. [Preserve]
  220. public new static StringHash TypeStatic {
  221. get {
  222. return GetTypeStatic ();
  223. }
  224. }
  225. public new static string TypeNameStatic {
  226. get {
  227. return GetTypeNameStatic ();
  228. }
  229. }
  230. /// <summary>
  231. /// Get image data from zero mip level. Only RGB and RGBA textures are supported.
  232. /// </summary>
  233. public Image Image {
  234. get {
  235. return GetImage ();
  236. }
  237. }
  238. /// <summary>
  239. /// Return render surface.
  240. /// </summary>
  241. public RenderSurface RenderSurface {
  242. get {
  243. return GetRenderSurface ();
  244. }
  245. }
  246. }
  247. }