// Copyright (c) Microsoft Corporation. 
// Licensed under the MIT license. 

#include <string>
#include <stdlib.h>
#include <filesystem>
#include <future>
#include "SimplygonLoader.h"

class CustomErrorHandler : public Simplygon::ErrorHandler
{
	public:
	void HandleError(Simplygon::spObject object, const char* interfaceName, const char* methodName, Simplygon::rid errorType , const char* errorText) override
	{
		printf("Error (%s:%s): %s\n", interfaceName, methodName, errorText);
	}
} customErrorHandler;


void RunReduction(Simplygon::ISimplygon* sg)
{
	// Set the custom error handler to the Simplygon interface. 
	sg->SetErrorHandler(&customErrorHandler);

	// Create the reduction pipeline. 
	Simplygon::spReductionPipeline sgReductionPipeline = sg->CreateReductionPipeline();

	// Start the reduction pipeline with a faulty input file path. 
	sgReductionPipeline->RunSceneFromFile("Foo.bar", "output.fbx", Simplygon::EPipelineRunMode::RunInNewProcess);

}

void main()
{
	Simplygon::ISimplygon* sg = NULL;
	Simplygon::EErrorCodes initval = Simplygon::Initialize( &sg );
	if( initval != Simplygon::EErrorCodes::NoError )
	{
		return;
	}

	RunReduction(sg);

	Simplygon::Deinitialize(sg);
}

