public bool Frame()
        {
            // Check if the user pressed escape and wants to exit the application.
            if (!Input.Frame() || Input.IsEscapePressed())
            {
                return(false);
            }

            // Update the system stats.
            Timer.Frame2();
            if (DPerfLogger.IsTimedTest)
            {
                DPerfLogger.Frame(Timer.FrameTime);
                if (Timer.CumulativeFrameTime >= DPerfLogger.TestTimeInSeconds * 1000)
                {
                    return(false);
                }
            }

            // Finally render the graphics to the screen.
            if (!Graphics.Frame())
            {
                return(false);
            }

            // Finally render the graphics to the screen.
            if (!Graphics.Render())
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public bool Frame()
        {
            // Read the user input.
            if (!DApplication.Input.Frame() || DApplication.Input.IsEscapePressed())
            {
                return(false);
            }

            // Update the system stats.
            Timer.Frame2();
            if (DPerfLogger.IsTimedTest)
            {
                DPerfLogger.Frame(Timer.FrameTime);
                if (Timer.CumulativeFrameTime >= DPerfLogger.TestTimeInSeconds * 1000)
                {
                    return(false);
                }
            }

            // Do the frame processing for the application object.
            if (!DApplication.Frame(Timer.FrameTime))
            {
                return(false);
            }

            return(true);
        }
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);

            // 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);
        }
Ejemplo n.º 4
0
        public bool Frame()
        {
            // Check if the user pressed escape and wants to exit the application.
            if (!App.Input.Frame() || App.Input.IsEscapePressed())
            {
                return(false);
            }

            // Update the system stats.
            Timer.Frame2();
            if (DPerfLogger.IsTimedTest)
            {
                DPerfLogger.Frame(Timer.FrameTime);
                if (Timer.CumulativeFrameTime >= DPerfLogger.TestTimeInSeconds * 1000)
                {
                    return(false);
                }
            }

            // Do the frame processing for the applicatioin object.
            if (!App.Frame())
            {
                return(false);
            }

            return(true);
        }
        // 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.º 6
