Ejemplo n.º 1
0
        // Methods.
        public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle)
        {
            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, 2.0f, -10.0f);
                #endregion

                #region Initialize Models
                // Create the Flat Plane  model class.
                FloorModel = new DModel();

                // Create the floor model object.
                if (!FloorModel.Initialize(D3D.Device, "floor.txt"))
                {
                    MessageBox.Show("Could not initialize the ground model object", "Error", MessageBoxButtons.OK);
                    return(false);
                }

                // Create the depth shader object.
                DepthShader = new DDepthShader();

                if (!DepthShader.Initialize(D3D.Device, windowHandle))
                {
                    return(false);
                }
                #endregion

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'");
                return(false);
            }
        }
Ejemplo n.º 2
0
        public void Shutdown()
        {
            // Release the camera object.
            Camera = null;

            // Release the depth shader object.
            DepthShader?.ShutDown();
            DepthShader = null;
            // Release the Floor model object.
            FloorModel?.Shutdown();
            FloorModel = null;
            // Release the Direct3D object.
            D3D?.ShutDown();
            D3D = null;
        }