Ejemplo n.º 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);

            // Create the application wrapper object.
            DApplication = new DApplication();

            // Initialize the application wrapper object.
            if (!DApplication.Initialize(Configuration, RenderForm.Handle))
            {
                return(false);
            }

            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);
            }

            return(result);
        }
        // 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();
                Input.Initialize();
            }
            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);

            return(result);
        }
Ejemplo n.º 3
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);
        }
        // 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 the FpsClass.
            FPS = new DFPS();
            FPS.Initialize();

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

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

            return(result);
        }
Ejemplo n.º 5
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 position object.
            Position = new DPosition();

            // Set the initial position of the viewer to the same as the initial camera position.
            SharpDX.Vector3 camPos = Graphics.Camera.GetPosition();
            Position.SetPosition(camPos.X, camPos.Y, camPos.Z);

            return(result);
        }
        // Methods.
        public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle, string appTitle, int testTimeSeconds)
        {
            try
            {
                // Create the input object.
                Input = new DInput();

                // Initialize the input object.
                if (!Input.Initialize(configuration, windowHandle))
                {
                    return(false);
                }

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

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

                // Create the timer object.
                Timer = new DTimer();

                // Initialize the timer object.
                if (!Timer.Initialize())
                {
                    return(false);
                }

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

                // Set the initial position.
                Position.SetPosition(0.0f, 7.0f, -11.0f);
                Position.SetRotation(20.0f, 0.0f, 0.0f);
                #endregion

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

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

                // Initialize the light object.
                Light.GenerateOrthoMatrix(15.0f, 15.0f, SHADOWMAP_DEPTH, SHADOWMAP_NEAR);
                #endregion

                // Create the ground model object.
                GroundModel = new DModel();

                // Initialize the ground model object.
                if (!GroundModel.Initialize(D3D.Device, "plane01.txt", "dirt.bmp", 2.0f))
                {
                    return(false);
                }

                // Set the position for the ground model.
                GroundModel.SetPosition(0.0f, 1.0f, 0.0f);

                // Create the tree object.
                TreeModel = new DTreeModel();

                // Initialize the shadow shader object.
                if (!TreeModel.Initialize(D3D.Device, "trunk001.txt", "trunk001.bmp", "leaf001.txt", "leaf001.bmp", 0.1f))
                {
                    return(false);
                }

                // Set the position for the tree model.
                TreeModel.SetPosition(0.0f, 1.0f, 0.0f);

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

                // Initialize the render to texture object.
                if (!RenderTexture.Initialize(D3D.Device, SHADOWMAP_WIDTH, SHADOWMAP_HEIGHT, SHADOWMAP_DEPTH, SHADOWMAP_NEAR))
                {
                    return(false);
                }

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

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

                // Create the transparent depth shader object.
                TransparentDepthShader = new DTransparentDepthShader();

                // Initialize the transparent depth shader object.
                if (!TransparentDepthShader.Initialize(D3D.Device, windowHandle))
                {
                    return(false);
                }

                // Create the shadow shader object.
                ShadowShader = new DShadowShader();

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

                DPerfLogger.Initialize("WinForms C# SharpDX: " + configuration.Width + "x" + configuration.Height + " VSync:" + DSystemConfiguration.VerticalSyncEnabled + " FullScreen:" + DSystemConfiguration.FullScreen + "   " + appTitle, testTimeSeconds, configuration.Width, configuration.Height);

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