예제 #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
#if DEBUG
            LogManager.AddDebugListener(true);
#endif

            var languageService = ServiceLocator.Default.ResolveType <ILanguageService>();

            // Note: it's best to use .CurrentUICulture in actual apps since it will use the preferred language
            // of the user. But in order to demo multilingual features for devs (who mostly have en-US as .CurrentUICulture),
            // we use .CurrentCulture for the sake of the demo
            languageService.PreferredCulture = CultureInfo.CurrentCulture;
            languageService.FallbackCulture  = new CultureInfo("en-US");


            FontMaterial.Initialize(false);
            FontAwesome.Initialize();

            var serviceLocator = ServiceLocator.Default;
            var shellService   = serviceLocator.ResolveType <IShellService>();
            shellService.CreateAsync <ShellWindow>();

            _stopwatch.Stop();

            Log.Info("Elapsed startup stopwatch time: {0}", _stopwatch.Elapsed);
        }
        public override void Run(RenderControl render)
        {
            if (!mLoaded)
            {
                mLoaded = true;

                FontManager.Instance().AddFont("LS", @"C:\Windows\Fonts\STLITI.TTF");
            }

            {
                var fontMaterial = FontMaterial.Create("font-texture-1");
                fontMaterial.SetFaceSide(EnumFaceSide.DoubleSide);
                fontMaterial.SetColor(new Vector3(1, 1, 0));
                fontMaterial.SetBackground(new Vector3(0, 0, 1));
                fontMaterial.SetBillboard(true);

                var dim   = fontMaterial.SetText("Hello 世界!", 128, "LS");
                var shape = GeometryBuilder.CreatePlane(dim.x * 0.1f, dim.y * 0.1f);

                var node = new PrimitiveSceneNode(shape, fontMaterial);
                node.SetPickable(false);

                render.ShowSceneNode(node);
            }
            {
                var fixedSizeMaterial = SpriteMaterial.Create("font-mesh-material");
                fixedSizeMaterial.SetSizeAttenuation(false);
                fixedSizeMaterial.SetColor(ColorTable.Green);

                var mesh  = FontManager.Instance().CreateMesh("哈哈");
                var node  = new PrimitiveSceneNode(mesh, fixedSizeMaterial);
                var scale = 1 / 2200.0f;
                node.SetTransform(Matrix4.makeTranslation(0, 0, 10) * Matrix4.makeScale(scale, scale, scale));
                node.SetPickable(false);

                render.ShowSceneNode(node);
            }
        }