示例#1
0
 public ShaderAttribute(ShaderAttributeName nameParam, ShaderDataType dataTypeParam, int locationParam, int elementSizeParam)
 {
     name        = nameParam;
     dataType    = dataTypeParam;
     location    = locationParam;
     elementSize = elementSizeParam;
 }
示例#2
0
 public ShaderAttribute(ShaderAttributeName nameParam, ShaderDataType dataTypeParam)
 {
     name        = nameParam;
     dataType    = dataTypeParam;
     location    = -1;
     elementSize = -1;
 }
示例#3
0
        public static int getAttributeSizeElements(ShaderAttributeName name)
        {
            switch (name)
            {
            case ShaderAttributeName.Position: return(MeshData.getElementsInPosition());

            case ShaderAttributeName.Normal: return(MeshData.getElementsInNormal());

            case ShaderAttributeName.TexCoord: return(MeshData.getElementsInTexCoord());

            default: return(0);
            }
        }
示例#4
0
        public static int getAttributeSizeBytes(ShaderAttributeName name)
        {
            switch (name)
            {
            case ShaderAttributeName.Position: return(MeshData.getPositionSizeBytes());

            case ShaderAttributeName.Normal: return(MeshData.getNormalSizeBytes());

            case ShaderAttributeName.TexCoord: return(MeshData.getTexCoordSizeBytes());

            default: return(0);
            }
        }
示例#5
0
        public static ShaderAttribute getAttribute(ShaderAttributeName name, ShaderProgram shaderProgram)
        {
            foreach (ShaderAttribute attr in shaderProgram.attributes)
            {
                if (attr.name == name)
                {
                    return(attr);
                }
            }
            Logger.LogError(Logger.ErrorState.Critical, "Did not get attribute " + ShaderUniformManager.GetSingleton().GetAttributeName(name));
            ShaderAttribute invalid = new ShaderAttribute(ShaderAttributeName.InvalidAttributeName, ShaderDataType.InvalidType);

            return(invalid);
        }
示例#6
0
        public int GetAttributeLocation(ShaderAttributeName attribName)
        {
            foreach (ShaderAttribute a in attributes)
            {
                if (a.name == attribName)
                {
                    return(a.location);
                }
            }
            ShaderUniformManager uniMan = ShaderUniformManager.GetSingleton();

            Logger.LogError(Logger.ErrorState.Limited, "Attribute " + uniMan.GetAttributeName(attribName) + " location not found");
            return(-1);
        }
示例#7
0
        public string GetAttributeName(ShaderAttributeName name)
        {
            switch (name)
            {
            case ShaderAttributeName.Position: return("aPosition");

            case ShaderAttributeName.Normal: return("aNormal");

            case ShaderAttributeName.TexCoord: return("aTexCoord");

            case ShaderAttributeName.DiffuseColor: return("aDiffuseColor");

            default: return(string.Empty);
            }
        }
示例#8
0
        private ShaderAttribute getAttribute(ShaderAttributeName name, List <ShaderAttribute> attributes)
        {
            ShaderAttribute result = new ShaderAttribute();

            result.location = -1;

            foreach (ShaderAttribute a in attributes)
            {
                if (a.name.Equals(name))
                {
                    if (checkAttribute(a))
                    {
                        result = a;
                    }
                }
            }

            if (result.location == -1)
            {
                Logger.LogError(Logger.ErrorState.Limited, "Did not get attribute ");
            }
            return(result);
        }
示例#9
0
 private void AddSupportedAttribute(ShaderAttributeName name, ShaderDataType type)
 {
     supportedAttributes.Add(GetAttributeName(name), new ShaderAttribute(name, type));
 }