<commit_before>﻿using System;
using System.Collections.Generic;
using IIS.SLSharp.Descriptions;
using OpenTK.Graphics.OpenGL;

namespace IIS.SLSharp.Bindings.OpenTK
{
    sealed class Program: IProgram
    {
        private int _name;

        public List<VariableDescription> VertexIns { get; private set; }

        public Program(IEnumerable<Tuple<int, SourceDescription>> units)
        {
            _name = GL.CreateProgram();

            var merged = SourceDescription.Empty;
            foreach (var unit in units)
            {
                GL.AttachShader(_name, unit.Item1);
                merged = merged.Merge(unit.Item2);
            }
            VertexIns = merged.VertexIns;

            GL.LinkProgram(_name);
            Utilities.CheckGL();
        }

        public void Dispose()
        {
            if (_name != 0)
                GL.DeleteProgram(_name);
            _name = 0;
        }

        public void Activate()
        {
            GL.UseProgram(_name);
            Utilities.CheckGL();
        }

        public void Finish()
        {
            GL.UseProgram(0);
        }

        public int GetUniformIndex(string name)
        {
            var result = GL.GetUniformLocation(_name, name);
            Utilities.CheckGL();
            return result;
        }

        public int GetAttributeIndex(string name)
        {
            var result = GL.GetAttribLocation(_name, name);
            Utilities.CheckGL();
            return result;
        }
    }
}<commit_msg>OpenTK binding changes: Made the GL program handle public accessable via a property. Exposed a method to retrieve the compiled GL source.<commit_after>﻿using System;
using System.Collections.Generic;
using IIS.SLSharp.Descriptions;
using OpenTK.Graphics.OpenGL;
using System.Linq;

namespace IIS.SLSharp.Bindings.OpenTK
{
    sealed class Program: IProgram
    {
        public int Name { get; private set; }

        public List<VariableDescription> VertexIns { get; private set; }

        public Program(IEnumerable<Tuple<int, SourceDescription>> units)
        {
            Name = GL.CreateProgram();

            var merged = SourceDescription.Empty;
            foreach (var unit in units)
            {
                GL.AttachShader(Name, unit.Item1);
                merged = merged.Merge(unit.Item2);
            }
            VertexIns = merged.VertexIns;

            GL.LinkProgram(Name);
            Utilities.CheckGL();
        }

        public void Dispose()
        {
            if (Name != 0)
                GL.DeleteProgram(Name);
            Name = 0;
        }

        public void Activate()
        {
            GL.UseProgram(Name);
            Utilities.CheckGL();
        }

        public void Finish()
        {
            GL.UseProgram(0);
        }

        public int GetUniformIndex(string name)
        {
            var result = GL.GetUniformLocation(Name, name);
            Utilities.CheckGL();
            return result;
        }

        public int GetAttributeIndex(string name)
        {
            var result = GL.GetAttribLocation(Name, name);
            Utilities.CheckGL();
            return result;
        }

        public Tuple<byte[], BinaryFormat> GetBinary()
        {
            int length;
            GL.GetProgram(Name, ProgramParameter.ProgramBinaryLength, out length);

            var bin = new byte[length];
            BinaryFormat format;
            int numRead;
            GL.GetProgramBinary(Name, length, out numRead, out format, bin);
            if (numRead < length)
                bin = bin.Take(length).ToArray();

            return new Tuple<byte[], BinaryFormat>(bin, format);
        }
    }
}
{'fraction_non_alphanumeric': 0.09004867495943754, 'fraction_numerical': 0.0027041644131963224, 'mean_word_length': 1.6271306818181819, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '114794', 'n_tokens_mistral': 987, 'n_tokens_neox': 942, 'n_words': 231}