Platform Integration
Native presentation surfaces
Surface description, which it uses to create a SwapChain. The application remains responsible for the operating-system window.
|
|
|
|
|---|---|---|
Win32
|
HWND
|
|
Wayland
|
|
|
Xlib
|
|
|
Android
|
ANativeWindow
|
|
Apple
|
CAMetalLayer
|
|
Surface.Wayland.
Swap-chain dimensions and lifetime
SwapChain.Drawable for each frame: the swap chain owns this texture and may replace it after presentation or resizing.
SwapChain.Resize. To replace the native presentation target, pass its new surface description and handles to SwapChain.Refresh after those uses finish. At shutdown, release the swap chain before destroying its native presentation target.
Rendering through a UI control
IZenithView. The application assigns GraphicsContext, updates scene data in UpdateRequested, and records commands in RenderRequested using the supplied RenderEventArgs.
ColorAttachment, and calls the update and render handlers. It then submits the recorded work and presents the image using the framework's presentation mechanism.
using Zenith.NET; to the file. For an initialized IZenithView named view with a graphics context assigned, register this handler to clear its drawable:
view.RenderRequested += (_, args) =>
{
args.CommandBuffer.BeginRenderPass([ColorAttachment.Clear(args.Drawable, new(0.04f, 0.055f, 0.075f, 1.0f))], null);
args.CommandBuffer.EndRenderPass();
};
ColorAttachment before returning so the control can perform its final transition.
Undefined, which allows the previous image contents to be discarded. Draw or clear the full image on each frame. Keep accumulated or cached rendering in an application-owned texture, then draw that texture into the control's drawable.
ZenithViewHelper.DrawableFormat provides the default color format used by these integrations.
Desc.Width, Desc.Height, Desc.Format, and Desc.SampleCount from the drawable supplied by the render event when creating matching attachments. The event texture gives the render target's actual dimensions; they should not be inferred from the control's layout size or display scale.
Framework and presentation path
|
|
|
|---|---|
|
|
WriteableBitmap. See ZenithView.cs and Surface.cs. |
|
|
HWND. See ZenithView.cs. |
|
|
D3DImage. See Surface.cs. |
|
|
SwapChainPanel. See ZenithView.WinUI.cs. |
|
|
WriteableBitmap. See ZenithView.Uno.cs. |
|
|
|
RenderRequested event, when choosing an integration.
Zenith.NET.Views.Avalonia.
UseZenithView, as shown in Extensions.cs.
Application and control ownership
GraphicsContext changes, the scheduler recreates the control's resources for the new context. Recreate the application's pipelines, buffers, and textures for that context as well.