All Projects → SupinePandora43 → UltralightNet

SupinePandora43 / UltralightNet

Licence: other
.NET bindings for Ultralight next-gen HTML renderer

Programming Languages

C#
18002 projects
javascript
184084 projects - #8 most used programming language
GLSL
2045 projects
CSS
56736 projects
HTML
75241 projects
Batchfile
5799 projects

Projects that are alternatives of or similar to UltralightNet

scala-native-bindgen
Scala Native Binding Generator
Stars: ✭ 29 (+0%)
Mutual labels:  bindings
ripeatlas
Go bindings for RIPE Atlas API
Stars: ✭ 12 (-58.62%)
Mutual labels:  bindings
kdb nim
Nim Kdb type-safe bindings
Stars: ✭ 13 (-55.17%)
Mutual labels:  bindings
x264-rs
x264 bindings
Stars: ✭ 32 (+10.34%)
Mutual labels:  bindings
interop
Python/C/Go/Rust/Haskell interop examples
Stars: ✭ 24 (-17.24%)
Mutual labels:  bindings
kindaVim.theapp
Ultimate Vim Mode for macOS
Stars: ✭ 372 (+1182.76%)
Mutual labels:  bindings
crystal-autobind
Automatic C bindings generator for Crystal
Stars: ✭ 15 (-48.28%)
Mutual labels:  bindings
sources-for-knative
VMware-related event sources for Knative.
Stars: ✭ 24 (-17.24%)
Mutual labels:  bindings
vsphere-automation-sdk-.net
[DEPRECATED] Please see README. C# samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API
Stars: ✭ 67 (+131.03%)
Mutual labels:  bindings
NModbus4.NetCore
Simply NModbus4 but targeting .NET instead of .NET Framework
Stars: ✭ 25 (-13.79%)
Mutual labels:  net5
OpenGL.NET
This repository contains low-level bindings for OpenGL and OpenGLES used in Evergine.
Stars: ✭ 29 (+0%)
Mutual labels:  bindings
simdjson-rust
Rust bindings for the simdjson project.
Stars: ✭ 59 (+103.45%)
Mutual labels:  bindings
libandroidjni
Android JNI bindings library
Stars: ✭ 66 (+127.59%)
Mutual labels:  bindings
webgl-raub
WebGL bindings to desktop OpenGL
Stars: ✭ 66 (+127.59%)
Mutual labels:  bindings
wlroots-ocaml
OCaml bindings to wlroots [experimental]
Stars: ✭ 24 (-17.24%)
Mutual labels:  bindings
nuklear4j
Java binding for nuklear
Stars: ✭ 61 (+110.34%)
Mutual labels:  bindings
cl-liballegro
Common Lisp bindings and interface to the Allegro 5 game programming library
Stars: ✭ 44 (+51.72%)
Mutual labels:  bindings
raylib-zig
Manually tweaked, auto generated raylib bindings for zig. https://github.com/raysan5/raylib
Stars: ✭ 122 (+320.69%)
Mutual labels:  bindings
pkcs11
OCaml bindings for the PKCS#11 cryptographic API
Stars: ✭ 21 (-27.59%)
Mutual labels:  bindings
Tomlet
Zero-Dependency, model-based TOML De/Serializer for .NET
Stars: ✭ 56 (+93.1%)
Mutual labels:  net5

UltralightNet

NuGet Build & Test codecov

Ultralight .NET bindings

Table of Content

Supported platforms

NOTE: ultralight supports only x64 processors NOTE: At that time, ultralight doesn't support arm. (eg. Android phones or macs on M1)

  • Windows
  • Linux
  • OSX

Supported frameworks

  • .Net >= 5.0
  • .Net Framework >= 4.5
  • .Net Standard >= 2.0

UltralightSharp

UltralightNet was a fork of UltralightSharp. But it was too complicated for me to update generated bindings. So i decided to rewrite it from scratch.

Differences

Packages

  • UltralightNet.Binaries is UltralightSharp.Core.LinuxX64, UltralightSharp.Core.OsxX64 and UltralightSharp.Core.WinX64 at same time.
  • UltralightNet.Binaries doesn't contain AppCore binaries, they're in UltralightNet.AppCore
  • UltralightNet.Resources contains only resources folder, as UltralightSharp.Core

Code

UltralightSharp uses a lot of IL injection, UltralightNet doesn't.

name conflicts like System.String and ImpromptuNinjas.UltralightSharp.String: UltralightNet just adds UL prefix.

Managed (string) versions vs Unmanaged (ULString*) versions: UltralightSharp has two different namespaces for that, UltralightNet just adds _ prefix. Example: ULFileSystem.OpenFile and ULFileSystem._OpenFile (also _ULFileSystem.OpenFile for [UnmanagedCallersOnlyAttribute] scenario)

Marshaling: UltralightNet heavily relies on DllImportGenerator for Native interop, it lets us easily marshal values without NET's CustomMarshaler overhead.

Reporting issues

Getting Started

Nuget packages

you need to install at least:

  • UltralightNet
  • UltralightNet.Binaries
  • UltralightNet.AppCore because only AppCore provides font loader

to have fully functional Ultralight renderer

How to render a static page

  1. Set Logger (optional)
  2. Set Font Loader (or crash)
  3. Set FileSystem (used by ultralight to load "resources" folder content)
  4. Create renderer (configurable, using ULConfig)
  5. Create View (html page)
  6. Load page: Page (raw html string) or URL (requires UltralightNet.Resources package, and ULConfig.ResourcePath set to ./resources)
  7. Update renderer until page is loaded
  8. Render
  9. Get View's Surface
  10. Get Surface's Bitmap
  11. Swap Red and Blue channels
  12. Save bitmap to png file

Code

using System;
using System.IO;
using System.Threading;
using UltralightNet;
using UltralightNet.AppCore;

namespace UltralightNet.GettingStarted
{
	class Program
	{
		static void Main()
		{
			// Set Logger
			ULPlatform.SetLogger(new ULLogger()
			{
				LogMessage = (level, message) =>
				{
					Console.WriteLine($"({level}): {message}");
				}
			});

			// Set Font Loader
			AppCoreMethods.ulEnablePlatformFontLoader();

			// Set filesystem (Ultralight requires "resources/icudt67l.dat", and probably cacert.pem too)
			AppCoreMethods.ulEnablePlatformFileSystem(Path.GetDirectoryName(typeof(Program).Assembly.Location));

			// Create config, used for specifying resources folder (used for URL loading)
			ULConfig config = new();

			// Create Renderer
			Renderer renderer = new(config);

			// Create View
			View view = new(renderer, 512, 512);

			// Load URL

			bool loaded = false;

			view.SetFinishLoadingCallback((user_data, caller, frame_id, is_main_frame, url) =>
			{
				loaded = true;
			});

			view.URL = "https://github.com"; // Requires "UltralightNet.Resources"

			// Update Renderer until page is loaded
			while (!loaded)
			{
				renderer.Update();
				// sleep | give ultralight time to process network etc.
				Thread.Sleep(10);
			}

			// Render
			renderer.Render();

			// Get Surface
			ULSurface surface = view.Surface;

			// Get Bitmap
			ULBitmap bitmap = surface.Bitmap;

			// Swap Red and Blue channels
			bitmap.SwapRedBlueChannels();

			// save bitmap to png file
			bitmap.WritePng("./github.png");
		}
	}
}

Ready to run project

UltralightNet.GettingStarted

Result

github

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].