v0.5.2
flutter_gpu_shaders
Build tools for Flutter GPU shader bundles/libraries.
21लाइक 77.7 हज़ार30-दिन डाउनलोड150Pub अंक
AndroidiOSLinuxmacOSWindows
Build tools for Flutter GPU shader bundles/libraries.
यह अंग्रेज़ी मूल स्नैपशॉट है। नवीनतम सामग्री GitHub पर देखें।
Build tools for Flutter GPU shader bundles/libraries.
Use native asset build hooks to import Flutter GPU shader bundle assets.
shaders/my_cool_shader.vert and shaders/my_cool_shader.frag..shaderbundle.json. For this example, we'll assume the following file is saved as my_cool_bundle.shaderbundle.json:{
"CoolVertex": {
"type": "vertex",
"file": "shaders/my_cool_shader.vert"
},
"CoolFragment": {
"type": "fragment",
"file": "shaders/my_cool_shader.frag"
}
}
buildShaderBundleJson. The build hook must be named hook/build.dart in your project; this script will be automatically invoked by Flutter:import 'package:hooks/hooks.dart';
import 'package:flutter_gpu_shaders/build.dart';
void main(List<String> args) async {
await build(args, (config, output) async {
await buildShaderBundleJson(
buildInput: config,
buildOutput: output,
manifestFileName: 'my_cool_bundle.shaderbundle.json');
});
}
buildShaderBundleJson always declares the manifest and directly listed
shader files as build dependencies. With Flutter SDKs whose impellerc
supports --depfile for shader bundles, it also declares transitive
#include dependencies from the generated depfile. Older impellerc
builds continue to use the manifest scan fallback.pubspec.yaml, add the built shader bundle as an asset:flutter:
assets:
- build/shaderbundles/my_cool_bundle.shaderbundle
pubspec.yaml:await buildShaderBundleJson(
buildInput: config,
buildOutput: output,
manifestFileName: 'my_cool_bundle.shaderbundle.json',
assetMode: ShaderBundleAssetMode.dataAssetsIfAvailable,
);
With DataAssets enabled, the result's flutterAssetKey is the key to pass
to gpu.ShaderLibrary.fromAsset. When DataAssets are unavailable,
dataAssetsIfAvailable falls back to the legacy file output. Use
ShaderBundleAssetMode.dataAssetsRequired to fail fast with guidance
instead.gpu.ShaderLibrary.fromAsset in your project. For example:import 'package:flutter_gpu/gpu.dart' as gpu;
final String _kBaseShaderBundlePath =
'build/shaderbundles/my_cool_bundle.shaderbundle';
gpu.ShaderLibrary? _baseShaderLibrary;
gpu.ShaderLibrary get baseShaderLibrary {
if (_baseShaderLibrary != null) {
return _baseShaderLibrary!;
}
_baseShaderLibrary = gpu.ShaderLibrary.fromAsset(_kBaseShaderBundlePath);
if (_baseShaderLibrary != null) {
return _baseShaderLibrary!;
}
throw Exception(
"Failed to load base shader bundle! ($_kBaseShaderBundlePath)");
}
निर्भरता सूची 7 आइटम
^3.0.3^0.20.0{"sdk":"flutter"}^2.0.0^1.3.0{"sdk":"flutter"}^6.0.0उपयोग के अनुसार छाँटें, गतिविधि की तुलना करें और अपनाने से पहले मूल प्रोजेक्ट की आवश्यकताएँ जाँचें।
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