0
        public bool Frame()
        {
            // Read the user input.
            if (!Input.Frame() || Input.IsEscapePressed())
            {
                return(false);
            }

            // Update the system stats.
            Timer.Frame2();
            if (DPerfLogger.IsTimedTest)
            {
                DPerfLogger.Frame(Timer.FrameTime);
                if (Timer.CumulativeFrameTime >= DPerfLogger.TestTimeInSeconds * 1000)
                {
                    return(false);
                }
            }

            // Do the frame input processing.
            if (!HandleInput(Timer.FrameTime))
            {
                return(false);
            }

            // Get the view point position/rotation.
            // Do the frame processing for the graphics object.
            if (!Graphics.Frame(Position.PositionX, Position.PositionY, Position.PositionZ, Position.RotationX, Position.RotationY, Position.RotationZ, Timer.FrameTime))
            {
                return(false);
            }

            return(true);
        }
        public bool Frame()
        {
            // Do the input frame processing if Escapsewas pressed then Exit.
            if (!Input.Frame() || Input.IsEscapePressed())
            {
                return(false);
            }

            // Update the system stats.
            Timer.Frame2();
            if (DPerfLogger.IsTimedTest)
            {
                DPerfLogger.Frame(Timer.FrameTime);
                if (Timer.CumulativeFrameTime >= DPerfLogger.TestTimeInSeconds * 1000)
                {
                    return(false);
                }
            }

            // Do the frame processing for the graphics object.Position
            if (!Graphics.Frame())
            {
                return(false);
            }

            // Finally render the graphics to the screen.
            if (!Graphics.Render())
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 8
0
        public bool Frame()
        {
            // Do the input frame processing
            if (!Input.Frame() || Input.IsEscapePressed())
            {
                return(false);
            }

            // Update the system stats.
            Timer.Frame2();
            if (DPerfLogger.IsTimedTest)
            {
                DPerfLogger.Frame(Timer.FrameTime);
                if (Timer.CumulativeFrameTime >= DPerfLogger.TestTimeInSeconds * 1000)
                {
                    return(false);
                }
            }

            // Do the frame processing for the graphics object.
            if (!Graphics.Frame())
            {
                return(false);
            }

            return(true);
        }
        public bool Frame()
        {
            // Check if the user pressed escape and wants to exit the application.
            if (!Input.Frame() || Input.IsEscapePressed())
            {
                return(false);
            }

            // Performance Logging.
            Graphics.Timer.Frame2();
            if (DPerfLogger.IsTimedTest)
            {
                DPerfLogger.Frame(Graphics.Timer.FrameTime);
                if (Graphics.Timer.CumulativeFrameTime >= DPerfLogger.TestTimeInSeconds * 1000)
                {
                    return(false);
                }
            }

            // Do the frame processing for the graphics object.mouseX, mouseY, Input.PressedKeyss
            if (!Graphics.Frame())
            {
                return(false);
            }

            // Finally render the graphics to the screen.   mouseX, mouseY
            if (!Graphics.Render())
            {
                return(false);
            }

            return(true);
        }
        public void ShutDown()
        {
            ShutdownWindows();
            DPerfLogger.ShutDown();

            Graphics?.ShutDown();
            Graphics      = null;
            Input         = null;
            Configuration = null;
        }
Ejemplo n.º 11
0
        public void ShutDown()
        {
            ShutdownWindows();
            DPerfLogger.ShutDown();

            // Release the graphics object.
            DApplication?.Shutdown();
            DApplication  = null;
            Configuration = null;
        }
Ejemplo n.º 12
0
        public void ShutDown()
        {
            // Shitdown the Window and the TestLogger for writing Test Results.
            ShutdownWindows();
            DPerfLogger.ShutDown();

            // Release the graphics object.
            DApplication?.Shutdown();
            DApplication  = null;
            Configuration = null;
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
0
        public void ShutDown()
        {
            ShutdownWindows();
            DPerfLogger.ShutDown();

            // Release graphics and related objects.
            Graphics?.Shutdown();
            Graphics = null;
            // Release DriectInput related object.
            Input?.Shutdown();
            Input         = null;
            Configuration = null;
        }
Ejemplo n.º 15
0
        public void ShutDown()
        {
            ShutdownWindows();
            DPerfLogger.ShutDown();

            // Release the Timer object
            Timer = null;

            // Release the graphics object.
            App?.ShutDown();
            App           = null;
            Configuration = null;
        }
Ejemplo n.º 16
0
        public void ShutDown()
        {
            // Close and Dispose the actual window adn handle.
            ShutdownWindows();
            DPerfLogger.ShutDown();

            // Release the Timer object
            Timer = null;

            // Release the graphics object.
            DApplication?.Shutdown();
            DApplication  = null;
            Configuration = null;
        }
        public bool Frame()
        {
            // Check if the user pressed escape and wants to exit the application.
            if (!Input.Frame() || Input.IsEscapePressed())
            {
                return(false);
            }

            // Update the system stats.
            Timer.Frame2();
            if (DPerfLogger.IsTimedTest)
            {
                DPerfLogger.Frame(Timer.FrameTime);
                if (Timer.CumulativeFrameTime >= DPerfLogger.TestTimeInSeconds * 1000)
                {
                    return(false);
                }
            }

            // Set the frame time for calculating the updated position.
            Position.FrameTime = Timer.FrameTime;

            // Check if the left or right arrow key has been pressed, if so rotate the camera accordingly.
            bool keydown = Input.IsLeftArrowPressed();

            Position.TurnLeft(keydown);
            keydown = Input.IsRightArrowPressed();
            Position.TurnRight(keydown);
            keydown = Input.IsUpArrowPressed();
            Position.LookUp(keydown);
            keydown = Input.IsDownArrowPressed();
            Position.LookDown(keydown);

            // Do the frame processing for the graphics object.
            if (!Graphics.Frame(Position))
            {
                return(false);
            }

            // Finally render the graphics to the screen.
            if (!Graphics.Render())
            {
                return(false);
            }

            return(true);
        }
        // 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.º 19
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);
        }
Ejemplo n.º 20
0
        public bool Frame()
        {
            if (Input.IsKeyDown(Keys.Escape))
            {
                return(false);
            }

            Graphics.Timer.Frame2();
            if (DPerfLogger.IsTimedTest)
            {
                DPerfLogger.Frame(Graphics.Timer.FrameTime);
                if (Graphics.Timer.CumulativeFrameTime >= DPerfLogger.TestTimeInSeconds * 1000)
                {
                    return(false);
                }
            }

            return(Graphics.Frame());
        }
        public void ShutDown()
        {
            ShutdownWindows();
            DPerfLogger.ShutDown();

            // Release the Timer object
            Timer = null;
            // Release the FPS object
            FPS = null;

            // Release the CPU object
            CPU?.Shutdown();
            CPU = null;
            // Release graphics and related objects.
            Graphics?.Shutdown();
            Graphics = null;
            // Release DriectInput related object.
            Input?.Shutdown();
            Input         = null;
            Configuration = null;
        }
