Ejemplo n.º 1
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), id));
                        }
                        return(null);
                    },
                    Checker = delegate(string id)
                    {
                        return(Path.GetExtension(id).ToLower().Contains("fus"));
                    }
                });
                AssetStorage.RegisterProvider(fap);

                var app = new Core.Deferred();

                // Inject Fusee.Engine InjectMe dependencies (hard coded)
                var rci = new RenderCanvasImp(ApplicationContext, null, delegate
                {
                    app.InitApp();
                    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...");
            }
        }
Ejemplo n.º 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"))
                            {
                                var ser = new Serializer();
                                return ser.Deserialize((Stream)storage, null, typeof(SceneContainer)) as SceneContainer;
                            }
                            return null;
                        },
                        Checker = delegate (string id)
                        {
                            return Path.GetExtension(id).ToLower().Contains("fus");
                        }
                    });
                AssetStorage.RegisterProvider(fap);

                var app = new Core.Main();

                // Inject Fusee.Engine InjectMe dependencies (hard coded)
                RenderCanvasImp 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...");
            }
        }