OpenGLView Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
A View that displays OpenGL content.
[Xamarin.Forms.RenderWith(typeof(Xamarin.Forms.Platform._OpenGLViewRenderer))]
public sealed class OpenGLView : Xamarin.Forms.View, Xamarin.Forms.IElementConfiguration<Xamarin.Forms.OpenGLView>, Xamarin.Forms.IOpenGlViewController
type OpenGLView = class
inherit View
interface IOpenGlViewController
interface IViewController
interface IVisualElementController
interface IElementController
interface IElementConfiguration<OpenGLView>
- Inheritance
- Attributes
- Implements
OpenGLViews are easiest to program using Shared Projects, in which case the reference to OpenTK is straightforward. The following example shows a simple OpenGL app with a render loop:
using Xamarin.Forms;
using OpenTK.Graphics.ES30;
namespace opengl
{
public class OpenGLPage : ContentPage
{
float red, green, blue;
public OpenGLPage ()
{
Title = "OpenGL";
var view = new OpenGLView { HasRenderLoop = true };
var toggle = new Switch { IsToggled = true };
var button = new Button { Text = "Display" };
view.HeightRequest = 300;
view.WidthRequest = 300;
view.OnDisplay = r => {
GL.ClearColor (red, green, blue, 1.0f);
GL.Clear ((ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit));
red += 0.01f;
if (red >= 1.0f)
red -= 1.0f;
green += 0.02f;
if (green >= 1.0f)
green -= 1.0f;
blue += 0.03f;
if (blue >= 1.0f)
blue -= 1.0f;
};
toggle.Toggled += (s, a) => {
view.HasRenderLoop = toggle.IsToggled;
};
button.Clicked += (s, a) => view.Display ();
var stack = new StackLayout {
Padding = new Size (20, 20),
Children = {view, toggle, button}
};
Content = stack;
}
}
}
Open |
Creates a new OpenGLView object with default values. |
Has |
Identifies the HasRenderLoop bindable property. |
AnchorX |
Gets or sets the X component of the center point for any transform, relative to the bounds of the element. This is a bindable property. (Inherited from VisualElement) |
AnchorY |
Gets or sets the Y component of the center point for any transform, relative to the bounds of the element. This is a bindable property. (Inherited from VisualElement) |
Automation |
Gets or sets a value that allows the automation framework to find and interact with this element. (Inherited from Element) |
Background | (Inherited from VisualElement) |
Background |
Gets or sets the color which will fill the background of a VisualElement. This is a bindable property. (Inherited from VisualElement) |
Batched |
For internal use by the Xamarin.Forms platform. (Inherited from VisualElement) |
Behaviors |
Gets the list of Behaviors associated to this element. This is a bindable property. (Inherited from VisualElement) |
Binding |
Gets or sets object that contains the properties that will be targeted by the bound properties that belong to this BindableObject. (Inherited from BindableObject) |
Bounds |
Gets the bounds of the element. (Inherited from VisualElement) |
class | (Inherited from NavigableElement) |
Class |
Gets or sets a value used to identify a collection of semantically similar elements. (Inherited from Element) |
Clip | (Inherited from VisualElement) |
Disable |
For internal use by the Xamarin.Forms platform. (Inherited from VisualElement) |
Dispatcher | (Inherited from BindableObject) |
Effect |
For internal use by the Xamarin.Forms platform. (Inherited from Element) |
Effects |
A list of the effects that are applied to this item. (Inherited from Element) |
Flow |
Gets or sets the layout flow direction. (Inherited from VisualElement) |
Gesture |
Gets the gesture controller for the view. (Inherited from View) |
Gesture |
The collection of gesture recognizers associated with this view. (Inherited from View) |
Has |
Whether this OpenGLView has a custom rendering loop. |
Height |
Gets the current rendered height of this element. This is a read-only bindable property. (Inherited from VisualElement) |
Height |
Gets or sets the desired height override of this element. (Inherited from VisualElement) |
Horizontal |
Gets or sets the LayoutOptions that define how the element gets laid in a layout cycle. This is a bindable property. (Inherited from View) |
Id |
Gets a value that can be used to uniquely identify an element through the run of an application. (Inherited from Element) |
Input |
Gets or sets a value indicating whether this element should be involved in the user interaction cycle. This is a bindable property. (Inherited from VisualElement) |
Is |
Gets or sets a value indicating whether this element is enabled in the user interface. This is a bindable property. (Inherited from VisualElement) |
Is |
Gets a value indicating whether this element is focused currently. This is a bindable property. (Inherited from VisualElement) |
Is |
For internal use by the Xamarin.Forms platform. (Inherited from VisualElement) |
Is |
For internal use by the Xamarin.Forms platform. (Inherited from VisualElement) |
Is |
For internal use by the Xamarin.Forms platform. (Inherited from VisualElement) |
Is |
Gets or sets a value that indicates whether this element is included in tab navigation. This is a bindable property. (Inherited from VisualElement) |
Is |
Gets or sets a value that determines whether this elements should be part of the visual tree or not. This is a bindable property. (Inherited from VisualElement) |
Logical |
For internal use by the Xamarin.Forms platform. (Inherited from Element) |
Margin |
Gets or sets the margin for the view. (Inherited from View) |
Minimum |
Gets or sets a value which overrides the minimum height the element will request during layout. (Inherited from VisualElement) |
Minimum |
Gets or sets a value which overrides the minimum width the element will request during layout. (Inherited from VisualElement) |
Navigation | (Inherited from NavigableElement) |
Navigation |
(Inherited from NavigableElement) |
On |
Overridden to create a custom rendering loop. |
Opacity |
Gets or sets the opacity value applied to the element when it is rendered. This is a bindable property. (Inherited from VisualElement) |
Parent |
Gets or sets the parent element of the element. (Inherited from Element) |
Parent |
Obsolete.
Gets the element which is the closest ancestor of this element that is a VisualElement. (Inherited from Element) |
Platform |
Obsolete.
(Inherited from Element)
|
Real |
For internal use by the Xamarin.Forms platform. (Inherited from Element) |
Resources |
Gets or sets the local resource dictionary. (Inherited from VisualElement) |
Rotation |
Gets or sets the rotation (in degrees) about the Z-axis (affine rotation) when the element is rendered. (Inherited from VisualElement) |
RotationX |
Gets or sets the rotation (in degrees) about the X-axis (perspective rotation) when the element is rendered. (Inherited from VisualElement) |
RotationY |
Gets or sets the rotation (in degrees) about the Y-axis (perspective rotation) when the element is rendered. (Inherited from VisualElement) |
Scale |
Gets or sets the scale factor applied to the element. (Inherited from VisualElement) |
ScaleX |
Gets or sets a scale value to apply to the X direction. (Inherited from VisualElement) |
ScaleY |
Gets or sets a scale value to apply to the Y direction. (Inherited from VisualElement) |
Style | (Inherited from NavigableElement) |
Style |
(Inherited from NavigableElement) |
Style |
Gets or sets a user defined value to uniquely identify the element. (Inherited from Element) |
Tab |
(Inherited from VisualElement) |
TranslationX |
Gets or sets the X translation delta of the element. (Inherited from VisualElement) |
TranslationY |
Gets or sets the Y translation delta of the element. (Inherited from VisualElement) |
Triggers |
Gets the list of Trigger associated to this element. This is a bindable property. (Inherited from VisualElement) |
Vertical |
Gets or sets the LayoutOptions that define how the element gets laid in a layout cycle. This is a bindable property. (Inherited from View) |
Visual | (Inherited from VisualElement) |
Width |
Gets the current rendered width of this element. This is a read-only bindable property. (Inherited from VisualElement) |
Width |
Gets or sets the desired width override of this element. (Inherited from VisualElement) |
X |
Gets the current X position of this element. This is a read-only bindable property. (Inherited from VisualElement) |
Y |
Gets the current Y position of this element. This is a read-only bindable property. (Inherited from VisualElement) |
Apply |
Apply the bindings to BindingContext. (Inherited from BindableObject) |
Batch |
Signals the start of a batch of changes to the elements properties. (Inherited from VisualElement) |
Batch |
Signals the end of a batch of commands to the element and that those commands should now be committed. (Inherited from VisualElement) |
Change |
For internal use by the Xamarin.Forms platform. (Inherited from VisualElement) |
Clear |
Clears any value set by SetValue for |
Clear |
Clears any value set by SetValue for the property that is identified by |
Coerce |
(Inherited from BindableObject) |
Coerce |
(Inherited from BindableObject) |
Descendants() |
For internal use by the Xamarin.Forms platform. (Inherited from Element) |
Display() |
Called prior to rendering. |
Effect |
For internal use by the Xamarin.Forms platform. (Inherited from Element) |
Find |
Returns the element that has the specified name. (Inherited from Element) |
Focus() |
Attemps to set focus to this element. (Inherited from VisualElement) |
Get |
Returns the child elements that are visually beneath the specified |
Get |
Obsolete.
Returns the SizeRequest of the element. Calling this method begins the measure pass of a layout cycle. (Inherited from VisualElement) |
Get |
Returns the value that is contained in the BindableProperty. (Inherited from BindableObject) |
Get |
Obsolete.
For internal use by the Xamarin.Forms platform. (Inherited from BindableObject) |
Get |
Obsolete.
For internal use by the Xamarin.Forms platform. (Inherited from BindableObject) |
Invalidate |
Method that is called to invalidate the layout of this VisualElement. Raises the MeasureInvalidated event. (Inherited from VisualElement) |
Invalidate |
For internal use by the Xamarin.Forms platform. (Inherited from VisualElement) |
Is |
Returns |
Layout(Rectangle) |
Updates the bounds of the element during the layout cycle. (Inherited from VisualElement) |
Measure(Double, Double, Measure |
Returns the minimum size that a visual element needs in order to be displayed on the device. (Inherited from VisualElement) |
Native |
For internal use by the Xamarin.Forms platform. (Inherited from VisualElement) |
On<T>() |
Returns the platform-specific instance of this OpenGLView, on which a platform-specific method may be called. |
On |
Invoked whenever the binding context of the View changes. Override this method to add class handling for this event. (Inherited from View) |
On |
Application developers can override this method to respond when a child is added. (Inherited from VisualElement) |
On |
(Inherited from VisualElement) |
On |
Obsolete.
Application developers can override this method to respond when a child is removed. (Inherited from VisualElement) |
On |
Invoked whenever the ChildrenReordered event is about to be emitted. Implement this method to add class handling for this event. (Inherited from VisualElement) |
On |
Method that is called when a layout measurement happens. (Inherited from VisualElement) |
On |
(Inherited from NavigableElement) |
On |
Method that is called when a bound property is changed. (Inherited from Element) |
On |
Call this method from a child class to notify that a change is going to happen on a property. (Inherited from BindableObject) |
On |
This method is called when the size of the element is set during a layout cycle. This method is called directly before the SizeChanged event is emitted. Implement this method to add class handling for this event. (Inherited from VisualElement) |
On |
Obsolete.
This method is called during the measure pass of a layout cycle to get the desired size of an element. (Inherited from VisualElement) |
On |
(Inherited from VisualElement) |
On |
(Inherited from VisualElement) |
Remove |
Removes a previously set binding. (Inherited from BindableObject) |
Remove |
Removes a previously set dynamic resource (Inherited from Element) |
Set |
Assigns a binding to a property. (Inherited from BindableObject) |
Set |
Sets the BindableProperty property of this element to be updated via the DynamicResource with the provided key. (Inherited from Element) |
Set |
Sets the value of the specified property. (Inherited from BindableObject) |
Set |
Sets the value of the propertyKey. (Inherited from BindableObject) |
Set |
For internal use by the Xamarin.Forms platform. (Inherited from BindableObject) |
Set |
For internal use by the Xamarin.Forms platform. (Inherited from Element) |
Set |
For internal use by the Xamarin.Forms platform. (Inherited from Element) |
Size |
SizeAllocated is called during a layout cycle to signal the start of a sub-tree layout. (Inherited from VisualElement) |
Tab |
(Inherited from VisualElement) |
Tab |
(Inherited from VisualElement) |
Unapply |
Unapplies all previously set bindings. (Inherited from BindableObject) |
Unfocus() |
Unsets focus to this element. (Inherited from VisualElement) |
Batch |
For internal use by the Xamarin.Forms platform. (Inherited from VisualElement) |
Binding |
Raised whenever the BindingContext property changes. (Inherited from BindableObject) |
Child |
Occurs whenever a child element is added to the element. (Inherited from Element) |
Child |
Occurs whenever a child element is removed from the element. (Inherited from Element) |
Children |
Occurs when the Children of a VisualElement have been re-ordered. (Inherited from VisualElement) |
Descendant |
Occurs whenever a child element is added to the elements subtree. (Inherited from Element) |
Descendant |
Occurs whenever a child element is removed from the elements subtree. (Inherited from Element) |
Display |
For internal use by the Xamarin.Forms platform. |
Focus |
For internal use by the Xamarin.Forms platform. (Inherited from VisualElement) |
Focused |
Occurs when the element receives focus. (Inherited from VisualElement) |
Measure |
Event that is raised when the layout of a visual element is invalidated. (Inherited from VisualElement) |
Platform |
Obsolete.
(Inherited from Element)
|
Property |
Raised when a property has changed. (Inherited from BindableObject) |
Property |
Raised when a property is about to change. (Inherited from BindableObject) |
Size |
Occurs when either the Width or the Height properties change value on this element. (Inherited from VisualElement) |
Unfocused |
Occurs when the element loses focus. (Inherited from VisualElement) |
IDynamic |
For internal use by the Xamarin.Forms platform. (Inherited from BindableObject) |
IElement |
For internal use by the Xamarin.Forms platform. (Inherited from Element) |
IGesture |
For internal use by the Xamarin.Forms platform. (Inherited from View) |
IName |
For internal use only. (Inherited from Element) |
IVisual |
Gets the effective visual flow direction for the element on the platform, taking into account the locale and logical flow settings. (Inherited from VisualElement) |
IVisual |
This method is for internal use. (Inherited from VisualElement) |