2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 using System.ComponentModel;
18 using System.Runtime.InteropServices;
23 /// TextureSet is a handle to an object that specifies the set of images used as textures by a renderer.<br />
24 /// The images have to be ordered in the same order they are declared in the shader.
26 /// <since_tizen> 3 </since_tizen>
27 public class TextureSet : BaseHandle
31 /// Create an instance of TextureSet.
33 /// <since_tizen> 3 </since_tizen>
34 public TextureSet() : this(Interop.TextureSet.New(), true)
36 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
39 internal TextureSet(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
44 /// Sets the texture at position "index".
46 /// <param name="index">The position in the texture set of the texture.</param>
47 /// <param name="texture">The texture.</param>
48 /// <since_tizen> 3 </since_tizen>
49 public void SetTexture(uint index, Texture texture)
51 Interop.TextureSet.SetTexture(SwigCPtr, index, Texture.getCPtr(texture));
52 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
56 /// Gets the image at position "index".
58 /// <param name="index">The position in the texture set of the image.</param>
59 /// <returns>A handle to the image at the the specified position.</returns>
60 /// <since_tizen> 3 </since_tizen>
61 public Texture GetTexture(uint index)
63 //to fix memory leak issue, match the handle count with native side.
64 System.IntPtr cPtr = Interop.TextureSet.GetTexture(SwigCPtr, index);
65 HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
66 Texture ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as Texture;
67 if (cPtr != null && ret == null)
69 ret = new Texture(cPtr, false);
70 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
73 Interop.BaseHandle.DeleteBaseHandle(CPtr);
74 CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
76 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81 /// Sets the sampler to be used by the image at position "index".
83 /// <param name="index">The position in the texture set of the image.</param>
84 /// <param name="sampler">The sampler to use.</param>
85 /// <since_tizen> 3 </since_tizen>
86 public void SetSampler(uint index, Sampler sampler)
88 Interop.TextureSet.SetSampler(SwigCPtr, index, Sampler.getCPtr(sampler));
89 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
93 /// Sets the sampler to be used by the image at position "index".
95 /// <param name="index">The position in the texture set of the image.</param>
96 /// <returns>A handle to the sampler at the specified position.</returns>
97 /// <since_tizen> 3 </since_tizen>
98 public Sampler GetSampler(uint index)
100 //to fix memory leak issue, match the handle count with native side.
101 System.IntPtr cPtr = Interop.TextureSet.GetSampler(SwigCPtr, index);
102 Sampler ret = this.GetInstanceSafely<Sampler>(cPtr);
103 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
108 /// Gets the number of textures present in the TextureSet.
110 /// <returns>The number of textures in the TextureSet.</returns>
111 /// <since_tizen> 3 </since_tizen>
112 public uint GetTextureCount()
114 uint ret = Interop.TextureSet.GetTextureCount(SwigCPtr);
115 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
119 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextureSet obj)
121 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
124 /// This will not be public opened.
125 [EditorBrowsable(EditorBrowsableState.Never)]
126 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
128 Interop.TextureSet.DeleteTextureSet(swigCPtr);