2 * Copyright(c) 2020 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.
18 extern alias TizenSystemInformation;
19 using TizenSystemInformation.Tizen.System;
21 using System.ComponentModel;
22 using System.Collections.Generic;
23 using global::System.Runtime.InteropServices;
24 using Tizen.NUI.BaseComponents;
29 /// The GLWindow class is to draw with native GLES.<br />
30 /// This class is the special window. It is for native GLES application.<br />
31 /// So, some special funtions and type are supported.<br />
32 /// In addition, basic window's functions are supported, too.<br />
34 [EditorBrowsable(EditorBrowsableState.Never)]
35 public partial class GLWindow : BaseHandle
37 internal GLWindow(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.GLWindow.GlWindow_SWIGUpcast(cPtr), cMemoryOwn)
43 /// Creates an initialized handle to a new GLWindow.<br />
44 /// This creates an GLWindow with default options.!--<br />
46 /// <returns>A new GLWindow.</returns>
47 [EditorBrowsable(EditorBrowsableState.Never)]
48 public GLWindow() : this(Interop.GLWindow.GlWindow_New__SWIG_0(), true)
50 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
54 /// Creates an initialized handle to a new GLWindow.<br />
55 /// This API can create GLWindow with specifc option.<br />
57 /// <param name="name">The name for GL window. </param>
58 /// <param name="windowPosition">The position and size of the Window.</param>
59 /// <param name="isTranslucent">Whether Window is translucent.</param>
60 /// <returns>A new Window.</returns>
61 [EditorBrowsable(EditorBrowsableState.Never)]
62 public GLWindow(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.GLWindow.GlWindow_New__SWIG_1( Rectangle.getCPtr(windowPosition), name, "", isTranslucent), true)
64 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
68 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
70 [EditorBrowsable(EditorBrowsableState.Never)]
71 public enum GLWindowOrientation
74 /// Portrait orientation. The height of the display area is greater than the width.
76 [EditorBrowsable(EditorBrowsableState.Never)]
80 /// Landscape orientation. A wide view area is needed.
82 [EditorBrowsable(EditorBrowsableState.Never)]
86 /// Portrait inverse orientation.
88 [EditorBrowsable(EditorBrowsableState.Never)]
89 PortraitInverse = 180,
92 /// Landscape inverse orientation.
94 [EditorBrowsable(EditorBrowsableState.Never)]
95 LandscapeInverse = 270,
98 /// No orientation. It is for the preferred orientation
99 /// Especially, NoOrientationPreference only has the effect for the preferred orientation.
100 /// It is used to unset the preferred orientation with SetPreferredOrientation.
102 [EditorBrowsable(EditorBrowsableState.Never)]
103 NoOrientationPreference = -1
107 /// Gets or sets a size of the window.
109 [EditorBrowsable(EditorBrowsableState.Never)]
110 public Size2D WindowSize
114 var val = new Rectangle(Interop.GLWindow.GlWindow_GetPositionSize(swigCPtr), true);
115 Size2D ret = new Size2D(val.Width, val.Height);
121 var val = new Rectangle(Interop.GLWindow.GlWindow_GetPositionSize(swigCPtr), true);
122 Rectangle ret = new Rectangle(val.X, val.Y, value.Width, value.Height );
124 Interop.GLWindow.GlWindow_SetPositionSize(swigCPtr, Rectangle.getCPtr(ret));
129 /// This Enumeration is used the GLES version for EGL configuration.<br />
130 /// If the device can not support GLES version 3.0 over, the version will be chosen with GLES version 2.0<br />
132 [EditorBrowsable(EditorBrowsableState.Never)]
133 public enum GLESVersion
138 [EditorBrowsable(EditorBrowsableState.Never)]
144 [EditorBrowsable(EditorBrowsableState.Never)]
149 /// Sets egl configuration for GLWindow
151 /// <param name="depth">The flag of depth buffer. If true is set, 24bit depth buffer is enabled.</param>
152 /// <param name="stencil">The flag of stencil. it true is set, 8bit stencil buffer is enabled.</param>
153 /// <param name="msaa">The bit of msaa.</param>
154 /// <param name="version">The GLES version.</param>
155 [EditorBrowsable(EditorBrowsableState.Never)]
156 public void SetEglConfig( bool depth, bool stencil, int msaa, GLESVersion version )
158 Interop.GLWindow.GlWindow_SetEglConfig(swigCPtr, depth, stencil, msaa, (int)version);
159 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
163 /// Shows the GLWindow if it is hidden.
165 [EditorBrowsable(EditorBrowsableState.Never)]
168 Interop.GLWindow.GlWindow_Show(swigCPtr);
169 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173 /// Hides the GLWindow if it is showing.
175 [EditorBrowsable(EditorBrowsableState.Never)]
178 Interop.GLWindow.GlWindow_Hide(swigCPtr);
179 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
183 /// Raises the window to the top of the window stack.
185 [EditorBrowsable(EditorBrowsableState.Never)]
188 Interop.GLWindow.GlWindow_Raise(swigCPtr);
189 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
193 /// Lowers the window to the bottom of the window stack.
195 [EditorBrowsable(EditorBrowsableState.Never)]
198 Interop.GLWindow.GlWindow_Lower(swigCPtr);
199 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
203 /// Activates the window to the top of the window stack even it is iconified.
205 [EditorBrowsable(EditorBrowsableState.Never)]
206 public void Activate()
208 Interop.GLWindow.GlWindow_Activate(swigCPtr);
209 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213 /// Sets position and size of the window. This API guarantees that
214 /// both moving and resizing of window will appear on the screen at once.
216 [EditorBrowsable(EditorBrowsableState.Never)]
217 public Rectangle WindowPositionSize
221 Rectangle val = new Rectangle(Interop.GLWindow.GlWindow_GetPositionSize(swigCPtr), true);
222 Rectangle ret = new Rectangle(val.X, val.Y, val.Width, val.Height );
228 Interop.GLWindow.GlWindow_SetPositionSize(swigCPtr, Rectangle.getCPtr(value));
233 /// Gets the count of supported auxiliary hints of the GLWindow.
235 /// <returns>The number of supported auxiliary hints.</returns>
236 [EditorBrowsable(EditorBrowsableState.Never)]
237 public uint GetSupportedAuxiliaryHintCount()
239 uint ret = Interop.GLWindow.GlWindow_GetSupportedAuxiliaryHintCount(swigCPtr);
240 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
245 /// Gets the supported auxiliary hint string of the GLWindow.
247 /// <param name="index">The index of the supported auxiliary hint lists.</param>
248 /// <returns>The auxiliary hint string of the index.</returns>
249 [EditorBrowsable(EditorBrowsableState.Never)]
250 public string GetSupportedAuxiliaryHint(uint index)
252 string ret = Interop.GLWindow.GlWindow_GetSupportedAuxiliaryHint(swigCPtr, index);
253 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
258 /// Creates an auxiliary hint of the GLWindow.
260 /// <param name="hint">The auxiliary hint string.</param>
261 /// <param name="value">The value string.</param>
262 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
263 [EditorBrowsable(EditorBrowsableState.Never)]
264 public uint AddAuxiliaryHint(string hint, string value)
266 uint ret = Interop.GLWindow.GlWindow_AddAuxiliaryHint(swigCPtr, hint, value);
267 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
272 /// Removes an auxiliary hint of the GLWindow.
274 /// <param name="id">The ID of the auxiliary hint.</param>
275 /// <returns>True if no error occurred, false otherwise.</returns>
276 [EditorBrowsable(EditorBrowsableState.Never)]
277 public bool RemoveAuxiliaryHint(uint id)
279 bool ret = Interop.GLWindow.GlWindow_RemoveAuxiliaryHint(swigCPtr, id);
280 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
285 /// Changes a value of the auxiliary hint.
287 /// <param name="id">The auxiliary hint ID.</param>
288 /// <param name="value">The value string to be set.</param>
289 /// <returns>True if no error occurred, false otherwise.</returns>
290 [EditorBrowsable(EditorBrowsableState.Never)]
291 public bool SetAuxiliaryHintValue(uint id, string value)
293 bool ret = Interop.GLWindow.GlWindow_SetAuxiliaryHintValue(swigCPtr, id, value);
294 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
299 /// Gets a value of the auxiliary hint.
301 /// <param name="id">The auxiliary hint ID.</param>
302 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
303 [EditorBrowsable(EditorBrowsableState.Never)]
304 public string GetAuxiliaryHintValue(uint id)
306 string ret = Interop.GLWindow.GlWindow_GetAuxiliaryHintValue(swigCPtr, id);
307 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
312 /// Gets an ID of the auxiliary hint string.
314 /// <param name="hint">The auxiliary hint string.</param>
315 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
316 [EditorBrowsable(EditorBrowsableState.Never)]
317 public uint GetAuxiliaryHintId(string hint)
319 uint ret = Interop.GLWindow.GlWindow_GetAuxiliaryHintId(swigCPtr, hint);
320 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
325 /// Sets a region to accept input events.
327 /// <param name="inputRegion">The region to accept input events.</param>
328 [EditorBrowsable(EditorBrowsableState.Never)]
329 public void SetInputRegion(Rectangle inputRegion)
331 Interop.GLWindow.GlWindow_SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
332 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
336 /// Sets a transparent window's visual state to opaque. <br />
337 /// If a visual state of a transparent window is opaque, <br />
338 /// then the window manager could handle it as an opaque window when calculating visibility.
340 /// <param name="opaque">Whether the window's visual state is opaque.</param>
341 /// <remarks>This will have no effect on an opaque window. <br />
342 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
344 [EditorBrowsable(EditorBrowsableState.Never)]
345 public void SetOpaqueState(bool opaque)
347 Interop.GLWindow.GlWindow_SetOpaqueState(swigCPtr, opaque);
348 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
352 /// Returns whether a transparent window's visual state is opaque or not.
354 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
355 /// <remarks> The return value has no meaning on an opaque window. </remarks>
356 [EditorBrowsable(EditorBrowsableState.Never)]
357 public bool IsOpaqueState()
359 bool ret = Interop.GLWindow.GlWindow_IsOpaqueState(swigCPtr);
360 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
365 /// Sets a preferred orientation.
367 /// <param name="orientation">The preferred orientation.</param>
368 [EditorBrowsable(EditorBrowsableState.Never)]
369 public void SetPreferredOrientation(GLWindow.GLWindowOrientation orientation)
371 Interop.GLWindow.GlWindow_SetPreferredOrientation(swigCPtr, (int)orientation);
372 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
376 /// Gets current orientation of the window.
378 /// <returns>The current window orientation if previously set, or none.</returns>
379 [EditorBrowsable(EditorBrowsableState.Never)]
380 public GLWindow.GLWindowOrientation GetCurrentOrientation()
382 GLWindow.GLWindowOrientation ret = (GLWindow.GLWindowOrientation)Interop.GLWindow.GlWindow_GetCurrentOrientation(swigCPtr);
383 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
388 /// Sets available orientations of the window.
389 /// This API is for setting several orientations one time.
391 /// <param name="orientations">The list of orientations.</param>
392 [EditorBrowsable(EditorBrowsableState.Never)]
393 public void SetAvailableOrientations(List<GLWindow.GLWindowOrientation> orientations)
395 PropertyArray orientationArray = new PropertyArray();
396 for (int i = 0; i < orientations.Count; i++)
398 orientationArray.PushBack(new PropertyValue((int)orientations[i]));
401 Interop.GLWindow.GlWindow_SetAvailableOrientations(swigCPtr, PropertyArray.getCPtr(orientationArray), orientations.Count);
402 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
406 /// Allows at least one more render, even when paused.
407 /// The window should be shown, not minimised.
409 [EditorBrowsable(EditorBrowsableState.Never)]
410 public void RenderOnce()
412 Interop.GLWindow.GlWindow_RenderOnce(swigCPtr);
413 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
417 /// Type of callback to initialize native GL code.
419 [EditorBrowsable(EditorBrowsableState.Never)]
420 public delegate void GLInitializeCallbackType();
422 GLInitializeCallbackType GLInitializeCallback;
423 HandleRef InitHandleRef;
426 /// Type of callback to render to frame to use native GL code.
428 [EditorBrowsable(EditorBrowsableState.Never)]
429 public delegate int GLRenderFrameCallbackType();
431 GLRenderFrameCallbackType GLRenderFrameCallback;
432 HandleRef RenderHandlerRef;
436 /// Type of callback to cleanup native GL resource.
438 [EditorBrowsable(EditorBrowsableState.Never)]
439 public delegate void GLTerminateCallbackType();
441 GLTerminateCallbackType GLTerminateCallback;
442 HandleRef TerminateHandlerRef;
445 /// Registers a GL callback function for application.
447 /// <param name="glInit">The callback function for application initialize</param>
448 /// <param name="glRenderFrame">The callback function to render to the frame</param>
449 /// <param name="glTerminate">The callback function to clean-up application GL resource</param>
450 [EditorBrowsable(EditorBrowsableState.Never)]
451 public void RegisterGlCallback( GLInitializeCallbackType glInit, GLRenderFrameCallbackType glRenderFrame, GLTerminateCallbackType glTerminate )
453 GLInitializeCallback = glInit;
454 InitHandleRef = new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(GLInitializeCallback));
456 GLRenderFrameCallback = glRenderFrame;
457 RenderHandlerRef = new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(GLRenderFrameCallback));
459 GLTerminateCallback = glTerminate;
460 TerminateHandlerRef = new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(GLTerminateCallback));
462 Interop.GLWindow.GlWindow_RegisterGlCallback(swigCPtr, InitHandleRef, RenderHandlerRef, TerminateHandlerRef);
464 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
468 /// Destroy the window immediately.
470 [EditorBrowsable(EditorBrowsableState.Never)]
471 public void Destroy()
477 /// Dispose for Window
479 protected override void Dispose(DisposeTypes type)
486 this.DisconnectNativeSignals();
491 /// This will not be public opened.
492 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
494 Interop.Window.delete_Window(swigCPtr);