public bool Render(DDX11 D3DDevice, DShaderManager shaderManager, Matrix worldMatrix, Matrix baseViewMatrix, Matrix orthoMatrix)
        {
            // Turn off the Z buffer and enable alpha blending to begin 2D rendering.
            D3DDevice.TurnZBufferOff();
            D3DDevice.TurnOnAlphaBlending();

            // Render the fps string.
            FpsString.Render(D3DDevice.DeviceContext, shaderManager, worldMatrix, baseViewMatrix, orthoMatrix, Font1.Texture.TextureResource);

            // Render the position and rotation strings.
            foreach (DText position in PositionStrings)
            {
                position.Render(D3DDevice.DeviceContext, shaderManager, worldMatrix, baseViewMatrix, orthoMatrix, Font1.Texture.TextureResource);
            }

            // Render the video card strings.
            foreach (DText vidString in VideoStrings)
            {
                vidString.Render(D3DDevice.DeviceContext, shaderManager, worldMatrix, baseViewMatrix, orthoMatrix, Font1.Texture.TextureResource);
            }

            // Turn the Z buffer back on and disable alpha blending now that the 2D rendering has completed.
            D3DDevice.TurnZBufferOn();
            D3DDevice.TurnOffAlphaBlending();

            return(true);
        }
        public void ShutDown()
        {
            // Release the render count strings.
            foreach (DText aSent in RenderCountStrings)
            {
                aSent?.Shutdown();
            }
            RenderCountStrings = null;

            // Release the position text strings.
            foreach (DText sent in VideoStrings)
            {
                sent?.Shutdown();
            }
            VideoStrings = null;

            // Release the position text strings.
            foreach (DText sentence in PositionStrings)
            {
                sentence?.Shutdown();
            }
            PositionStrings = null;

            PreviousPositions = null;
            // Release the fps text string.
            FpsString?.Shutdown();
            FpsString = null;
            // Release the font object.
            Font1?.Shutdown();
            Font1 = null;
        }
Exemplo n.º 3
0
        public void Dispose()
        {
            foreach (var videoString in VideoStrings)
            {
                videoString?.Dispose();
            }

            VideoStrings = null;

            foreach (var positionString in PositionStrings)
            {
                positionString?.Dispose();
            }

            PositionStrings = null;

            PreviousPositions = null;

            FpsString?.Dispose();
            FpsString = null;

            Font.Dispose();
            Font = null;
            {
            }
        }
Exemplo n.º 4
0
        private bool UpdateFPSString(int fps, DeviceContext deviceContext)
        {
            var result = true;

            var colour = new Colour(NamedColour.Black);

            if (PreviousFPS != fps)
            {
                PreviousFPS = fps;

                fps = Math.Min(99999, fps);

                var finalString = $"FPS: {fps}";

                if (fps >= 60)
                {
                    colour.ChangeTo(NamedColour.Green);
                }
                else if (fps >= 30)
                {
                    colour.ChangeTo(NamedColour.Yellow);
                }
                else
                {
                    colour.ChangeTo(NamedColour.Red);
                }

                result &= FpsString.UpdateSentence(Font, finalString, new Coordinate2D <int>(10, 50), colour, deviceContext);
            }

            return(result);
        }
        private bool UpdateFPSString(int fps, DeviceContext deviceContext)
        {
            float red = 0.0f, green = 0.0f, blue = 0.0f;

            // Check if the fps from the previous frame was the same, if so don't need to update the text string.
            if (PreviousFPS == fps)
            {
                return(true);
            }

            // Store the fps for checking next frame.
            PreviousFPS = fps;

            // Truncate the fps to below 100,000.
            if (fps > 99999)
            {
                fps = 99999;
            }

            // Setup the fps string.
            string finalString = String.Format("FPS: {0}", fps);

            // If fps is 60 or above set the fps color to green.
            if (fps >= 60)
            {
                red   = 0.0f;
                green = 1.0f;
                blue  = 0.0f;
            }
            // If fps is below 60 set the fps color to yellow.
            if (fps < 60)
            {
                red   = 1.0f;
                green = 1.0f;
                blue  = 0.0f;
            }
            // If fps is below 30 set the fps color to red.
            if (fps < 60)
            {
                red   = 1.0f;
                green = 0.0f;
                blue  = 0.0f;
            }

            // Update the sentence vertex buffer with the new string information.
            if (!FpsString.UpdateSentence2(Font1, finalString, 10, 50, red, green, blue, deviceContext))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 6
0
        public void Render(DirectX directXDevice, ShaderManager shaderManager, Matrix worldMatrix, Matrix viewMatrix, Matrix orthoMatrix)
        {
            directXDevice.SetZBuffer(false);
            directXDevice.SetAlphaBlending(true);

            FpsString.Render(directXDevice.DeviceContext, shaderManager, worldMatrix, viewMatrix, orthoMatrix, Font.Texture.TextureResource);

            foreach (var positionString in PositionStrings)
            {
                positionString.Render(directXDevice.DeviceContext, shaderManager, worldMatrix, viewMatrix, orthoMatrix, Font.Texture.TextureResource);
            }

            foreach (var videoString in VideoStrings)
            {
                videoString.Render(directXDevice.DeviceContext, shaderManager, worldMatrix, viewMatrix, orthoMatrix, Font.Texture.TextureResource);
            }

            directXDevice.SetZBuffer(true);
            directXDevice.SetAlphaBlending(false);
        }