Vertex attribute information for a particular shader/vertex declaration combination.
예제 #1
0
        internal void Apply(Shader shader, IntPtr offset)
        {
            int hashCode = shader.GetHashCode();

            VertexDeclaration.VertexDeclarationAttributeInfo declarationAttributeInfo;
            if (!this.shaderAttributeInfo.TryGetValue(hashCode, out declarationAttributeInfo))
            {
                declarationAttributeInfo = new VertexDeclaration.VertexDeclarationAttributeInfo(this.GraphicsDevice.MaxVertexAttributes);
                foreach (VertexElement element in this._elements)
                {
                    int attribLocation = shader.GetAttribLocation(element.VertexElementUsage, element.UsageIndex);
                    if (attribLocation >= 0)
                    {
                        declarationAttributeInfo.Elements.Add(new VertexDeclaration.VertexDeclarationAttributeInfo.Element()
                        {
                            Offset                  = element.Offset,
                            AttributeLocation       = attribLocation,
                            NumberOfElements        = GraphicsExtensions.OpenGLNumberOfElements(element.VertexElementFormat),
                            VertexAttribPointerType = GraphicsExtensions.OpenGLVertexAttribPointerType(element.VertexElementFormat),
                            Normalized              = GraphicsExtensions.OpenGLVertexAttribNormalized(element)
                        });
                        declarationAttributeInfo.EnabledAttributes[attribLocation] = true;
                    }
                }
                this.shaderAttributeInfo.Add(hashCode, declarationAttributeInfo);
            }
            foreach (VertexDeclaration.VertexDeclarationAttributeInfo.Element element in declarationAttributeInfo.Elements)
            {
                GL.VertexAttribPointer(element.AttributeLocation, element.NumberOfElements, element.VertexAttribPointerType, element.Normalized, this.VertexStride, (IntPtr)(offset.ToInt64() + (long)element.Offset));
            }
            this.GraphicsDevice.SetVertexAttributeArray(declarationAttributeInfo.EnabledAttributes);
        }
 public BufferBindingInfo(VertexDeclaration.VertexDeclarationAttributeInfo attributeInfo, int vertexOffset, int instanceFrequency, int vbo)
 {
     AttributeInfo     = attributeInfo;
     VertexOffset      = vertexOffset;
     InstanceFrequency = instanceFrequency;
     Vbo = vbo;
 }
예제 #3
0
 internal void Apply(Shader shader, IntPtr offset)
 {
   int hashCode = shader.GetHashCode();
   VertexDeclaration.VertexDeclarationAttributeInfo declarationAttributeInfo;
   if (!this.shaderAttributeInfo.TryGetValue(hashCode, out declarationAttributeInfo))
   {
     declarationAttributeInfo = new VertexDeclaration.VertexDeclarationAttributeInfo(this.GraphicsDevice.MaxVertexAttributes);
     foreach (VertexElement element in this._elements)
     {
       int attribLocation = shader.GetAttribLocation(element.VertexElementUsage, element.UsageIndex);
       if (attribLocation >= 0)
       {
         declarationAttributeInfo.Elements.Add(new VertexDeclaration.VertexDeclarationAttributeInfo.Element()
         {
           Offset = element.Offset,
           AttributeLocation = attribLocation,
           NumberOfElements = GraphicsExtensions.OpenGLNumberOfElements(element.VertexElementFormat),
           VertexAttribPointerType = GraphicsExtensions.OpenGLVertexAttribPointerType(element.VertexElementFormat),
           Normalized = GraphicsExtensions.OpenGLVertexAttribNormalized(element)
         });
         declarationAttributeInfo.EnabledAttributes[attribLocation] = true;
       }
     }
     this.shaderAttributeInfo.Add(hashCode, declarationAttributeInfo);
   }
   foreach (VertexDeclaration.VertexDeclarationAttributeInfo.Element element in declarationAttributeInfo.Elements)
     GL.VertexAttribPointer(element.AttributeLocation, element.NumberOfElements, element.VertexAttribPointerType, element.Normalized, this.VertexStride, (IntPtr) (offset.ToInt64() + (long) element.Offset));
   this.GraphicsDevice.SetVertexAttributeArray(declarationAttributeInfo.EnabledAttributes);
 }