Beispiel #1
0
        public void EndRender()
        {
            GL.Disable(EnableCap.DepthTest);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);

            GL.BindVertexArray(vao);
            GL.BindBuffer(BufferTarget.ArrayBuffer, vbo);
            GL.BufferData(BufferTarget.ArrayBuffer, vertices.Count * VertexTexture.SizeInBytes, vertices.ToArray(), BufferUsageHint.DynamicDraw);

            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, VertexTexture.SizeInBytes, 0);
            GL.EnableVertexAttribArray(0);
            GL.VertexAttribPointer(1, 2, VertexAttribPointerType.Float, false, VertexTexture.SizeInBytes, Vector3.SizeInBytes);
            GL.EnableVertexAttribArray(1);

            GL.BindBuffer(BufferTarget.ElementArrayBuffer, ebo);
            GL.BufferData(BufferTarget.ElementArrayBuffer, indices.Count * sizeof(ushort), indices.ToArray(), BufferUsageHint.DynamicDraw);

            font.Bind();

            sdf.Use();
            sdf.UploadMatrix("ortho", ref ortho);
            sdf.UploadMatrix("model", ref scale);
            sdf.UploadColor("color", Color4.White);
            GL.DrawElements(BeginMode.Triangles, indices.Count, DrawElementsType.UnsignedShort, 0);

            font.Unbind();

            GL.BindVertexArray(0);

            GL.Disable(EnableCap.Blend);
            GL.Enable(EnableCap.DepthTest);

            vertices.Clear();
            indices.Clear();
        }