OpenTkEngine.Core.Graphics.BindCorner C# (CSharp) Method

BindCorner() private static method

private static BindCorner ( ) : void
return void
        private static void BindCorner()
        {
            if (_cornerVao == 0)
            {
                _cornerVao = GL.GenVertexArray();
                _cornerVbos = new int[2];
                GL.GenBuffers(2, _cornerVbos);

                _cornerVerts[0] = 1.0f;
                _cornerVerts[1] = 1.0f;
                float segments = _cornerIndices.Length - 1;
                for (int i = 0; i < segments; i++)
                {
                    float angle = MathHelper.DegreesToRadians(90) * ((float)i / (segments - 1)) - (float)Math.PI;
                    _cornerVerts[(i + 1) * 3] = (float)Math.Sin(angle) + 1.0f;
                    _cornerVerts[((i + 1) * 3) + 1] = (float)Math.Cos(angle) + 1.0f;
                    _cornerIndices[i + 1] = i + 1;
                }

                GL.BindVertexArray(_cornerVao);
                _currentVao = _cornerVao;

                GL.BindBuffer(BufferTarget.ArrayBuffer, _cornerVbos[0]);
                GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(_cornerVerts.Length * sizeof(float)), _cornerVerts, BufferUsageHint.StaticDraw);

                int size;
                GL.GetBufferParameter(BufferTarget.ArrayBuffer, BufferParameterName.BufferSize, out size);
                if (_cornerVerts.Length * sizeof(float) != size)
                {
                    throw new ApplicationException("Vertex data not loaded onto graphics card correctly");
                }

                int vPositionLocation = _currentShader.GetAttribLocation("vPosition");
                GL.EnableVertexAttribArray(vPositionLocation);
                GL.VertexAttribPointer(vPositionLocation, 3, VertexAttribPointerType.Float, false, 3 * sizeof(float), 0);

                GL.BindBuffer(BufferTarget.ElementArrayBuffer, _cornerVbos[1]);
                GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(_cornerIndices.Length * sizeof(int)), _cornerIndices, BufferUsageHint.StaticDraw);

                GL.GetBufferParameter(BufferTarget.ElementArrayBuffer, BufferParameterName.BufferSize, out size);
                if (_cornerIndices.Length * sizeof(int) != size)
                {
                    throw new ApplicationException("Index data not loaded onto graphics card correctly");
                }
            }
            else
            {
                GL.BindVertexArray(_cornerVao);
                _currentVao = _cornerVao;
            }
        }