示例#1
0
        public bool TryGetValue(uint id, out IUniformBinding result)
        {
            result = null;
            if (id < 0)
            {
                return(false);
            }

            var bindings = BindingsByID;

            if (id >= bindings.Length)
            {
                return(false);
            }

            var hasValue = HasValue;

            if (!hasValue[id])
            {
                return(false);
            }

            result = bindings[id];

            return(true);
        }
示例#2
0
        public void Add(uint id, IUniformBinding binding)
        {
            var b         = BindingsByID;
            var hv        = HasValue;
            var bToUnlock = b;

            lock (bToUnlock) {
                if (id >= b.Length)
                {
                    var newLength = id + 12;
                    {
                        var newArray = new IUniformBinding[newLength];
                        Array.Copy(b, newArray, b.Length);
                        b = BindingsByID = newArray;
                    }
                    {
                        var newArray = new bool[newLength];
                        Array.Copy(HasValue, newArray, hv.Length);
                        hv = HasValue = newArray;
                    }
                }

                var existing = b[id];
                if ((existing != null) && (existing != binding))
                {
                    throw new UniformBindingException("Binding table has two entries for the same ID");
                }

                hv[id] = true;
                b[id]  = binding;
            }
        }
示例#3
0
        internal static void Register(Effect effect, IUniformBinding binding)
        {
            List <IUniformBinding> bindings;

            lock (BindingsByEffect) {
                if (!BindingsByEffect.TryGetValue(effect, out bindings))
                {
                    BindingsByEffect[effect] = bindings = new List <IUniformBinding>();
                }

                bindings.Add(binding);
            }
        }
示例#4
0
 public static UniformBinding <T> Cast <T> (this IUniformBinding iub)
     where T : struct
 {
     return((UniformBinding <T>)iub);
 }
示例#5
0
 public static UniformBinding <T> Cast <T> (this IUniformBinding iub)
     where T : unmanaged
 {
     return((UniformBinding <T>)iub);
 }