Edit

Share via


iPhoneOSGameView.CreateFrameBuffer Method

Definition

Creates the framebuffer so that OpenGL operations can be performed.

protected virtual void CreateFrameBuffer();
abstract member CreateFrameBuffer : unit -> unit
override this.CreateFrameBuffer : unit -> unit

Exceptions

ContextRenderingApi hasn't been initialized.

LayerColorFormat hasn't been initialized.

The instance has had Dispose(Boolean) invoked on it.

Remarks

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

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

<block subset="none" type="behaviors"> This method performs the following operations:

  1. Configure the Layer's DrawableProperties. LayerRetainsBacking is used to set the RetainedBacking property, while LayerColorFormat is used to set the ColorFormat property.
  2. ConfigureLayer(CAEAGLLayer) is invoked.
  3. The GraphicsContext is created, wihch in turns creates an EAGLContext. The EAGLContext can be retrieved through the EAGLContext property.
  4. A renderbuffer is created and bound to the GL context as the RenderbufferOes property. The renderbuffer is accessible via via Renderbuffer.
  5. RenderBufferStorage(nuint, 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 Framebuffer.
  7. The framebuffer and renderbuffer are bound together: GL.Oes.FramebufferRenderbuffer (All.FramebufferOes, All.ColorAttachment0Oes, All.RenderbufferOes, renderbuffer);
  8. Size is initialized based on the current Bounds value.
  9. GL.Viewport(0, 0, Size.Width, Size.Height) is invoked.
  10. GL.Scissor(0, 0, Size.Width, Size.Height) is invoked.
</block> <block subset="none" type="overrides">

Inheritors can override either ConfigureLayer(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 ContextRenderingApi if an error occurs. For example:

<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();
    }
}

</example> </block>

Applies to