Feature: Add MauiZenithView for iOS and MacCatalyst#17
Merged
Conversation
Added a new .NET MAUI project, Sandbox.Maui, targeting Android, iOS, MacCatalyst, and Windows. The project demonstrates integration of Zenith.NET graphics rendering within a MAUI UI, including a sample page with a counter and a ZenithView. Platform-specific startup/configuration files, app icons, splash screens, images, and fonts were included. Added resource dictionaries for colors and styles, and documentation for asset management. Project references to Zenith.NET graphics backends and Zenith.NET.Views.Maui were established.
Changed render pass options to clear all buffers by setting Depth to 1.0, Stencil to 0, and Flags to ClearFlags.All, ensuring color, depth, and stencil buffers are cleared at the start of each render pass.
Implement CAMetalLayer and swapchain management for MauiZenithView on both iOS and MacCatalyst. This includes dynamic swapchain creation, resizing, and presentation, as well as updated pixel formats for color and depth-stencil attachments. Rendering is now performed only when the graphics context and view size are valid, improving resource management and enabling efficient Metal-based rendering.
Added using directives for Foundation and ObjCRuntime in MauiZenithView.cs to enable access to Apple platform-specific types and functionality. This prepares the file for features or integrations that rely on these namespaces.
Removed OS-specific graphics context selection in App.xaml.cs to always use Vulkan. Added animated HSV color gradient background in MainPage.xaml.cs by incrementing hue on each render and converting HSV to Vector4. Added System.Numerics import for Vector4 support.
Deleted the entire Sandbox.Maui experimental MAUI application, including its project file, source code, platform-specific files, resources, and configuration. Also removed its reference from the solution file. This cleans up the repository by eliminating the MAUI sample app and all associated assets.
The XML declaration at the top of Zenith.NET.slnx was removed or replaced. No changes were made to the solution structure or project references.
Centralize color and depth/stencil pixel format selection in a new ZenithViewHelper class, replacing hardcoded formats throughout the codebase. Update all platform backends to use these helper properties, add conversion utilities as needed, and adjust Uno backend stream writing for correct byte order. This improves consistency, maintainability, and cross-platform support.
Replace static Convert methods with ColorFormat(), which uses ZenithViewHelper.ColorTargetFormat directly. This centralizes and simplifies color/pixel format handling for surfaces and textures, and updates error messages to reference the global format.
Moved property initialization for ColorTargetFormat and DepthStencilTargetFormat from the static constructor to inline expression-bodied properties. This removes the need for a static constructor and improves code clarity and conciseness.
Updated the package version from 0.0.4 to 0.0.5 in NuGet.Packaging.props. No other metadata or configuration changes were made.
Renamed `ColorTargetFormat` to `ColorFormat` and `DepthStencilTargetFormat` to `DepthStencilFormat` in `ZenithViewHelper`. Updated all usages across the codebase, including texture creation, swap chain setup, pixel format switching, and output configuration. This improves naming consistency and makes the property names more descriptive.
Updated EnsureResources to validate both width and height are non-zero before proceeding, correcting a previous logic error. Also added a missing closing brace to properly terminate the MauiZenithView class.
Simplified the loop structure for handling PixelFormat.R8G8B8A8UNorm by removing a redundant outer loop. Now, pixel data is written per row with a single loop over x inside the y loop, improving clarity without changing the pixel writing logic.
Refactored the LayerClass method to use C# target-typed new for creating the Class object, improving code conciseness and readability. No functional changes were made.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors the handling of color and depth-stencil formats throughout the Zenith.NET view implementations for Avalonia, MAUI (Android, iOS, MacCatalyst, Windows), WPF, WinForms, and WinUI. The main change is to centralize format selection using the new
ZenithViewHelper.ColorFormatandZenithViewHelper.DepthStencilFormatproperties, replacing hardcoded pixel formats. This enables easier support for multiple formats and improves maintainability and platform consistency. Additionally, helper methods are added to map internal formats to platform-specific representations, and several platform view classes are streamlined by removing redundant staticOutputproperties.Centralized Format Selection
ZenithViewHelper.ColorFormatandZenithViewHelper.DepthStencilFormatacross all supported platforms (Surface.cs,MauiZenithView.cs,D3DTexture.cs,ZenithView.Uno.cs, etc.). [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]Platform-Specific Format Mapping
ColorFormat()) in platform-specific files to convertZenithViewHelper.ColorFormatto the appropriate pixel format for Avalonia, Direct3D, DXGI, etc., with error handling for unsupported formats. [1] [2] [3]Removal of Redundant Static Output Properties
Outputproperties from view classes for all platforms (Avalonia, MAUI, WPF, WinForms), as format selection is now handled dynamically throughZenithViewHelper. [1] [2] [3] [4] [5] [6]Platform View Refactoring and Improvements
Version Bump
0.0.4to0.0.5inNuGet.Packaging.props.