Esempio n. 1
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (Window.Current.Content == null)
            {
                deviceManager = new DeviceManager();

                scene = new Scene();

                // Place the frame in the current Window and ensure that it is active
                var swapchainPanel = new MainPage();
                swapchainPanel.SetScene(scene);
                Window.Current.Content = swapchainPanel;
                Window.Current.Activate();

                // Use CoreWindowTarget as the rendering target (Initialize SwapChain, RenderTargetView, DepthStencilView, BitmapTarget)
                target = new SwapChainBackgroundPanelTarget(swapchainPanel);

                // Add Initializer to device manager
                deviceManager.OnInitialize += target.Initialize;
                deviceManager.OnInitialize += scene.Initialize;

                // Render the cube within the CoreWindow
                target.OnRender += scene.Render;

                // Initialize the device manager and all registered deviceManager.OnInitialize
                deviceManager.Initialize(DisplayProperties.LogicalDpi);

                // Setup rendering callback
                CompositionTarget.Rendering += CompositionTarget_Rendering;

                // Callback on DpiChanged
                DisplayProperties.LogicalDpiChanged += DisplayProperties_LogicalDpiChanged;


                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }
            }

            // Ensure the current window is active
            Window.Current.Activate();
        }
Esempio n. 2
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                //TODO: Load state from previously suspended application
            }

            // Safely dispose any previous instance
            // Creates a new DeviceManager (Direct3D, Direct2D, DirectWrite, WIC)
            deviceManager = new DeviceManager();

            // New CubeRenderer
            cubeRenderer              = new CubeRenderer();
            cubeRenderer.ShowCube     = true;
            shapeRenderer             = new ShapeRenderer();
            shapeRenderer.Show        = false;
            shapeRenderer.EnableClear = false;

            // Place the frame in the current Window and ensure that it is active
            var swapchainPanel = new DirectXPanelXaml(cubeRenderer, shapeRenderer);

            Window.Current.Content = swapchainPanel;
            Window.Current.Activate();

            // Use CoreWindowTarget as the rendering target (Initialize SwapChain, RenderTargetView, DepthStencilView, BitmapTarget)
            target = new SwapChainBackgroundPanelTarget(swapchainPanel);

            // Add Initializer to device manager
            deviceManager.OnInitialize += target.Initialize;
            deviceManager.OnInitialize += cubeRenderer.Initialize;
            deviceManager.OnInitialize += shapeRenderer.Initialize;

            // Render the cube within the CoreWindow
            target.OnRender += cubeRenderer.Render;
            target.OnRender += shapeRenderer.Render;

            // Initialize the device manager and all registered deviceManager.OnInitialize
            deviceManager.Initialize(DisplayProperties.LogicalDpi);

            // Setup rendering callback
            CompositionTarget.Rendering += CompositionTarget_Rendering;

            // Callback on DpiChanged
            DisplayProperties.LogicalDpiChanged += DisplayProperties_LogicalDpiChanged;
        }
Esempio n. 3
0
        public MPSCBP()
        {
            this.InitializeComponent();

            effectRenderer = new EffectRenderer(root, root);
            var fpsRenderer = new FpsRenderer();

            d2dTarget           = new SwapChainBackgroundPanelTarget(root);
            d2dTarget.OnRender += effectRenderer.Render;
            d2dTarget.OnRender += fpsRenderer.Render;

            deviceManager = new DeviceManager();
            deviceManager.OnInitialize += d2dTarget.Initialize;
            deviceManager.OnInitialize += effectRenderer.Initialize;
            deviceManager.OnInitialize += fpsRenderer.Initialize;

            deviceManager.Initialize(DisplayProperties.LogicalDpi);

            // Setup rendering callback
            CompositionTarget.Rendering += CompositionTarget_Rendering;
        }