コード例 #1
0
        public void Shutdown()
        {
            // Release the camera object.
            Camera = null;

            // Release the glow shader object.
            GlowShader?.ShutDown();
            GlowShader = null;
            // Release the glow map shader object.
            GlowMapShader?.ShutDown();
            GlowMapShader = null;
            // Release the full screen ortho window object.
            FullScreenWindow?.Shutdown();
            FullScreenWindow = null;
            // Release the small ortho window object.
            SmallWindow?.Shutdown();
            SmallWindow = null;
            // Release the up sample render to texture object.
            UpSampleTexure?.Shutdown();
            UpSampleTexure = null;
            // Release the vertical blur render to texture object.
            VerticalBlurTexture?.Shutdown();
            VerticalBlurTexture = null;
            // Release the vertical blur shader object.
            VerticalBlurShader?.ShutDown();
            VerticalBlurShader = null;
            // Release the horizontal blur render to texture object.
            HorizontalBlurTexture?.Shutdown();
            HorizontalBlurTexture = null;
            // Release the horizontal blur shader object.
            HorizontalBlurShader?.ShutDown();
            HorizontalBlurShader = null;
            // Release the small ortho window object.
            SmallWindow?.Shutdown();
            SmallWindow = null;
            // Release the down sample render to texture object.
            DownSampleTexture?.Shutdown();
            DownSampleTexture = null;
            // Release the render to texture object.
            RenderTexture?.Shutdown();
            RenderTexture = null;
            // Release the model object.
            BitMap?.Shutdown();
            BitMap = null;
            // Release the texture shader object.
            TextureShader?.ShutDown();
            TextureShader = null;
            // Release the Direct3D object.
            D3D?.ShutDown();
            D3D = null;
        }
コード例 #2
0
        // Methods.
        public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle)
        {
            // Set the size to sample down to.
            int downSampleWidth  = configuration.Width / 2;
            int downSampleHeight = configuration.Height / 2;

            try
            {
                #region Initialize System
                // Create the Direct3D object.
                D3D = new DDX11();

                // Initialize the Direct3D object.
                if (!D3D.Initialize(configuration, windowHandle))
                {
                    return(false);
                }
                #endregion

                #region Initialize Camera
                // Create the camera object
                Camera = new DCamera();

                // Set the initial position of the camera.
                Camera.SetPosition(0.0f, 0.0f, -10.0f);
                #endregion

                // Create the texture shader object.
                TextureShader = new DTextureShader();

                // Create the texture shader object.
                if (!TextureShader.Initialize(D3D.Device, windowHandle))
                {
                    return(false);
                }

                // Create the bitmap object.
                BitMap = new DBitmap();

                // Initialize the bitmap object.
                if (!BitMap.Initialize(D3D.Device, configuration.Width, configuration.Height, "test.bmp", "glowmap.bmp", 256, 32))
                {
                    return(false);
                }

                // Create the render to texture object.
                RenderTexture = new DRenderTexture();

                // Initialize the render to texture object.
                if (!RenderTexture.Initialize(D3D.Device, configuration.Width, configuration.Height, DSystemConfiguration.ScreenNear, DSystemConfiguration.ScreenDepth))
                {
                    return(false);
                }

                // Create the down sample render to texture object.
                DownSampleTexture = new DRenderTexture();

                // Initialize the down sample render to texture object.
                if (!DownSampleTexture.Initialize(D3D.Device, configuration.Width / 2, configuration.Height / 2, DSystemConfiguration.ScreenNear, DSystemConfiguration.ScreenDepth))
                {
                    return(false);
                }

                // Create the small ortho window object.
                SmallWindow = new DOrthoWindow();

                // Initialize the small ortho window object.
                if (!SmallWindow.Initialize(D3D.Device, configuration.Width / 2, configuration.Height / 2))
                {
                    return(false);
                }

                // Create the horizontal blur render to texture object.
                HorizontalBlurTexture = new DRenderTexture();

                // Initialize the horizontal blur render to texture object.
                if (!HorizontalBlurTexture.Initialize(D3D.Device, configuration.Width / 2, configuration.Height / 2, DSystemConfiguration.ScreenNear, DSystemConfiguration.ScreenDepth))
                {
                    return(false);
                }

                // Create the horizontal blur shader object.
                HorizontalBlurShader = new DHorizontalBlurShader();

                // Initialize the horizontal blur shader object.
                if (!HorizontalBlurShader.Initialize(D3D.Device, windowHandle))
                {
                    return(false);
                }

                // Create the vertical blur render to texture object.
                VerticalBlurTexture = new DRenderTexture();

                // Initialize the vertical blur render to texture object.
                if (!VerticalBlurTexture.Initialize(D3D.Device, configuration.Width / 2, configuration.Height / 2, DSystemConfiguration.ScreenNear, DSystemConfiguration.ScreenDepth))
                {
                    return(false);
                }

                // Create the vertical blur shader object.
                VerticalBlurShader = new DVerticalBlurShader();

                // Initialize the vertical blur shader object.
                if (!VerticalBlurShader.Initialize(D3D.Device, windowHandle))
                {
                    return(false);
                }

                // Create the up sample render to texture object.
                UpSampleTexure = new DRenderTexture();

                // Initialize the up sample render to texture object.
                if (!UpSampleTexure.Initialize(D3D.Device, configuration.Width, configuration.Height, DSystemConfiguration.ScreenNear, DSystemConfiguration.ScreenDepth))
                {
                    return(false);
                }

                // Create the full screen ortho window object.
                FullScreenWindow = new DOrthoWindow();

                // Initialize the full screen ortho window object.
                if (!FullScreenWindow.Initialize(D3D.Device, configuration.Width, configuration.Height))
                {
                    return(false);
                }

                // Create the glow map shader object.
                GlowMapShader = new DGlowMapShader();

                // Initialize the glow map shader object.
                if (!GlowMapShader.Initialize(D3D.Device, windowHandle))
                {
                    return(false);
                }

                // Create the glow shader object.
                GlowShader = new DGlowShader();

                // Initialize the glow shader object.
                if (!GlowShader.Initialize(D3D.Device, windowHandle))
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'");
                return(false);
            }
        }