OpenTK.Platform.iPhoneOS.iPhoneOSGameView.CreateFrameBuffer Method
Creates the framebuffer so that OpenGL operations can be performed.

Syntax

protected virtual void CreateFrameBuffer ()

Exceptions

TypeReason
ArgumentExceptioniPhoneOSGameView.ContextRenderingApi hasn't been initialized.
InvalidOperationExceptioniPhoneOSGameView.LayerColorFormat hasn't been initialized.
ObjectDisposedException The instance has had Foundation.NSObject.Dispose invoked on it.

Remarks

This method is invoked to create an OpenTK.Graphics.IGraphicsContext implementation, create a OpenGLES.EAGLContext, and initialize the GL context so that a framebuffer and renderbuffer exist for future GL calls.

This method is invoked by: iPhoneOSGameView.LayoutSubviews, iPhoneOSGameView.Run, and iPhoneOSGameView.Run(double).

Operation
This method performs the following operations:
  1. Configure the UIKit.UIView.Layer's CoreAnimation.CAEAGLLayer.DrawableProperties. iPhoneOSGameView.LayerRetainsBacking is used to set the OpenGLES.EAGLDrawableProperty.RetainedBacking property, while iPhoneOSGameView.LayerColorFormat is used to set the OpenGLES.EAGLDrawableProperty.ColorFormat property.
  2. iPhoneOSGameView.ConfigureLayer(CoreAnimation.CAEAGLLayer) is invoked.
  3. The iPhoneOSGameView.GraphicsContext is created, wihch in turns creates an OpenGLES.EAGLContext. The EAGLContext can be retrieved through the iPhoneOSGameView.EAGLContext property.
  4. A renderbuffer is created and bound to the GL context as the RenderbufferOes property. The renderbuffer is accessible via via iPhoneOSGameView.Renderbuffer.
  5. OpenGLES.EAGLContext.RenderBufferStorage(nuint, CoreAnimation.CAEAGLLayer) is invoked to bind the above renderbuffer to EAGLContext.
  6. A framebuffer is created and bound to the GL context as the FramebufferOes property. The framebuffer is accessible via iPhoneOSGameView.Framebuffer.
  7. The framebuffer and renderbuffer are bound together: GL.Oes.FramebufferRenderbuffer (All.FramebufferOes, All.ColorAttachment0Oes, All.RenderbufferOes, renderbuffer);
  8. iPhoneOSGameView.Size is initialized based on the current UIKit.UIView.Bounds value.
  9. GL.Viewport(0, 0, Size.Width, Size.Height) is invoked.
  10. GL.Scissor(0, 0, Size.Width, Size.Height) is invoked.
Note to Inheritors

Inheritors can override either iPhoneOSGameView.ConfigureLayer(CoreAnimation.CAEAGLLayer), or this method to add additional construction logic (e.g. to add a depth buffer). If only the layer needs to be configured, then override ConfigureLayer; otherwise, override this method and call this implementation to create the framebuffer and renderbuffer.

Intelligent OpenGLES fallback can be performed by changing the iPhoneOSGameView.ContextRenderingApi if an error occurs. For example:

C# Example

protected override CreateFrameBuffer()
{
    try {
        ContextRenderingApi = EAGLRenderingAPI.OpenGLES2;
        base.CreateFrameBuffer();
    } catch (Exception) {
        // device doesn't support OpenGLES 2.0; retry with 1.1:
        ContextRenderingApi = EAGLRenderingAPI.OpenGLES1;
        base.CreateFrameBuffer();
    }
}
				

Requirements

Namespace: OpenTK.Platform.iPhoneOS
Assembly: OpenTK-1.0 (in OpenTK-1.0.dll)
Assembly Versions: 0.0.0.0