Exemplo n.º 1
0
        public bool Initialize(SystemConfiguration configuration, IntPtr windowHandle)
        {
            try
            {
                // Create the Direct3D object.
                D3D = new DX11();
                // Initialize the Direct3D object.
                if (!D3D.Initialize(configuration, windowHandle))
                {
                    return(false);
                }

                // Create the camera object
                Camera = new Camera();

                // Set the initial position of the camera.
                Camera.SetPosition(0, 2, -11);

                // Create the model object.
                Model = new Model();

                // Initialize the model object.
                if (!Model.Initialize(D3D.Device, "Cube.txt", "seafloor.dds"))
                {
                    MessageBox.Show("Could not initialize the model object.");
                    return(false);
                }

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

                // Initialize the texture shader object.
                if (!LightShader.Initialize(D3D.Device, windowHandle))
                {
                    MessageBox.Show("Could not initialize the texture shader object.");
                    return(false);
                }

                // Create the light object.
                Light = new Light();

                // Iniialize the light object.
                Light.SetAmbientColor(0.15f, 0.15f, 0.15f, 1.0f);
                Light.SetDiffuseColor(1, 1, 1f, 1f);
                Light.SetDirection(1, 0, 0);

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'");
                return(false);
            }
        }
Exemplo n.º 2
0
        public bool Initialize(SystemConfiguration configuration, IntPtr windowHandle)
        {
            try
            {
                // Create the Direct3D object.
                D3D = new DX11();
                // Initialize the Direct3D object.
                if (!D3D.Initialize(configuration, windowHandle))
                    return false;

                // Create the camera object
                Camera = new Camera();

                // Set the initial position of the camera.
                Camera.SetPosition(0, 2, -11);

                // Create the model object.
                Model = new Model();

                // Initialize the model object.
                if (!Model.Initialize(D3D.Device, "Cube.txt", "seafloor.dds"))
                {
                    MessageBox.Show("Could not initialize the model object.");
                    return false;
                }

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

                // Initialize the texture shader object.
                if (!LightShader.Initialize(D3D.Device, windowHandle))
                {
                    MessageBox.Show("Could not initialize the texture shader object.");
                    return false;
                }

                // Create the light object.
                Light = new Light();

                // Iniialize the light object.
                Light.SetAmbientColor(0.15f, 0.15f, 0.15f, 1.0f);
                Light.SetDiffuseColor(1, 1, 1f, 1f);
                Light.SetDirection(1, 0, 0);

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