/// <summary>
        ///     Draw the screen element.
        /// </summary>
        /// <param name="offset">The relative position on the screen.</param>
        /// <param name="scaling">The scale of the screen element.</param>
        public void Draw(Vector2 offset, float scaling)
        {
            if (disposed)
            {
                return;
            }

            var     screenSize = Screen.Size.ToVector2();
            Vector3 scale      = new Vector3(scaling, scaling, z: 1f) * screenSize.Length;
            var     translate  = new Vector3((offset - new Vector2(x: 0.5f, y: 0.5f)) * screenSize);

            Matrix4 model = Matrix4.Identity * Matrix4.CreateScale(scale) * Matrix4.CreateTranslation(translate);

            drawGroup.BindVertexArray();

            Shaders.ScreenElement.Use();

            Shaders.ScreenElement.SetMatrix4("model", model);
            Shaders.ScreenElement.SetVector3("color", color);
            Shaders.ScreenElement.SetInt("tex", texUnit);

            drawGroup.DrawElements(PrimitiveType.Triangles);

            GL.BindVertexArray(array: 0);
            GL.UseProgram(program: 0);
        }
Example #2
0
        /// <summary>
        ///     Draw the bounding box.
        /// </summary>
        /// <param name="position">The position at which the box should be drawn.</param>
        public void Draw(Vector3 position)
        {
            if (disposed)
            {
                return;
            }

            drawGroup.BindVertexArray();

            Shaders.Selection.Use();

            Matrix4 model = Matrix4.Identity * Matrix4.CreateTranslation(position);

            Shaders.Selection.SetMatrix4("model", model);
            Shaders.Selection.SetMatrix4("view", Application.Client.Player.GetViewMatrix());
            Shaders.Selection.SetMatrix4("projection", Application.Client.Player.GetProjectionMatrix());

            drawGroup.DrawElements(PrimitiveType.Lines);

            GL.BindVertexArray(array: 0);
            GL.UseProgram(program: 0);
        }
        /// <summary>
        ///     Draw the overlay.
        /// </summary>
        public void Draw()
        {
            if (disposed)
            {
                return;
            }

            GL.Enable(EnableCap.Blend);

            drawGroup.BindVertexArray();

            Shaders.Overlay.Use();

            Shaders.Overlay.SetInt("texId", textureId);
            Shaders.Overlay.SetInt("tex", samplerId);

            drawGroup.DrawElements(PrimitiveType.Triangles);

            GL.BindVertexArray(array: 0);
            GL.UseProgram(program: 0);

            GL.Disable(EnableCap.Blend);
        }