Exemple #1
0
        public bool Initialize()
        {
            // Initialize the system configuration.
            if (Configuration == null)
            {
                Configuration = new SystemConfiguration();
            }

            // Initialize windows api.
            InitializeWindows();

            if (Input == null)
            {
                Input = new InputClass();
                if (!Input.Initialize(Configuration, MainForm.Handle))
                {
                    return(false);
                }
            }

            if (Graphics == null)
            {
                Graphics = new GraphicsClass();
                if (!Graphics.Initialize(Configuration, MainForm.Handle))
                {
                    return(false);
                }
            }

            // Create the sound object
            Sound = new WaveSound("sound01.wav");

            // Initialize the sound object.
            if (!Sound.Initialize(MainForm.Handle))
            {
                MessageBox.Show("Could not initialize Direct Sound", "Error", MessageBoxButtons.OK);
                return(false);
            }

            // Create and initialize the FPS object.
            FPS = new FPS();
            FPS.Initialize();

            // Create and initialize the CPU.
            CPU = new CPU();
            CPU.Initialize();

            // Create and initialize Timer.
            Timer = new Timer();
            if (!Timer.Initialize())
            {
                MessageBox.Show("Could not initialize Timer object", "Error", MessageBoxButtons.OK);
                return(false);
            }

            // Create the position object.
            Position = new Position();

            return(true);
        }
Exemple #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))
                {
                    MessageBox.Show("Could not initialize Direct3D", "Error", MessageBoxButtons.OK);
                    return false;
                }

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

                // Initialize a base view matrix the camera for 2D user interface rendering.
                Camera.SetPosition(0, 0, -10);
                Camera.Render();
                var baseViewMatrix = Camera.ViewMatrix;

                // Create the model class.
                BumpMapModel = new BumpMapModel();

                // Initialize the model object.
                if (!BumpMapModel.Initialize(D3D.Device, "sphere.txt", new[] { "stone01.dds", "bump01.dds" }))
                {
                    MessageBox.Show("Could not initialize the model object", "Error", MessageBoxButtons.OK);
                    return false;
                }

                // Create the bump map shader object.
                BumpMapShader = new BumpMapShader();

                // Initialize the bump map shader object.
                if (!BumpMapShader.Initialize(D3D.Device, windowHandle))
                {
                    MessageBox.Show("Could not initialize the light shader", "Error", MessageBoxButtons.OK);
                    return false;
                }

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

                // Initialize the light object.
                Light.SetAmbientColor(0.15f, 0.15f, 0.15f, 1.0f);
                Light.SetDiffuseColor(1, 1, 1, 1f);
                Light.SetDirection(0, 0, 1);
                Light.SetSpecularColor(0, 1, 1, 1);
                Light.SetSpecularPower(32);

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'");
                return false;
            }
        }
Exemple #3
0
        public bool Initialize()
        {
            // Initialize the system configuration.
            if(Configuration == null)
                Configuration = new SystemConfiguration();

            // Initialize windows api.
            InitializeWindows();

            if (Input == null)
            {
                Input = new InputClass();
                if (!Input.Initialize(Configuration, MainForm.Handle))
                    return false;
            }

            if (Graphics == null)
            {
                Graphics = new GraphicsClass();
                if (!Graphics.Initialize(Configuration, MainForm.Handle))
                    return false;
            }

            // Create the sound object
            Sound = new WaveSound("sound01.wav");

            // Initialize the sound object.
            if (!Sound.Initialize(MainForm.Handle))
            {
                MessageBox.Show("Could not initialize Direct Sound", "Error", MessageBoxButtons.OK);
                return false;
            }

            // Create and initialize the FPS object.
            FPS = new FPS();
            FPS.Initialize();

            // Create and initialize the CPU.
            CPU = new CPU();
            CPU.Initialize();

            // Create and initialize Timer.
            Timer = new Timer();
            if (!Timer.Initialize())
            {
                MessageBox.Show("Could not initialize Timer object", "Error", MessageBoxButtons.OK);
                return false;
            }

            // Create the position object.
            Position = new Position();

            return true;
        }