add Dart/headless example
This commit is contained in:
4
examples/dart/cli_headless/.gitignore
vendored
Normal file
4
examples/dart/cli_headless/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# https://dart.dev/guides/libraries/private-files
|
||||||
|
# Created by `dart pub`
|
||||||
|
.dart_tool/
|
||||||
|
output/**
|
||||||
3
examples/dart/cli_headless/CHANGELOG.md
Normal file
3
examples/dart/cli_headless/CHANGELOG.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
## 1.0.0
|
||||||
|
|
||||||
|
- Initial version.
|
||||||
3
examples/dart/cli_headless/README.md
Normal file
3
examples/dart/cli_headless/README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# cli_headless
|
||||||
|
|
||||||
|
An example of Thermion running via Dart CLI with no hardware accelerated rendering surface.
|
||||||
30
examples/dart/cli_headless/analysis_options.yaml
Normal file
30
examples/dart/cli_headless/analysis_options.yaml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# This file configures the static analysis results for your project (errors,
|
||||||
|
# warnings, and lints).
|
||||||
|
#
|
||||||
|
# This enables the 'recommended' set of lints from `package:lints`.
|
||||||
|
# This set helps identify many issues that may lead to problems when running
|
||||||
|
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
|
||||||
|
# style and format.
|
||||||
|
#
|
||||||
|
# If you want a smaller set of lints you can change this to specify
|
||||||
|
# 'package:lints/core.yaml'. These are just the most critical lints
|
||||||
|
# (the recommended set includes the core lints).
|
||||||
|
# The core lints are also what is used by pub.dev for scoring packages.
|
||||||
|
|
||||||
|
include: package:lints/recommended.yaml
|
||||||
|
|
||||||
|
# Uncomment the following section to specify additional rules.
|
||||||
|
|
||||||
|
# linter:
|
||||||
|
# rules:
|
||||||
|
# - camel_case_types
|
||||||
|
|
||||||
|
# analyzer:
|
||||||
|
# exclude:
|
||||||
|
# - path/to/excluded/files/**
|
||||||
|
|
||||||
|
# For more information about the core and recommended set of lints, see
|
||||||
|
# https://dart.dev/go/core-lints
|
||||||
|
|
||||||
|
# For additional information about configuring this file, see
|
||||||
|
# https://dart.dev/guides/language/analysis-options
|
||||||
32
examples/dart/cli_headless/bin/example.dart
Normal file
32
examples/dart/cli_headless/bin/example.dart
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
import 'dart:isolate';
|
||||||
|
|
||||||
|
import 'package:thermion_dart/thermion_dart.dart';
|
||||||
|
import 'package:thermion_dart/src/filament/src/implementation/ffi_filament_app.dart';
|
||||||
|
|
||||||
|
void main() async {
|
||||||
|
await FFIFilamentApp.create();
|
||||||
|
final (width, height) = (500, 500);
|
||||||
|
final sc = await FilamentApp.instance!.createHeadlessSwapChain(width, height);
|
||||||
|
var viewer = ThermionViewerFFI();
|
||||||
|
await viewer.initialized;
|
||||||
|
|
||||||
|
await FilamentApp.instance!.register(sc, viewer.view);
|
||||||
|
|
||||||
|
await viewer.view.setFrustumCullingEnabled(false);
|
||||||
|
await viewer.setBackgroundColor(1, 0, 1, 1);
|
||||||
|
await viewer.setViewport(width, height);
|
||||||
|
final result = await FilamentApp.instance!.capture(
|
||||||
|
sc,
|
||||||
|
view: viewer.view,
|
||||||
|
);
|
||||||
|
|
||||||
|
final bitmap = await pixelBufferToBmp(result.first.$2, width, height,
|
||||||
|
hasAlpha: true, isFloat: true);
|
||||||
|
|
||||||
|
var outfile = File("output/render.bmp");
|
||||||
|
outfile.parent.create();
|
||||||
|
outfile.writeAsBytesSync(bitmap);
|
||||||
|
await FilamentApp.instance!.destroy();
|
||||||
|
Isolate.current.kill();
|
||||||
|
}
|
||||||
15
examples/dart/cli_headless/pubspec.yaml
Normal file
15
examples/dart/cli_headless/pubspec.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
name: example_cli
|
||||||
|
description: A sample command-line application.
|
||||||
|
version: 1.0.0
|
||||||
|
|
||||||
|
environment:
|
||||||
|
sdk: ^3.3.0
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
thermion_dart:
|
||||||
|
path: ../../../thermion_dart
|
||||||
|
|
||||||
|
dev_dependencies:
|
||||||
|
ffigen: ^11.0.0
|
||||||
|
lints: ^3.0.0
|
||||||
|
test: ^1.24.0
|
||||||
Reference in New Issue
Block a user