/// <inheritdoc/> public void SetWindow(CoreWindow window) { this.window = window; // Safely dispose any previous instance RemoveAndDispose(ref deviceManager); RemoveAndDispose(ref target); RemoveAndDispose(ref cubeRenderer); // Creates a new DeviceManager (Direct3D, Direct2D, DirectWrite, WIC) deviceManager = ToDispose(new DeviceManager()); // Use CoreWindowTarget as the rendering target (Initialize SwapChain, RenderTargetView, DepthStencilView, BitmapTarget) target = ToDispose(new CoreWindowTarget(window)); // New CubeRenderer cubeRenderer = ToDispose(new CubeRenderer()); var fpsRenderer = new FpsRenderer(); // Add Initializer to device manager deviceManager.OnInitialize += target.Initialize; deviceManager.OnInitialize += cubeRenderer.Initialize; deviceManager.OnInitialize += fpsRenderer.Initialize; // Render the cube within the CoreWindow target.OnRender += cubeRenderer.Render; target.OnRender += fpsRenderer.Render; // Initialize the device manager and all registered deviceManager.OnInitialize deviceManager.Initialize(DisplayProperties.LogicalDpi); }
/// <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 } // Place the frame in the current Window and ensure that it is active var swapChainPanel = new MainPage(); Window.Current.Content = swapChainPanel; Window.Current.Activate(); // Safely dispose any previous instance // Creates a new DeviceManager (Direct3D, Direct2D, DirectWrite, WIC) deviceManager = new DeviceManager(); // New CubeRenderer renderer = new ShapeRenderer(); var fpsRenderer = new FpsRenderer(); // Use CoreWindowTarget as the rendering target (Initialize SwapChain, RenderTargetView, DepthStencilView, BitmapTarget) target = new SwapChainPanelTarget(swapChainPanel); // Add Initializer to device manager deviceManager.OnInitialize += target.Initialize; deviceManager.OnInitialize += renderer.Initialize; deviceManager.OnInitialize += fpsRenderer.Initialize; // Render the cube within the CoreWindow target.OnRender += renderer.Render; target.OnRender += fpsRenderer.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; }
public MPSCBP() { this.InitializeComponent(); effectRenderer = new EffectRenderer(root, root); var fpsRenderer = new FpsRenderer(); d2dTarget = new SwapChainPanelTarget(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; }