2 * Copyright (c) 2021 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.
19 #include <dali-toolkit/public-api/controls/gl-view/gl-view.h>
22 #include <dali-csharp-binder/common/common.h>
23 #include <dali/public-api/signals/render-callback.h>
31 SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_GlView_New_SWIG(int nuiColorFormat)
34 Dali::Toolkit::GlView result;
36 Dali::Toolkit::GlView::ColorFormat colorFormat;
37 colorFormat = static_cast<Dali::Toolkit::GlView::ColorFormat>(nuiColorFormat);
41 result = Dali::Toolkit::GlView::New(colorFormat);
43 CALL_CATCH_EXCEPTION(0);
46 jresult = new Dali::Toolkit::GlView((const Dali::Toolkit::GlView &)result);
50 SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_GlView_New2_SWIG(int nuiBackendMode, int nuiColorFormat)
53 Dali::Toolkit::GlView result;
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);
63 result = Dali::Toolkit::GlView::New(backendMode, colorFormat);
65 CALL_CATCH_EXCEPTION(0);
68 jresult = new Dali::Toolkit::GlView((const Dali::Toolkit::GlView &)result);
76 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_GlView_SetGraphicsConfig(void *nuiGlView, bool nuiDepth, bool nuiStencil, int nuiMsaa, int nuiVersion)
78 Dali::Toolkit::GlView *glView = nullptr;
79 Dali::Toolkit::GlView::GraphicsApiVersion version;
81 glView = (Dali::Toolkit::GlView *)nuiGlView;
82 version = static_cast<Dali::Toolkit::GlView::GraphicsApiVersion>(nuiVersion);
86 (glView)->SetGraphicsConfig(nuiDepth, nuiStencil, nuiMsaa, version);
88 CALL_CATCH_EXCEPTION();
92 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_GlView_RegisterGlCallbacks(void *nuiGlView, void *nuiInitCB, int *nuiRenderFrameCB, void *nuiTerminateCB)
94 Dali::Toolkit::GlView *glView = (Dali::Toolkit::GlView *)nuiGlView;
95 void (*initCB)() = (void (*)())nuiInitCB;
96 int (*renderFrameCB)() = (int (*)())nuiRenderFrameCB;
97 void (*terminateCB)() = (void (*)())nuiTerminateCB;
99 if (!glView || !initCB || !renderFrameCB || !terminateCB)
101 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null", 0);
106 glView->RegisterGlCallbacks(Dali::MakeCallback(initCB), Dali::MakeCallback(renderFrameCB), Dali::MakeCallback(terminateCB));
108 CALL_CATCH_EXCEPTION();
111 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_GlView_SetResizeCallback(void *nuiGlView, void *nuiResizeCB)
113 Dali::Toolkit::GlView *glView = (Dali::Toolkit::GlView *)nuiGlView;
114 void (*resizeCB)(int, int) = (void (*)(int, int))nuiResizeCB;
116 if (!glView || !resizeCB)
118 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null", 0);
123 glView->SetResizeCallback(Dali::MakeCallback(resizeCB));
125 CALL_CATCH_EXCEPTION();
128 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_GlView_RenderOnce(void *nuiGlView)
130 Dali::Toolkit::GlView *glView = (Dali::Toolkit::GlView *)nuiGlView;
133 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Toolkit::GlView", 0);
139 glView->RenderOnce();
141 CALL_CATCH_EXCEPTION();
145 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_GlView_BindTextureResources(void *nuiGlView, void *textures, int size)
147 Dali::Toolkit::GlView *glView = (Dali::Toolkit::GlView *)nuiGlView;
148 Dali::Texture **texPtr = (Dali::Texture **)textures;
151 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Toolkit::GlView", 0);
157 // Convert array to vector
158 std::vector<Dali::Texture> vTex;
159 for (int i = 0; i < size; i++)
161 Dali::Texture texture = *texPtr[i];
162 vTex.push_back(texture);
164 glView->BindTextureResources(vTex);
166 CALL_CATCH_EXCEPTION();
170 SWIGEXPORT int SWIGSTDCALL CSharp_Dali_GlView_GetRenderingMode(void *nuiGlView)
173 Dali::Toolkit::GlView *glView = nullptr;
174 Dali::Toolkit::GlView::RenderingMode result;
176 glView = (Dali::Toolkit::GlView *)nuiGlView;
179 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Toolkit::GlView", 0);
186 result = (Dali::Toolkit::GlView::RenderingMode)(glView)->GetRenderingMode();
188 CALL_CATCH_EXCEPTION(0);
191 jresult = (int)result;
195 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_GlView_SetRenderingMode(void *nuiGlView, int nuiRenderingMode)
197 Dali::Toolkit::GlView *glView = nullptr;
198 Dali::Toolkit::GlView::RenderingMode renderingMode;
200 glView = (Dali::Toolkit::GlView *)nuiGlView;
203 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Toolkit::GlView", 0);
206 renderingMode = (Dali::Toolkit::GlView::RenderingMode)nuiRenderingMode;
210 (glView)->SetRenderingMode(renderingMode);
212 CALL_CATCH_EXCEPTION();
217 SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_RenderCallbackInput_Size_get(void *input)
220 Dali::Size *result = 0;
221 Dali::RenderCallbackInput *renderInput = (Dali::RenderCallbackInput *)input;
223 result = &(renderInput->size);
224 jresult = (void *)result;
228 SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_RenderCallbackInput_Mvp_get(void *input)
231 Dali::Matrix *result = 0;
232 Dali::RenderCallbackInput *renderInput = (Dali::RenderCallbackInput *)input;
234 result = &(renderInput->mvp);
235 jresult = (void *)result;
239 SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_RenderCallbackInput_Projection_get(void *input)
242 Dali::Matrix *result = 0;
243 Dali::RenderCallbackInput *renderInput = (Dali::RenderCallbackInput *)input;
245 result = &(renderInput->projection);
246 jresult = (void *)result;
250 SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_RenderCallbackInput_ClippingBox_get(void *input)
253 Dali::Rect<int> *result = 0;
254 Dali::RenderCallbackInput *renderInput = (Dali::RenderCallbackInput *)input;
256 result = &(renderInput->clippingBox);
257 jresult = (void *)result;
261 SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_RenderCallbackInput_TextureBindings_get(void *input, int *size)
265 Dali::RenderCallbackInput *renderInput = (Dali::RenderCallbackInput *)input;
267 result = renderInput->textureBindings.data();
268 *size = renderInput->textureBindings.size();
269 jresult = (void *)result;