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; } }
private void onSourceValidityChanged( Shader sender, Validity oldValidity, Validity newValidity) { OnPropertyChanged("SourceValidity"); OnPropertyChanged("CompilationError"); }
public ShaderViewModel(Shader shader) { Shader = shader; renaming = false; shader.SourceValidityChanged += onSourceValidityChanged; }
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); }
private void raiseShaderDetached(Shader shader) { var handlers = ShaderDetached; handlers?.Invoke(this, shader); }
private void onAttachedShaderSourceChanged(Shader shader) { programInputsChanged(); }
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(); }
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(); }