Example #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)
        {
            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;
        }
Example #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;
        }