Ejemplo n.º 1
0
        public static bool Equals(ref VertexAttributeDescription d1, ref VertexAttributeDescription d2)
        {
            if (d1.IsEnabled == false && d2.IsEnabled == false) return true;

            return
                d1.IsEnabled == d2.IsEnabled &&
                d1.SetFunction == d2.SetFunction &&
                d1.Dimension == d2.Dimension &&
                d1.IsNormalized == d2.IsNormalized &&
                d1.Type == d2.Type &&
                d1.Offset == d2.Offset &&
                d1.Stride == d2.Stride &&
                d1.Divisor == d2.Divisor &&
                d1.Buffer == d2.Buffer;
        }
Ejemplo n.º 2
0
        public static bool Equals(ref VertexAttributeDescription d1, ref VertexAttributeDescription d2)
        {
            if (d1.IsEnabled == false && d2.IsEnabled == false)
            {
                return(true);
            }

            return
                (d1.IsEnabled == d2.IsEnabled &&
                 d1.SetFunction == d2.SetFunction &&
                 d1.Dimension == d2.Dimension &&
                 d1.IsNormalized == d2.IsNormalized &&
                 d1.Type == d2.Type &&
                 d1.Offset == d2.Offset &&
                 d1.Stride == d2.Stride &&
                 d1.Divisor == d2.Divisor &&
                 d1.Buffer == d2.Buffer);
        }
Ejemplo n.º 3
0
        public void SetVertexAttributeF(uint index, IBuffer buffer, VertexAttributeDimension dimension, VertexAttribPointerType type, bool normalized, int stride, int offset, uint divisor = 0)
        {
            var newDesc = new VertexAttributeDescription
            {
                IsEnabled    = true,
                SetFunction  = All.Float,
                Dimension    = dimension,
                Type         = (int)type,
                IsNormalized = normalized,
                Stride       = stride,
                Offset       = offset,
                Divisor      = divisor,
                Buffer       = buffer
            };

            if (VertexAttributeDescription.Equals(ref vertexAttributes[index], ref newDesc))
            {
                return;
            }

            context.Bindings.VertexArray.Set(this);

            if (!vertexAttributes[index].IsEnabled)
            {
                GL.EnableVertexAttribArray(index);
            }

            context.Bindings.Buffers.Array.Set(buffer);
            GL.VertexAttribPointer(index, (int)dimension, (int)type, normalized, stride, (IntPtr)offset);

            if (vertexAttributes[index].Divisor != divisor)
            {
                GL.VertexAttribDivisor(index, divisor);
            }

            vertexAttributes[index] = newDesc;

            if (index >= enabledVertexAttributesRange)
            {
                enabledVertexAttributesRange = index + 1;
            }
        }