Exemplo n.º 1
0
        internal void Bind(GraphicsDevice graphicsDevice, IntPtr source)
        {
            if (_lastUsed == this && _lastUsedPointer == source && _lastUsedShader == graphicsDevice.ActiveShader)
                return;

            for (int i = 0; i < graphicsDevice.ActiveShader.Input.Length; i++)
            {
                VertexElement element = null;
                ShaderInput input = graphicsDevice.ActiveShader.Input[i];

                for (int j = 0; j < _vertexElements.Length; j++)
                {
                    if (_vertexElements[j].VertexElementUsage == input.Usage && _vertexElements[j].UsageIndex == input.UsageIndex)
                    {
                        element = _vertexElements[j];
                        break;
                    }
                }

                if (element != null)
                {
                    GL.EnableVertexAttribArray(input.Index);
                    GL.VertexAttribPointer(input.Index, element.ElementCount, element.VertexAttribPointerType, !element.IsNormalized, VertexStride, source + element.Offset);
                }
                else
                {
                    GL.DisableVertexAttribArray(input.Index);
                }
            }

            _lastUsed = this;
            _lastUsedPointer = source;
            _lastUsedShader = graphicsDevice.ActiveShader;
        }
Exemplo n.º 2
0
 public VertexBuffer(GraphicsDevice graphicsDevice, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
     : base(graphicsDevice, BufferTarget.ArrayBuffer, vertexDeclaration.VertexStride, vertexCount, usage)
 {
     VertexDeclaration = vertexDeclaration;
 }
Exemplo n.º 3
0
 public static void ResetLastUsedCache()
 {
     _lastUsed = null;
     _lastUsedPointer = IntPtr.Zero;
     _lastUsedShader = null;
 }