Example #1
0
        public static void Main()
        {
            // Inject Fusee.Engine.Base InjectMe dependencies
            IO.IOImp = new Fusee.Base.Imp.Desktop.IOImp();

            var fap = new Fusee.Base.Imp.Desktop.FileAssetProvider("Assets");

            fap.RegisterTypeHandler(
                new AssetHandler
            {
                ReturnedType = typeof(Font),
                Decoder      = delegate(string id, object storage)
                {
                    if (!Path.GetExtension(id).ToLower().Contains("ttf"))
                    {
                        return(null);
                    }
                    return(new Font {
                        _fontImp = new FontImp((Stream)storage)
                    });
                },
                Checker = id => Path.GetExtension(id).ToLower().Contains("ttf")
            });
            fap.RegisterTypeHandler(
                new AssetHandler
            {
                ReturnedType = typeof(SceneContainer),
                Decoder      = delegate(string id, object storage)
                {
                    if (!Path.GetExtension(id).ToLower().Contains("fus"))
                    {
                        return(null);
                    }
                    var ser = new Serializer();
                    return(new ConvertSceneGraph().Convert(ser.Deserialize((Stream)storage, null, typeof(SceneContainer)) as SceneContainer));
                },
                Checker = id => Path.GetExtension(id).ToLower().Contains("fus")
            });

            AssetStorage.RegisterProvider(fap);

            var app = new Core.UI();

            // Inject Fusee.Engine InjectMe dependencies (hard coded)
            System.Drawing.Icon appIcon = System.Drawing.Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
            app.CanvasImplementor  = new Fusee.Engine.Imp.Graphics.Desktop.RenderCanvasImp(appIcon);
            app.ContextImplementor = new Fusee.Engine.Imp.Graphics.Desktop.RenderContextImp(app.CanvasImplementor);
            Input.AddDriverImp(new Fusee.Engine.Imp.Graphics.Desktop.RenderCanvasInputDriverImp(app.CanvasImplementor));
            Input.AddDriverImp(new Fusee.Engine.Imp.Graphics.Desktop.WindowsTouchInputDriverImp(app.CanvasImplementor));
            // app.InputImplementor = new Fusee.Engine.Imp.Graphics.Desktop.InputImp(app.CanvasImplementor);
            // app.AudioImplementor = new Fusee.Engine.Imp.Sound.Desktop.AudioImp();
            // app.NetworkImplementor = new Fusee.Engine.Imp.Network.Desktop.NetworkImp();
            // app.InputDriverImplementor = new Fusee.Engine.Imp.Input.Desktop.InputDriverImp();
            // app.VideoManagerImplementor = ImpFactory.CreateIVideoManagerImp();

            // Start the app
            app.Run();
        }
Example #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            RequestWindowFeature(WindowFeatures.NoTitle);
            if (SupportedOpenGLVersion() >= 3)
            {
                // SetContentView(new LibPaintingView(ApplicationContext, null));

                // Inject Fusee.Engine.Base InjectMe dependencies
                IO.IOImp = new IOImp(ApplicationContext);

                var fap = new Fusee.Base.Imp.Android.ApkAssetProvider(ApplicationContext);
                fap.RegisterTypeHandler(
                    new AssetHandler
                {
                    ReturnedType = typeof(Font),
                    Decoder      = delegate(string id, object storage)
                    {
                        if (Path.GetExtension(id).ToLower().Contains("ttf"))
                        {
                            return(new Font
                            {
                                _fontImp = new FontImp((Stream)storage)
                            });
                        }

                        return(null);
                    },
                    Checker = delegate(string id)
                    {
                        return(Path.GetExtension(id).ToLower().Contains("ttf"));
                    }
                });
                fap.RegisterTypeHandler(
                    new AssetHandler
                {
                    ReturnedType = typeof(SceneContainer),
                    Decoder      = delegate(string id, object storage)
                    {
                        if (Path.GetExtension(id).ToLower().Contains("fus"))
                        {
                            return(FusSceneConverter.ConvertFrom(ProtoBuf.Serializer.Deserialize <FusFile>((Stream)storage)));
                        }
                        return(null);
                    },
                    Checker = delegate(string id)
                    {
                        return(Path.GetExtension(id).ToLower().Contains("fus"));
                    }
                });
                AssetStorage.RegisterProvider(fap);

                var app = new Core.UI();

                // Inject Fusee.Engine InjectMe dependencies (hard coded)
                var rci = new RenderCanvasImp(ApplicationContext, null, delegate { app.Run(); });
                app.CanvasImplementor  = rci;
                app.ContextImplementor = new RenderContextImp(rci, ApplicationContext);

                SetContentView(rci.View);

                Engine.Core.Input.AddDriverImp(
                    new Fusee.Engine.Imp.Graphics.Android.RenderCanvasInputDriverImp(app.CanvasImplementor));
                // Engine.Core.Input.AddDriverImp(new Fusee.Engine.Imp.Graphics.Android.WindowsTouchInputDriverImp(app.CanvasImplementor));
                // Deleayed into rendercanvas imp....app.Run() - SEE DELEGATE ABOVE;
            }
            else
            {
                Toast.MakeText(ApplicationContext, "Hardware does not support OpenGL ES 3.0 - Aborting...", ToastLength.Long);
                Log.Info("@string/app_name", "Hardware does not support OpenGL ES 3.0 - Aborting...");
            }
        }