feat: add MaterialInstance.setDepthFunc
This commit is contained in:
1 parent
bb27f40cb2
commit
0b9f3160d9
9 files changed
+262
-108
No files matched your search
@@ -7,6 +7,76 @@ library;
|
||||
|
||||
import 'dart:ffi' as ffi;
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TMaterialInstance>, ffi.Bool)>(
|
||||
isLeaf: true)
|
||||
external void MaterialInstance_setDepthWrite(
|
||||
ffi.Pointer<TMaterialInstance> materialInstance,
|
||||
bool enabled,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TMaterialInstance>, ffi.Bool)>(
|
||||
isLeaf: true)
|
||||
external void MaterialInstance_setDepthCulling(
|
||||
ffi.Pointer<TMaterialInstance> materialInstance,
|
||||
bool enabled,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TMaterialInstance>, ffi.Pointer<ffi.Char>,
|
||||
ffi.Double, ffi.Double, ffi.Double, ffi.Double)>(isLeaf: true)
|
||||
external void MaterialInstance_setParameterFloat4(
|
||||
ffi.Pointer<TMaterialInstance> materialInstance,
|
||||
ffi.Pointer<ffi.Char> name,
|
||||
double x,
|
||||
double y,
|
||||
double w,
|
||||
double z,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TMaterialInstance>, ffi.Pointer<ffi.Char>,
|
||||
ffi.Double, ffi.Double)>(isLeaf: true)
|
||||
external void MaterialInstance_setParameterFloat2(
|
||||
ffi.Pointer<TMaterialInstance> materialInstance,
|
||||
ffi.Pointer<ffi.Char> name,
|
||||
double x,
|
||||
double y,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TMaterialInstance>, ffi.Pointer<ffi.Char>,
|
||||
ffi.Double)>(isLeaf: true)
|
||||
external void MaterialInstance_setParameterFloat(
|
||||
ffi.Pointer<TMaterialInstance> materialInstance,
|
||||
ffi.Pointer<ffi.Char> name,
|
||||
double value,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TMaterialInstance>, ffi.Pointer<ffi.Char>,
|
||||
ffi.Int)>(isLeaf: true)
|
||||
external void MaterialInstance_setParameterInt(
|
||||
ffi.Pointer<TMaterialInstance> materialInstance,
|
||||
ffi.Pointer<ffi.Char> name,
|
||||
int value,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TMaterialInstance>, ffi.UnsignedInt)>(
|
||||
symbol: "MaterialInstance_setDepthFunc", isLeaf: true)
|
||||
external void _MaterialInstance_setDepthFunc(
|
||||
ffi.Pointer<TMaterialInstance> materialInstance,
|
||||
int depthFunc,
|
||||
);
|
||||
|
||||
void MaterialInstance_setDepthFunc(
|
||||
ffi.Pointer<TMaterialInstance> materialInstance,
|
||||
TDepthFunc depthFunc,
|
||||
) =>
|
||||
_MaterialInstance_setDepthFunc(
|
||||
materialInstance,
|
||||
depthFunc.value,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Pointer<ffi.Void> Function(LoadFilamentResourceFromOwner,
|
||||
FreeFilamentResourceFromOwner, ffi.Pointer<ffi.Void>)>(isLeaf: true)
|
||||
@@ -1205,60 +1275,6 @@ external ffi.Pointer<TMaterialInstance> get_material_instance_at(
|
||||
int materialIndex,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TMaterialInstance>, ffi.Bool)>(
|
||||
isLeaf: true)
|
||||
external void MaterialInstance_setDepthWrite(
|
||||
ffi.Pointer<TMaterialInstance> materialInstance,
|
||||
bool enabled,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TMaterialInstance>, ffi.Bool)>(
|
||||
isLeaf: true)
|
||||
external void MaterialInstance_setDepthCulling(
|
||||
ffi.Pointer<TMaterialInstance> materialInstance,
|
||||
bool enabled,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TMaterialInstance>, ffi.Pointer<ffi.Char>,
|
||||
ffi.Double, ffi.Double, ffi.Double, ffi.Double)>(isLeaf: true)
|
||||
external void MaterialInstance_setParameterFloat4(
|
||||
ffi.Pointer<TMaterialInstance> materialInstance,
|
||||
ffi.Pointer<ffi.Char> name,
|
||||
double x,
|
||||
double y,
|
||||
double w,
|
||||
double z,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TMaterialInstance>, ffi.Pointer<ffi.Char>,
|
||||
ffi.Double, ffi.Double)>(isLeaf: true)
|
||||
external void MaterialInstance_setParameterFloat2(
|
||||
ffi.Pointer<TMaterialInstance> materialInstance,
|
||||
ffi.Pointer<ffi.Char> name,
|
||||
double x,
|
||||
double y,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TMaterialInstance>, ffi.Pointer<ffi.Char>,
|
||||
ffi.Double)>(isLeaf: true)
|
||||
external void MaterialInstance_setParameterFloat(
|
||||
ffi.Pointer<TMaterialInstance> materialInstance,
|
||||
ffi.Pointer<ffi.Char> name,
|
||||
double value,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TMaterialInstance>, ffi.Pointer<ffi.Char>,
|
||||
ffi.Int)>(isLeaf: true)
|
||||
external void MaterialInstance_setParameterInt(
|
||||
ffi.Pointer<TMaterialInstance> materialInstance,
|
||||
ffi.Pointer<ffi.Char> name,
|
||||
int value,
|
||||
);
|
||||
|
||||
@ffi.Native<TViewport Function(ffi.Pointer<TView>)>(isLeaf: true)
|
||||
external TViewport View_getViewport(
|
||||
ffi.Pointer<TView> view,
|
||||
@@ -1487,19 +1503,6 @@ external void Viewer_captureRenderTargetRenderThread(
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> onComplete,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Pointer<TRenderTarget> Function(
|
||||
ffi.Pointer<TViewer>, ffi.IntPtr, ffi.Uint32, ffi.Uint32,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<TRenderTarget>)>>
|
||||
)>(isLeaf: true)
|
||||
external ffi.Pointer<TRenderTarget> Viewer_createRenderTargetRenderThread(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
int texture,
|
||||
int width,
|
||||
int height,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<TRenderTarget>)>> onComplete,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TViewer>,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>>)>(isLeaf: true)
|
||||
@@ -1518,6 +1521,24 @@ external void Viewer_loadIblRenderThread(
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> onComplete,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(
|
||||
ffi.Pointer<TViewer>,
|
||||
ffi.IntPtr,
|
||||
ffi.Uint32,
|
||||
ffi.Uint32,
|
||||
ffi.Pointer<
|
||||
ffi.NativeFunction<
|
||||
ffi.Void Function(ffi.Pointer<TRenderTarget>)>>)>(isLeaf: true)
|
||||
external void Viewer_createRenderTargetRenderThread(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
int texture,
|
||||
int width,
|
||||
int height,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<TRenderTarget>)>>
|
||||
onComplete,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(
|
||||
ffi.Pointer<TView>, ffi.Pointer<TEngine>, ffi.Int)>(isLeaf: true)
|
||||
@@ -2124,10 +2145,51 @@ external void Gizmo_setVisibility(
|
||||
bool visible,
|
||||
);
|
||||
|
||||
final class TCamera extends ffi.Opaque {}
|
||||
|
||||
final class TMaterialInstance extends ffi.Opaque {}
|
||||
|
||||
enum TDepthFunc {
|
||||
/// !< Less or equal
|
||||
LE(0),
|
||||
|
||||
/// !< Greater or equal
|
||||
GE(1),
|
||||
|
||||
/// !< Strictly less than
|
||||
L(2),
|
||||
|
||||
/// !< Strictly greater than
|
||||
G(3),
|
||||
|
||||
/// !< Equal
|
||||
E(4),
|
||||
|
||||
/// !< Not equal
|
||||
NE(5),
|
||||
|
||||
/// !< Always. Depth / stencil testing is deactivated.
|
||||
A(6),
|
||||
|
||||
/// !< Never. The depth / stencil test always fails.
|
||||
N(7);
|
||||
|
||||
final int value;
|
||||
const TDepthFunc(this.value);
|
||||
|
||||
static TDepthFunc fromValue(int value) => switch (value) {
|
||||
0 => LE,
|
||||
1 => GE,
|
||||
2 => L,
|
||||
3 => G,
|
||||
4 => E,
|
||||
5 => NE,
|
||||
6 => A,
|
||||
7 => N,
|
||||
_ => throw ArgumentError("Unknown value for TDepthFunc: $value"),
|
||||
};
|
||||
}
|
||||
|
||||
final class TCamera extends ffi.Opaque {}
|
||||
|
||||
final class TEngine extends ffi.Opaque {}
|
||||
|
||||
final class TEntityManager extends ffi.Opaque {}
|
||||
|
||||
@@ -2277,6 +2277,11 @@ class ThermionFFIMaterialInstance extends MaterialInstance {
|
||||
MaterialInstance_setParameterInt(
|
||||
_pointer, name.toNativeUtf8().cast<Char>(), value);
|
||||
}
|
||||
|
||||
@override
|
||||
Future setDepthFunc(SampleCompareFunction depthFunc) async {
|
||||
MaterialInstance_setDepthFunc(_pointer, TDepthFunc.values[depthFunc.index]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,26 @@
|
||||
import 'package:thermion_dart/src/viewer/src/ffi/src/callbacks.dart';
|
||||
|
||||
enum SampleCompareFunction {
|
||||
/// !< Less or equal
|
||||
LE,
|
||||
/// !< Greater or equal
|
||||
GE,
|
||||
/// !< Strictly less than
|
||||
L,
|
||||
/// !< Strictly greater than
|
||||
G,
|
||||
/// !< Equal
|
||||
E,
|
||||
/// !< Not equal
|
||||
NE,
|
||||
/// !< Always. Depth / stencil testing is deactivated.
|
||||
A,
|
||||
/// !< Never. The depth / stencil test always fails.
|
||||
N;
|
||||
}
|
||||
abstract class MaterialInstance {
|
||||
Future setDepthWriteEnabled(bool enabled);
|
||||
Future setDepthFunc(SampleCompareFunction depthFunc);
|
||||
|
||||
Future setDepthCullingEnabled(bool enabled);
|
||||
Future setParameterFloat4(String name, double x, double y, double z, double w);
|
||||
|
||||
@@ -27,4 +27,22 @@ class ThermionWasmMaterialInstance extends MaterialInstance {
|
||||
// TODO: implement setParameterFloat
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future setDepthFunc(SampleCompareFunction depthFunc) {
|
||||
// TODO: implement setDepthFunc
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future setParameterFloat4(String name, double x, double y, double z, double w) {
|
||||
// TODO: implement setParameterFloat4
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future setParameterInt(String name, int value) {
|
||||
// TODO: implement setParameterInt
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user