예제 #1
0
        // Methods
        public virtual bool Initialize(string title, int width, int height, bool vSync, bool fullScreen, int testTimeSeconds)
        {
            bool result = false;

            if (Configuration == null)
            {
                Configuration = new DSystemConfiguration(title, width, height, fullScreen, vSync);
            }

            // Initialize Window.
            InitializeWindows(title);

            if (Input == null)
            {
                Input = new DInput();
                if (!Input.Initialize(Configuration, RenderForm.Handle))
                {
                    return(false);
                }
            }
            if (Graphics == null)
            {
                Graphics = new DGraphics();
                result   = Graphics.Initialize(Configuration, RenderForm.Handle);
            }

            DPerfLogger.Initialize("RenderForm C# SharpDX: " + Configuration.Width + "x" + Configuration.Height + " VSync:" + DSystemConfiguration.VerticalSyncEnabled + " FullScreen:" + DSystemConfiguration.FullScreen + "   " + RenderForm.Text, testTimeSeconds, Configuration.Width, Configuration.Height);;

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

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

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

            // This seperates out the creation of one DirectSound object and one PrimaryBuffer nad loads as many SecondaryBuffers as there are Sound.LoadAudio Calls. We pass in only the first instanceances DirectSound to play from both secondaryBuffers from the one primaryBuffer.
            Sound.LoadAudio(Sound._DirectSound);
            Sound.Play(0, new SharpDX.Vector3(-2.0f, 0, 0.0f)); // Front Center

            return(result);
        }