Example #1
0
        private static void ConfigureGraphicsContext(Application application, Window window)
        {
            GraphicsContext graphicsContext = new WaveEngine.DirectX11.DX11GraphicsContext();

            graphicsContext.CreateDevice();
            SwapChainDescription swapChainDescription = new SwapChainDescription()
            {
                SurfaceInfo              = window.SurfaceInfo,
                Width                    = window.Width,
                Height                   = window.Height,
                ColorTargetFormat        = PixelFormat.R8G8B8A8_UNorm,
                ColorTargetFlags         = TextureFlags.RenderTarget | TextureFlags.ShaderResource,
                DepthStencilTargetFormat = PixelFormat.D24_UNorm_S8_UInt,
                DepthStencilTargetFlags  = TextureFlags.DepthStencil,
                SampleCount              = TextureSampleCount.None,
                IsWindowed               = true,
                RefreshRate              = 60
            };
            var swapChain = graphicsContext.CreateSwapChain(swapChainDescription);

            swapChain.VerticalSync = true;

            var graphicsPresenter = application.Container.Resolve <GraphicsPresenter>();
            var firstDisplay      = new Display(window, swapChain);

            graphicsPresenter.AddDisplay("DefaultDisplay", firstDisplay);

            application.Container.RegisterInstance(graphicsContext);
        }
Example #2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            // Create app
            WaveApplication = new MyApplication();

            // Create Window System
            var windowsSystem = new WaveEngine.WPF.WPFWindowsSystem(this);

            WaveApplication.Container.RegisterInstance(windowsSystem);

            // Create Graphic context
            var graphicsContext = new WaveEngine.DirectX11.DX11GraphicsContext();

            graphicsContext.CreateDevice();
            WaveApplication.Container.RegisterInstance(graphicsContext);

            // Creates XAudio device
            var xaudio = new WaveEngine.XAudio2.XAudioDevice();

            WaveApplication.Container.RegisterInstance(xaudio);

            Stopwatch clockTimer = Stopwatch.StartNew();

            windowsSystem.Run(
                () =>
            {
                WaveApplication.Initialize();
            },
                () =>
            {
                var gameTime = clockTimer.Elapsed;
                clockTimer.Restart();

                WaveApplication.UpdateFrame(gameTime);
                WaveApplication.DrawFrame(gameTime);
            });
        }