示例#1
0
        public void ApplyStdMaterial(StdMaterial mat)
        {
            OpenGL.glBindVertexArray(vertex_array);
            MakeCurrent();
            this.mat = mat;
            for (int i = 0; i < elements.Count; i++)
            {
                ElementType t = (ElementType)(((int)desc.types[i] & 0xf) | ((int)desc.types[i] & 0x0f000000));
                switch (t)
                {
                case ElementType.Position:
                    elements[i].attribute = (uint)mat.PositionAttribute;
                    break;

                case ElementType.Normals:
                    elements[i].attribute = (uint)mat.NormalAttribute;
                    break;

                case ElementType.TexCoord:
                    elements[i].attribute = (uint)mat.TexCoord0Attribute;
                    break;

                case ElementType.TexCoord | (ElementType)0x01000000:
                    elements[i].attribute = (uint)mat.TexCoord1Attribute;
                    break;

                case ElementType.TexCoord | (ElementType)0x02000000:
                    elements[i].attribute = (uint)mat.TexCoord2Attribute;
                    break;

                case ElementType.TexCoord | (ElementType)0x03000000:
                    elements[i].attribute = (uint)mat.TexCoord3Attribute;
                    break;

                case ElementType.Color:
                    elements[i].attribute = (uint)mat.Color0Attribute;
                    break;

                case ElementType.Color | (ElementType)0x01000000:
                    elements[i].attribute = (uint)mat.Color1Attribute;
                    break;

                case ElementType.Color | (ElementType)0x02000000:
                    elements[i].attribute = (uint)mat.Color2Attribute;
                    break;

                case ElementType.Color | (ElementType)0x03000000:
                    elements[i].attribute = (uint)mat.Color3Attribute;
                    break;
                }
            }
            AssignPointers();
        }
示例#2
0
 public void ApplyMaterial(Material mat, Dictionary <ElementType, string> bindings)
 {
     OpenGL.glBindVertexArray(vertex_array);
     MakeCurrent();
     for (int i = 0; i < elements.Count; i++)
     {
         ElementType t = (ElementType)(((int)desc.types[i] & 0xf) | ((int)desc.types[i] & 0x0f000000));
         string      s = "";
         if (bindings.TryGetValue(t, out s))
         {
             elements[i].attribute = (uint)mat.Shader.GetAttributeLocation(s);
         }
     }
     AssignPointers();
 }
示例#3
0
 public override void MakeNonCurrent()
 {
     OpenGL.glBindVertexArray(0);
     base.MakeNonCurrent();
 }
示例#4
0
 public override void MakeCurrent()
 {
     OpenGL.glBindVertexArray(vertex_array);
     base.MakeCurrent();
 }