Ejemplo n.º 22
0
        public bool Frame()
        {
            // Do the input frame processing
            if (!Input.Frame() || Input.IsEscapePressed())
            {
                return(false);
            }

            // Update the system stats.
            Timer.Frame2();
            if (DPerfLogger.IsTimedTest)
            {
                DPerfLogger.Frame(Timer.FrameTime);
                if (Timer.CumulativeFrameTime >= DPerfLogger.TestTimeInSeconds * 1000)
                {
                    return(false);
                }
            }

            //// Set the frame time for calculating the updated position.
            Position.FrameTime = Timer.FrameTime;

            // Handle the input.
            bool keydown = Input.IsLeftArrowPressed();

            Position.MoveLeft(keydown);
            keydown = Input.IsRightArrowPressed();
            Position.MoveRight(keydown);

            // Get the view point position/rotation.
            SharpDX.Vector3 currentViewPort = new SharpDX.Vector3(Position.PositionX, Position.PositionY, Position.PositionZ);

            // Do the frame processing for the graphics object.
            if (!Graphics.Frame(currentViewPort.X, currentViewPort.Y, currentViewPort.Z))
            {
                return(false);
            }

            return(true);
        }
        public bool Frame()
        {
            // Check if the user pressed escape and wants to exit the application.
            if (Input.IsKeyDown(Keys.Escape))
            {
                return(false);
            }

            // Performance Logging.
            Graphics.Timer.Frame2();
            if (DPerfLogger.IsTimedTest)
            {
                DPerfLogger.Frame(Graphics.Timer.FrameTime);
                if (Graphics.Timer.CumulativeFrameTime >= DPerfLogger.TestTimeInSeconds * 1000)
                {
                    return(false);
                }
            }

            // Do the frame processing for the graphics object.
            return(Graphics.Frame());
        }
Ejemplo n.º 24
0
        public bool Frame()
        {
            // Check if the user pressed escape and wants to exit the application.
            if (!Input.Frame() || Input.IsEscapePressed())
            {
                return(false);
            }

            // Update the system stats.
            Timer.Frame2();
            if (DPerfLogger.IsTimedTest)
            {
                DPerfLogger.Frame(Timer.FrameTime);
                if (Timer.CumulativeFrameTime >= DPerfLogger.TestTimeInSeconds * 1000)
                {
                    return(false);
                }
            }

            // The following Rotates the entire scenes around the speakers.
            // Get current positions of each secondarySound in 3dSpace.
            SharpDX.Vector3 SoundBufferPosition = Sound._3DSecondarySoundBuffer.Position;
            // Create a reset Matreix in the o,o,o home position.
            SharpDX.Matrix rotationMatrix = SharpDX.Matrix.Identity;
            // Rotate it slightly.
            rotationMatrix = SharpDX.Matrix.RotationY(0.0002f);
            // And apply that rotation towards each coordinate for each secondarySoundBuffer being played in 3D space.
            SharpDX.Vector3 rotatedCoordinates = SharpDX.Vector3.TransformCoordinate(SoundBufferPosition, rotationMatrix);
            // And assign back the rotated coordinates to each Secondary Soundbuffer that will now been roated.
            Sound._3DSecondarySoundBuffer.Position = rotatedCoordinates;

            // Finally render the graphics to the screen.
            if (!Graphics.Render())
            {
                return(false);
            }

            return(true);
        }
        public void ShutDown()
        {
            DPerfLogger.ShutDown();

            // Release the light object.
            Light = null;
            // Release the position object.
            Position = null;
            // Release the timer object.
            Timer = null;
            // Release the camera object.
            Camera = null;

            // Release the shadow shader object.
            ShadowShader?.ShutDown();
            ShadowShader = null;
            // Release the transparent depth shader object.
            TransparentDepthShader?.ShutDown();
            TransparentDepthShader = null;
            // Release the depth shader object.
            DepthShader?.ShutDown();
            DepthShader = null;
            // Release the render to texture object.
            RenderTexture?.Shutdown();
            RenderTexture = null;
            // Release the tree object.
            TreeModel?.Shutdown();
            TreeModel = null;
            // Release the model object.
            GroundModel?.Shutdown();
            GroundModel = null;
            // Release the input object.
            Input?.Shutdown();
            Input = null;
            // Release the Direct3D object.
            D3D?.ShutDown();
            D3D = null;
        }
        public bool Frame()
        {
            // Read the user input.
            if (!Input.Frame() || Input.IsEscapePressed())
            {
                return(false);
            }

            // Update the system stats.
            Timer.Frame2();
            if (DPerfLogger.IsTimedTest)
            {
                DPerfLogger.Frame(Timer.FrameTime);
                if (Timer.CumulativeFrameTime >= DPerfLogger.TestTimeInSeconds * 1000)
                {
                    return(false);
                }
            }

            // Do the frame input processing.
            if (!HandleMovementInput(Timer.FrameTime))
            {
                return(false);
            }

            // Update the scene lighting.
            UpdateLighting();

            // Render the graphics.
            if (!Render())
            {
                return(false);
            }

            return(true);
        }
        // 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);
            }
        }