feat: allow passing renderTargetColorTextureFormat via ThermionFlutterOptions
This commit is contained in:
@@ -212,7 +212,7 @@ class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform {
|
|||||||
TextureUsage.TEXTURE_USAGE_COLOR_ATTACHMENT,
|
TextureUsage.TEXTURE_USAGE_COLOR_ATTACHMENT,
|
||||||
TextureUsage.TEXTURE_USAGE_SAMPLEABLE,
|
TextureUsage.TEXTURE_USAGE_SAMPLEABLE,
|
||||||
},
|
},
|
||||||
textureFormat: TextureFormat.RGBA32F,
|
textureFormat: options.renderTargetColorTextureFormat,
|
||||||
textureSamplerType: TextureSamplerType.SAMPLER_2D,
|
textureSamplerType: TextureSamplerType.SAMPLER_2D,
|
||||||
);
|
);
|
||||||
final depth = await FilamentApp.instance!.createTexture(
|
final depth = await FilamentApp.instance!.createTexture(
|
||||||
@@ -225,7 +225,7 @@ class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform {
|
|||||||
TextureUsage.TEXTURE_USAGE_STENCIL_ATTACHMENT
|
TextureUsage.TEXTURE_USAGE_STENCIL_ATTACHMENT
|
||||||
},
|
},
|
||||||
textureFormat:
|
textureFormat:
|
||||||
TextureFormat.DEPTH24_STENCIL8, // TextureFormat.DEPTH32F,
|
options.renderTargetDepthTextureFormat,
|
||||||
textureSamplerType: TextureSamplerType.SAMPLER_2D,
|
textureSamplerType: TextureSamplerType.SAMPLER_2D,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,25 @@ import 'thermion_flutter_texture.dart';
|
|||||||
class ThermionFlutterOptions {
|
class ThermionFlutterOptions {
|
||||||
final String? uberarchivePath;
|
final String? uberarchivePath;
|
||||||
final Backend? backend;
|
final Backend? backend;
|
||||||
|
|
||||||
|
/// The format to use for the default render target color attachment.
|
||||||
|
/// Currently only applicable on iOS/macOS.
|
||||||
|
///
|
||||||
|
final TextureFormat renderTargetColorTextureFormat;
|
||||||
|
|
||||||
|
/// The format to use for the default render target depth attachment.
|
||||||
|
/// Currently only applicable on iOS/macOS.
|
||||||
|
///
|
||||||
|
final TextureFormat renderTargetDepthTextureFormat;
|
||||||
|
|
||||||
const ThermionFlutterOptions(
|
const ThermionFlutterOptions(
|
||||||
{this.uberarchivePath = null, this.backend = null});
|
{this.uberarchivePath = null,
|
||||||
|
this.backend = null,
|
||||||
|
this.renderTargetColorTextureFormat = TextureFormat.RGBA32F,
|
||||||
|
this.renderTargetDepthTextureFormat = TextureFormat.DEPTH24_STENCIL8});
|
||||||
}
|
}
|
||||||
|
|
||||||
class ThermionFlutterWebOptions extends ThermionFlutterOptions {
|
class ThermionFlutterWebOptions extends ThermionFlutterOptions {
|
||||||
|
|
||||||
final bool createCanvas;
|
final bool createCanvas;
|
||||||
final bool importCanvasAsWidget;
|
final bool importCanvasAsWidget;
|
||||||
|
|
||||||
@@ -22,8 +34,6 @@ class ThermionFlutterWebOptions extends ThermionFlutterOptions {
|
|||||||
this.createCanvas = true,
|
this.createCanvas = true,
|
||||||
String? uberarchivePath})
|
String? uberarchivePath})
|
||||||
: super(uberarchivePath: uberarchivePath);
|
: super(uberarchivePath: uberarchivePath);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class ThermionFlutterPlatform extends PlatformInterface {
|
abstract class ThermionFlutterPlatform extends PlatformInterface {
|
||||||
@@ -42,15 +52,11 @@ abstract class ThermionFlutterPlatform extends PlatformInterface {
|
|||||||
_options ??= const ThermionFlutterOptions();
|
_options ??= const ThermionFlutterOptions();
|
||||||
return _options!;
|
return _options!;
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
void setOptions(covariant ThermionFlutterOptions options) {
|
void setOptions(covariant ThermionFlutterOptions options) {
|
||||||
if (_options != null) {
|
|
||||||
throw Exception(
|
|
||||||
"Options can only be set once for the entire app lifecycle.");
|
|
||||||
}
|
|
||||||
_options = options;
|
_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user