Release 4.0.0-preview1-00271
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Geometry.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16
17 namespace Tizen.NUI
18 {
19
20     /// <summary>
21     /// Geometry is handle to an object that can be used to define a geometric elements.
22     /// </summary>
23     public class Geometry : BaseHandle
24     {
25         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
26
27         internal Geometry(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Geometry_SWIGUpcast(cPtr), cMemoryOwn)
28         {
29             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
30         }
31
32         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Geometry obj)
33         {
34             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
35         }
36
37         protected override void Dispose(DisposeTypes type)
38         {
39             if (disposed)
40             {
41                 return;
42             }
43
44             if (type == DisposeTypes.Explicit)
45             {
46                 //Called by User
47                 //Release your own managed resources here.
48                 //You should release all of your own disposable objects here.
49
50             }
51
52             //Release your own unmanaged resources here.
53             //You should not access any managed member here except static instance.
54             //because the execution order of Finalizes is non-deterministic.
55
56             if (swigCPtr.Handle != global::System.IntPtr.Zero)
57             {
58                 if (swigCMemOwn)
59                 {
60                     swigCMemOwn = false;
61                     NDalicPINVOKE.delete_Geometry(swigCPtr);
62                 }
63                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
64             }
65
66             base.Dispose(type);
67         }
68
69         /// <summary>
70         /// Create an instance of Geometry.
71         /// <since_tizen> 3 </since_tizen>
72         /// </summary>
73         public Geometry() : this(NDalicPINVOKE.Geometry_New(), true)
74         {
75             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
76
77         }
78
79         /// <summary>
80         /// Adds a PropertyBuffer to be used as source of geometry vertices.
81         /// </summary>
82         /// <param name="vertexBuffer">PropertyBuffer to be used as source of geometry vertices.</param>
83         /// <returns>Index of the newly added buffer.</returns>
84         /// <since_tizen> 3 </since_tizen>
85         public uint AddVertexBuffer(PropertyBuffer vertexBuffer)
86         {
87             uint ret = NDalicPINVOKE.Geometry_AddVertexBuffer(swigCPtr, PropertyBuffer.getCPtr(vertexBuffer));
88             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
89             return ret;
90         }
91
92         /// <summary>
93         /// Retrieves the number of vertex buffers that have been added to this geometry.
94         /// </summary>
95         /// <returns>Number of vertex buffers that have been added to this geometry.</returns>
96         /// <since_tizen> 3 </since_tizen>
97         public uint GetNumberOfVertexBuffers()
98         {
99             uint ret = NDalicPINVOKE.Geometry_GetNumberOfVertexBuffers(swigCPtr);
100             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
101             return ret;
102         }
103
104         /// <summary>
105         /// Removes a vertex buffer.
106         /// </summary>
107         /// <param name="index">Index to the vertex buffer to remove.</param>
108         /// <since_tizen> 3 </since_tizen>
109         public void RemoveVertexBuffer(uint index)
110         {
111             NDalicPINVOKE.Geometry_RemoveVertexBuffer(swigCPtr, index);
112             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
113         }
114
115         /// <summary>
116         /// Sets a the index data to be used as a source of indices for the geometry
117         /// Setting this buffer will cause the geometry to be rendered using indices.
118         /// </summary>
119         /// <param name="indices">Array of indices.</param>
120         /// <param name="count">Number of indices in the array.</param>
121         /// <since_tizen> 3 </since_tizen>
122         public void SetIndexBuffer(ushort[] indices, uint count)
123         {
124             NDalicPINVOKE.Geometry_SetIndexBuffer(swigCPtr, indices, count);
125             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
126         }
127
128         /// <summary>
129         /// Sets the type of primitives this geometry contains.
130         /// </summary>
131         /// <param name="geometryType">Array of indices.</param>
132         /// <since_tizen> 3 </since_tizen>
133         public void SetType(Geometry.Type geometryType)
134         {
135             NDalicPINVOKE.Geometry_SetType(swigCPtr, (int)geometryType);
136             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
137         }
138
139         /// <summary>
140         /// Gets the type of primitives this geometry contains.
141         /// </summary>
142         /// <returns>Type of primitives this geometry contains.</returns>
143         /// <since_tizen> 3 </since_tizen>
144         public new Geometry.Type GetType()
145         {
146             Geometry.Type ret = (Geometry.Type)NDalicPINVOKE.Geometry_GetType(swigCPtr);
147             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148             return ret;
149         }
150
151         /// <summary>
152         /// Enumeration for the description of the type of geometry,
153         /// used to determine how the coordinates will be used.
154         /// </summary>
155         /// <returns>Type of primitives this geometry contains.</returns>
156         /// <since_tizen> 3 </since_tizen>
157         public enum Type
158         {
159             /// <summary>
160             /// Individual points.
161             /// </summary>
162             POINTS,
163
164             /// <summary>
165             /// Individual lines (made of 2 points each).
166             /// </summary>
167             LINES,
168
169             /// <summary>
170             /// A strip of lines (made of 1 point each) which also joins the first and last point.
171             /// </summary>
172             LINE_LOOP,
173
174             /// <summary>
175             /// A strip of lines (made of 1 point each).
176             /// </summary>
177             LINE_STRIP,
178
179             /// <summary>
180             /// Individual triangles (made of 3 points each).
181             /// </summary>
182             TRIANGLES,
183
184             /// <summary>
185             /// A fan of triangles around a centre point (after the first triangle, following triangles need only 1 point).
186             /// </summary>
187             TRIANGLE_FAN,
188
189             /// <summary>
190             /// A strip of triangles (after the first triangle, following triangles need only 1 point).
191             /// </summary>
192             TRIANGLE_STRIP
193         }
194
195     }
196
197 }