first pass Windows implementation

This commit is contained in:
Nick Fisher
2023-09-22 08:24:14 +08:00
parent 7c2659c89e
commit 693e5431ed

View File

@@ -53,23 +53,137 @@ PolyvoxFilamentPlugin::PolyvoxFilamentPlugin() {}
PolyvoxFilamentPlugin::~PolyvoxFilamentPlugin() {}
static FlMethodResponse* _set_bloom(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) {
FlValue* args = fl_method_call_get_args(method_call);
set_bloom(self->viewer, fl_value_get_float(args));
return FL_METHOD_RESPONSE(fl_method_success_response_new(fl_value_new_bool(true)));
}
void PolyvoxFilamentPlugin::HandleMethodCall(
const flutter::MethodCall<flutter::EncodableValue> &method_call,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result) {
if (method_call.method_name().compare("getPlatformVersion") == 0) {
std::ostringstream version_stream;
version_stream << "Windows ";
if (IsWindows10OrGreater()) {
version_stream << "10+";
} else if (IsWindows8OrGreater()) {
version_stream << "8";
} else if (IsWindows7OrGreater()) {
version_stream << "7";
}
result->Success(flutter::EncodableValue(version_stream.str()));
} else {
result->NotImplemented();
}
if(strcmp(method, "createFilamentViewer") == 0) {
response = _create_filament_viewer(self, method_call);
} else if(strcmp(method, "createTexture") == 0) {
response = _create_texture(self, method_call);
} else if(strcmp(method, "updateViewportAndCameraProjection")==0){
response = _update_viewport_and_camera_projection(self, method_call);
}
// else if(strcmp(method, "getAssetManager") ==0){
// response = _get_asset_manager(self, method_call);
// } else if(strcmp(method, "setToneMapping") == 0) {
// response = _set_tone_mapping(self, method_call);
// } else if(strcmp(method, "setBloom") == 0) {
// response = _set_bloom(self, method_call);
// } else if(strcmp(method, "resize") == 0) {
// response = _resize(self, method_call);
// } else if(strcmp(method, "getContext") == 0) {
// g_autoptr(FlValue) result =
// fl_value_new_int(reinterpret_cast<int64_t>(glXGetCurrentContext()));
// response = FL_METHOD_RESPONSE(fl_method_success_response_new(result));
// } else if(strcmp(method, "getGlTextureId") == 0) {
// g_autoptr(FlValue) result =
// fl_value_new_int(reinterpret_cast<unsigned int>(((FilamentTextureGL*)self->texture)->texture_id));
// response = FL_METHOD_RESPONSE(fl_method_success_response_new(result));
// } else if(strcmp(method, "getResourceLoader") == 0) {
// ResourceLoaderWrapper* resourceLoader = new ResourceLoaderWrapper(loadResource, freeResource);
// g_autoptr(FlValue) result =
// fl_value_new_int(reinterpret_cast<int64_t>(resourceLoader));
// response = FL_METHOD_RESPONSE(fl_method_success_response_new(result));
// } else if(strcmp(method, "setRendering") == 0) {
// self->rendering = fl_value_get_bool(fl_method_call_get_args(method_call));
// response = FL_METHOD_RESPONSE(fl_method_success_response_new(fl_value_new_string("OK")));
// } else if(strcmp(method, "loadSkybox") == 0) {
// response = _loadSkybox(self, method_call);
// } else if(strcmp(method, "loadIbl") == 0) {
// response = _loadIbl(self, method_call);
// } else if(strcmp(method, "removeIbl") ==0) {
// response = _remove_ibl(self, method_call);
// } else if(strcmp(method, "removeSkybox") == 0) {
// response = _removeSkybox(self, method_call);
// } else if(strcmp(method, "render") == 0) {
// render(self->viewer, 0);
// g_autoptr(FlValue) result = fl_value_new_string("OK");
// response = FL_METHOD_RESPONSE(fl_method_success_response_new(result));
// } else if(strcmp(method, "setBackgroundColor") == 0) {
// response = _set_background_color(self, method_call);
// } else if(strcmp(method, "setBackgroundImage") == 0) {
// response = _set_background_image(self, method_call);
// } else if(strcmp(method, "addLight") == 0) {
// response = _add_light(self, method_call);
// } else if(strcmp(method, "loadGlb") == 0) {
// response = _load_glb(self, method_call);
// } else if(strcmp(method, "getAnimationNames") == 0) {
// response = _get_animation_names(self, method_call);
// } else if(strcmp(method, "clearAssets") == 0) {
// clear_assets(self->viewer);
// g_autoptr(FlValue) result = fl_value_new_string("OK");
// response = FL_METHOD_RESPONSE(fl_method_success_response_new(result));
// } else if(strcmp(method, "removeAsset") == 0) {
// response = _remove_asset(self, method_call);
// } else if(strcmp(method, "transformToUnitCube") == 0) {
// response = _transform_to_unit_cube(self, method_call);
// } else if(strcmp(method, "clearLights") == 0) {
// clear_lights(self->viewer);
// g_autoptr(FlValue) result = fl_value_new_string("OK");
// response = FL_METHOD_RESPONSE(fl_method_success_response_new(result));
// } else if(strcmp(method, "panStart") == 0) {
// response = _pan_start(self, method_call);
// } else if(strcmp(method, "panEnd") == 0) {
// response = _pan_end(self, method_call);
// } else if(strcmp(method, "panUpdate") == 0) {
// response = _pan_update(self, method_call);
// } else if(strcmp(method, "rotateStart") == 0) {
// response = _rotate_start(self, method_call);
// } else if(strcmp(method, "rotateEnd") == 0) {
// response = _rotate_end(self, method_call);
// } else if(strcmp(method, "rotateUpdate") == 0) {
// response = _rotate_update(self, method_call);
// } else if(strcmp(method, "setRotation") == 0) {
// response = _set_rotation(self, method_call);
// } else if(strcmp(method, "setCamera") == 0) {
// response = _set_camera(self, method_call);
// } else if(strcmp(method, "setCameraModelMatrix") == 0) {
// response = _set_camera_model_matrix(self, method_call);
// } else if(strcmp(method, "setCameraExposure") == 0) {
// response = _set_camera_exposure(self, method_call);
// } else if(strcmp(method, "setCameraPosition") == 0) {
// response = _set_camera_position(self, method_call);
// } else if(strcmp(method, "setCameraRotation") == 0) {
// response = _set_camera_rotation(self, method_call);
// } else if(strcmp(method, "setFrameInterval") == 0) {
// response = _set_frame_interval(self, method_call);
// } else if(strcmp(method, "scrollBegin") == 0) {
// response = _scroll_begin(self, method_call);
// } else if(strcmp(method, "scrollEnd") == 0) {
// response = _scroll_end(self, method_call);
// } else if(strcmp(method, "scrollUpdate") == 0) {
// response = _scroll_update(self, method_call);
// } else if(strcmp(method, "grabBegin") == 0) {
// response = _grab_begin(self, method_call);
// } else if(strcmp(method, "grabEnd") == 0) {
// response = _grab_end(self, method_call);
// } else if(strcmp(method, "grabUpdate") == 0) {
// response = _grab_update(self, method_call);
// } else if(strcmp(method, "playAnimation") == 0) {
// response = _play_animation(self, method_call);
// } else if(strcmp(method, "stopAnimation") == 0) {
// response = _stop_animation(self, method_call);
// } else if(strcmp(method, "setMorphTargetWeights") == 0) {
// response = _set_morph_target_weights(self, method_call);
// } else if(strcmp(method, "setMorphAnimation") == 0) {
// response = _set_morph_animation(self, method_call);
// } else if(strcmp(method, "getMorphTargetNames") == 0) {
// response = _get_morph_target_names(self, method_call);
// } else if(strcmp(method, "setPosition") == 0) {
// response = _set_position(self, method_call);
// } else if(strcmp(method, "setBoneTransform") == 0) {
// response = _set_bone_transform(self, method_call);
// } else {
// response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new());
// }
fl_method_call_respond(method_call, response, nullptr);
}
} // namespace