Merge "Remove Not Referenced APIs" into devel/master
[platform/core/uifw/dali-csharp-binder.git] / dali-csharp-binder / dali-toolkit / gl-view-wrap.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // EXTERNAL INCLUDES
19 #include <dali-toolkit/public-api/controls/gl-view/gl-view.h>
20
21 // INTERNAL INCLUDES
22 #include <dali-csharp-binder/common/common.h>
23 #include <dali/public-api/signals/render-callback.h>
24
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #endif
29
30   /*GlView binding*/
31   SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_GlView_New_SWIG(int nuiColorFormat)
32   {
33     void *jresult;
34     Dali::Toolkit::GlView result;
35
36     Dali::Toolkit::GlView::ColorFormat colorFormat;
37     colorFormat = static_cast<Dali::Toolkit::GlView::ColorFormat>(nuiColorFormat);
38     {
39       try
40       {
41         result = Dali::Toolkit::GlView::New(colorFormat);
42       }
43       CALL_CATCH_EXCEPTION(0);
44     }
45
46     jresult = new Dali::Toolkit::GlView((const Dali::Toolkit::GlView &)result);
47     return jresult;
48   }
49
50   SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_GlView_New2_SWIG(int nuiBackendMode, int nuiColorFormat)
51   {
52     void *jresult;
53     Dali::Toolkit::GlView result;
54
55     Dali::Toolkit::GlView::ColorFormat colorFormat;
56     Dali::Toolkit::GlView::BackendMode backendMode;
57     colorFormat = static_cast<Dali::Toolkit::GlView::ColorFormat>(nuiColorFormat);
58     backendMode = static_cast<Dali::Toolkit::GlView::BackendMode>(nuiBackendMode);
59     {
60       try
61       {
62
63         result = Dali::Toolkit::GlView::New(backendMode, colorFormat);
64       }
65       CALL_CATCH_EXCEPTION(0);
66     }
67
68     jresult = new Dali::Toolkit::GlView((const Dali::Toolkit::GlView &)result);
69     return jresult;
70   }
71
72
73
74
75
76   SWIGEXPORT void SWIGSTDCALL CSharp_Dali_GlView_SetGraphicsConfig(void *nuiGlView, bool nuiDepth, bool nuiStencil, int nuiMsaa, int nuiVersion)
77   {
78     Dali::Toolkit::GlView *glView = nullptr;
79     Dali::Toolkit::GlView::GraphicsApiVersion version;
80
81     glView = (Dali::Toolkit::GlView *)nuiGlView;
82     version = static_cast<Dali::Toolkit::GlView::GraphicsApiVersion>(nuiVersion);
83     {
84       try
85       {
86         (glView)->SetGraphicsConfig(nuiDepth, nuiStencil, nuiMsaa, version);
87       }
88       CALL_CATCH_EXCEPTION();
89     }
90   }
91
92   SWIGEXPORT void SWIGSTDCALL CSharp_Dali_GlView_RegisterGlCallbacks(void *nuiGlView, void *nuiInitCB, int *nuiRenderFrameCB, void *nuiTerminateCB)
93   {
94     Dali::Toolkit::GlView *glView = (Dali::Toolkit::GlView *)nuiGlView;
95     void (*initCB)() = (void (*)())nuiInitCB;
96     int (*renderFrameCB)() = (int (*)())nuiRenderFrameCB;
97     void (*terminateCB)() = (void (*)())nuiTerminateCB;
98
99     if (!glView || !initCB || !renderFrameCB || !terminateCB)
100     {
101       SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null", 0);
102       return;
103     }
104     try
105     {
106       glView->RegisterGlCallbacks(Dali::MakeCallback(initCB), Dali::MakeCallback(renderFrameCB), Dali::MakeCallback(terminateCB));
107     }
108     CALL_CATCH_EXCEPTION();
109   }
110
111   SWIGEXPORT void SWIGSTDCALL CSharp_Dali_GlView_SetResizeCallback(void *nuiGlView, void *nuiResizeCB)
112   {
113     Dali::Toolkit::GlView *glView = (Dali::Toolkit::GlView *)nuiGlView;
114     void (*resizeCB)(int, int) = (void (*)(int, int))nuiResizeCB;
115
116     if (!glView || !resizeCB)
117     {
118       SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null", 0);
119       return;
120     }
121     try
122     {
123       glView->SetResizeCallback(Dali::MakeCallback(resizeCB));
124     }
125     CALL_CATCH_EXCEPTION();
126   }
127
128   SWIGEXPORT void SWIGSTDCALL CSharp_Dali_GlView_RenderOnce(void *nuiGlView)
129   {
130     Dali::Toolkit::GlView *glView = (Dali::Toolkit::GlView *)nuiGlView;
131     if (!glView)
132     {
133       SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Toolkit::GlView", 0);
134       return;
135     }
136     {
137       try
138       {
139         glView->RenderOnce();
140       }
141       CALL_CATCH_EXCEPTION();
142     }
143   }
144
145   SWIGEXPORT void SWIGSTDCALL CSharp_Dali_GlView_BindTextureResources(void *nuiGlView, void *textures, int size)
146   {
147     Dali::Toolkit::GlView *glView = (Dali::Toolkit::GlView *)nuiGlView;
148     Dali::Texture **texPtr = (Dali::Texture **)textures;
149     if (!glView)
150     {
151       SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Toolkit::GlView", 0);
152       return;
153     }
154     {
155       try
156       {
157         // Convert array to vector
158         std::vector<Dali::Texture> vTex;
159         for (int i = 0; i < size; i++)
160         {
161           Dali::Texture texture = *texPtr[i];
162           vTex.push_back(texture);
163         }
164         glView->BindTextureResources(vTex);
165       }
166       CALL_CATCH_EXCEPTION();
167     }
168   }
169
170   SWIGEXPORT int SWIGSTDCALL CSharp_Dali_GlView_GetRenderingMode(void *nuiGlView)
171   {
172     int jresult;
173     Dali::Toolkit::GlView *glView = nullptr;
174     Dali::Toolkit::GlView::RenderingMode result;
175
176     glView = (Dali::Toolkit::GlView *)nuiGlView;
177     if (!glView)
178     {
179       SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Toolkit::GlView", 0);
180       return 0;
181     }
182
183     {
184       try
185       {
186         result = (Dali::Toolkit::GlView::RenderingMode)(glView)->GetRenderingMode();
187       }
188       CALL_CATCH_EXCEPTION(0);
189     }
190
191     jresult = (int)result;
192     return jresult;
193   }
194
195   SWIGEXPORT void SWIGSTDCALL CSharp_Dali_GlView_SetRenderingMode(void *nuiGlView, int nuiRenderingMode)
196   {
197     Dali::Toolkit::GlView *glView = nullptr;
198     Dali::Toolkit::GlView::RenderingMode renderingMode;
199
200     glView = (Dali::Toolkit::GlView *)nuiGlView;
201     if (!glView)
202     {
203       SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Toolkit::GlView", 0);
204       return;
205     }
206     renderingMode = (Dali::Toolkit::GlView::RenderingMode)nuiRenderingMode;
207     {
208       try
209       {
210         (glView)->SetRenderingMode(renderingMode);
211       }
212       CALL_CATCH_EXCEPTION();
213     }
214   }
215
216
217   SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_RenderCallbackInput_Size_get(void *input)
218   {
219     void *jresult;
220     Dali::Size *result = 0;
221     Dali::RenderCallbackInput *renderInput = (Dali::RenderCallbackInput *)input;
222
223     result = &(renderInput->size);
224     jresult = (void *)result;
225     return jresult;
226   }
227
228   SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_RenderCallbackInput_Mvp_get(void *input)
229   {
230     void *jresult;
231     Dali::Matrix *result = 0;
232     Dali::RenderCallbackInput *renderInput = (Dali::RenderCallbackInput *)input;
233
234     result = &(renderInput->mvp);
235     jresult = (void *)result;
236     return jresult;
237   }
238
239   SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_RenderCallbackInput_Projection_get(void *input)
240   {
241     void *jresult;
242     Dali::Matrix *result = 0;
243     Dali::RenderCallbackInput *renderInput = (Dali::RenderCallbackInput *)input;
244
245     result = &(renderInput->projection);
246     jresult = (void *)result;
247     return jresult;
248   }
249
250   SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_RenderCallbackInput_ClippingBox_get(void *input)
251   {
252     void *jresult;
253     Dali::Rect<int> *result = 0;
254     Dali::RenderCallbackInput *renderInput = (Dali::RenderCallbackInput *)input;
255
256     result = &(renderInput->clippingBox);
257     jresult = (void *)result;
258     return jresult;
259   }
260
261   SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_RenderCallbackInput_TextureBindings_get(void *input, int *size)
262   {
263     void *jresult;
264     uint *result = 0;
265     Dali::RenderCallbackInput *renderInput = (Dali::RenderCallbackInput *)input;
266
267     result = renderInput->textureBindings.data();
268     *size = renderInput->textureBindings.size();
269     jresult = (void *)result;
270     return jresult;
271   }
272
273 #ifdef __cplusplus
274 }
275 #endif