Наследование: ShaderResourceI
Пример #1
0
        public override ShaderResourceI Resource(string name)
        {
            // Try to find existing variable
            foreach (var resource in resources)
            {
                if (resource.Name == name)
                {
                    return(resource);
                }
            }

            // Otherwise add a variable instance
                        #if SILVERLIGHT
            int resourceIndex = -1;
            for (int i = 0; i != psResourceNames.Count; ++i)
            {
                if (psResourceNames[i] == name)
                {
                    resourceIndex = psResourceIndices[i];
                    break;
                }
            }

            if (resourceIndex == -1)
            {
                Debug.ThrowError("Shader", string.Format("Shader resource '{0}' does not exist", name));
            }

            var resourceOut = new ShaderResource(video, resourceIndex, name);
            resources.Add(resourceOut);
            return(resourceOut);
                        #else
            var parameter = effect.Parameters[name];
            if (parameter == null)
            {
                Debug.ThrowError("Shader", string.Format("Shader resource '{0}' does not exist", name));
            }

            var resourceOut = new ShaderResource(parameter, name);
            resources.Add(resourceOut);
            return(resourceOut);
                        #endif
        }
Пример #2
0
        public override ShaderResourceI Resource(string name)
        {
            // Try to find existing variable
            foreach (var resource in resources)
            {
                if (resource.Name == name) return resource;
            }

            // Otherwise add a variable instance
            #if SILVERLIGHT
            int resourceIndex = -1;
            for (int i = 0; i != psResourceNames.Count; ++i)
            {
                if (psResourceNames[i] == name)
                {
                    resourceIndex = psResourceIndices[i];
                    break;
                }
            }

            if (resourceIndex == -1)
            {
                Debug.ThrowError("Shader", string.Format("Shader resource '{0}' does not exist", name));
            }

            var resourceOut = new ShaderResource(video, resourceIndex, name);
            resources.Add(resourceOut);
            return resourceOut;
            #else
            var parameter = effect.Parameters[name];
            if (parameter == null)
            {
                Debug.ThrowError("Shader", string.Format("Shader resource '{0}' does not exist", name));
            }

            var resourceOut = new ShaderResource(parameter, name);
            resources.Add(resourceOut);
            return resourceOut;
            #endif
        }