//********************************** Banshee Engine (www.banshee3d.com) **************************************************// //**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************// using System; using System.Runtime.CompilerServices; namespace BansheeEngine { /** @addtogroup GUI_Engine * @{ */ /// /// Allows you to display a render texture in the GUI. Has the same functionality as GUITexture, but also forwards any /// input to underlying GUI elements being rendered on the provided render texture. /// public sealed class GUIRenderTexture : GUIElement { private RenderTexture renderTexture; /// /// Render texture that is displayed on the GUI element. /// public RenderTexture RenderTexture { get { return renderTexture; } set { IntPtr texturePtr = IntPtr.Zero; if (value != null) texturePtr = value.GetCachedPtr(); renderTexture = value; Internal_SetTexture(mCachedPtr, texturePtr); } } /// /// Creates a new render texture element. /// /// Render texture to display in the element. /// Determines should the texture be rendered with transparency active. /// Optional style to use for the element. Style controls the look of the element, as well as /// default layout options. Style will be retrieved from the active GUISkin. If not specified /// default element style is used. /// Options that allow you to control how is the element positioned and sized. This will /// override any similar options set by style. public GUIRenderTexture(RenderTexture texture, bool transparent, string style, params GUIOption[] options) { IntPtr texturePtr = IntPtr.Zero; if (texture != null) texturePtr = texture.GetCachedPtr(); Internal_CreateInstance(this, texturePtr, transparent, style, options); } /// /// Creates a new render texture element. /// /// Render texture to display in the element. /// Determines should the texture be rendered with transparency active. /// Options that allow you to control how is the element positioned and sized. This will /// override any similar options set by style. public GUIRenderTexture(RenderTexture texture, bool transparent, params GUIOption[] options) { IntPtr texturePtr = IntPtr.Zero; if (texture != null) texturePtr = texture.GetCachedPtr(); Internal_CreateInstance(this, texturePtr, transparent, "", options); } /// /// Creates a new render texture element. /// /// Render texture to display in the element. /// Optional style to use for the element. Style controls the look of the element, as well as /// default layout options. Style will be retrieved from the active GUISkin. If not specified /// default element style is used. /// Options that allow you to control how is the element positioned and sized. This will /// override any similar options set by style. public GUIRenderTexture(RenderTexture texture, string style, params GUIOption[] options) { IntPtr texturePtr = IntPtr.Zero; if (texture != null) texturePtr = texture.GetCachedPtr(); Internal_CreateInstance(this, texturePtr, false, style, options); } /// /// Creates a new render texture element. /// /// Render texture to display in the element. /// Options that allow you to control how is the element positioned and sized. This will /// override any similar options set by style. public GUIRenderTexture(RenderTexture texture, params GUIOption[] options) { IntPtr texturePtr = IntPtr.Zero; if (texture != null) texturePtr = texture.GetCachedPtr(); Internal_CreateInstance(this, texturePtr, false, "", options); } /// /// Colors the element with a specific tint. /// /// Tint to apply to the element. public void SetTint(Color color) { Internal_SetTint(mCachedPtr, ref color); } [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_CreateInstance(GUIRenderTexture instance, IntPtr texture, bool transparency, string style, GUIOption[] options); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_SetTexture(IntPtr nativeInstance, IntPtr texture); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_SetTint(IntPtr nativeInstance, ref Color color); } /** @} */ }