示例#1
0
        public static void ReadProject(Stream inputStream, out Shader[] shaders, out Program[] programs)
        {
            int numberShaders = readInt(inputStream);
            var idToShaderMap = new Dictionary<uint, Shader>(numberShaders);
            shaders = new Shader[numberShaders];
            for (uint shaderId = 0; shaderId < numberShaders; ++shaderId)
            {
            var shader = new Shader((ProgramStage) readUint(inputStream));
            shader.Name = readString(inputStream);
            shader.Source = readString(inputStream);

            shaders[shaderId] = shader;
            idToShaderMap[shaderId] = shader;
            }

            int numberPrograms = readInt(inputStream);
            programs = new Program[numberPrograms];
            for (uint i = 0; i < numberPrograms; ++i)
            {
            Program program = new Program();
            program.Name = readString(inputStream);
            var attachedShaderCount = readInt(inputStream);
            for (uint j = 0; j < attachedShaderCount; ++j)
            {
                var shaderId = readUint(inputStream);
                var shader = idToShaderMap[shaderId];
                program.AttachShader(shader);
            }
            programs[i] = program;
            }
        }
示例#2
0
 private void onSourceValidityChanged(
 Shader sender, Validity oldValidity, Validity newValidity)
 {
     OnPropertyChanged("SourceValidity");
     OnPropertyChanged("CompilationError");
 }
示例#3
0
 public ShaderViewModel(Shader shader)
 {
     Shader = shader;
     renaming = false;
     shader.SourceValidityChanged += onSourceValidityChanged;
 }
示例#4
0
 public ActiveShaderValues(Shader shader)
 {
     Stage = shader.Stage;
     Source = shader.Source;
 }
 public ShaderViewModel GetViewModelForShader(Shader shader)
 {
     return shaderViewModelsByShader[shader];
 }
 public void AddShader(Shader shader)
 {
     GlContextManager.ShaderCompiler.AddShader(shader);
     var shaderViewModel = new ShaderViewModel(shader);
     shaderViewModelsByShader.Add(shader, shaderViewModel);
     Shaders.Add(shaderViewModel);
 }
示例#7
0
 private void raiseShaderDetached(Shader shader)
 {
     var handlers = ShaderDetached;
     handlers?.Invoke(this, shader);
 }
示例#8
0
 private void onAttachedShaderSourceChanged(Shader shader)
 {
     programInputsChanged();
 }
示例#9
0
        public void DetachShader(Shader shader)
        {
            bool removed = shadersByStage.Remove(
            new KeyValuePair<ProgramStage, Shader>(shader.Stage, shader));
            Debug.Assert(
            removed,
            "No shader is attached to the "
                + shader.Stage.ToString() + " stage of this program");

            shader.SourceChanged -= onAttachedShaderSourceChanged;
            raiseShaderDetached(shader);
            programInputsChanged();
        }
示例#10
0
        public void AttachShader(Shader shader)
        {
            Debug.Assert(
            !ShadersByStage.ContainsKey(shader.Stage),
            "A shader for the " + shader.Stage.ToString()
                + " stage is already attached to this program");

            shader.SourceChanged += onAttachedShaderSourceChanged;
            shadersByStage.Add(shader.Stage, shader);
            raiseShaderAttached(shader);
            programInputsChanged();
        }