public static Shader LoadShader(string vShaderPath, string fShaderPath, string name) { if (!Shaders.ContainsKey(name)) { Shaders[name] = LoadShaderFromFile(vShaderPath, fShaderPath); } return(Shaders[name]); }
public void AddShader(string pass, Shader shader) { if (!Shaders.ContainsKey(pass)) { Shaders.Add(pass, new List <Shader>()); } Shaders[pass].Add(shader); }
private void AddShader(Shader shader) { if (shader == null) { throw new ArgumentNullException("shader"); } if (Shaders.ContainsKey(shader.Type)) { throw new InvalidOperationException($"ShaderProgram.AddShader ({Name}): Program already contains a shader of type {shader.Type.ToString()}"); } Shaders.Add(shader.Type, shader); }
public bool TryAddShader(Shader shader) { if ((shader == null) || string.IsNullOrEmpty(shader.Name) || Shaders.ContainsKey(shader.Name)) { return(false); } if (string.IsNullOrEmpty(shader.Material) || !Materials.ContainsKey(shader.Material)) { return(false); } if (!string.IsNullOrEmpty(shader.Texture) && !Textures.ContainsKey(shader.Texture)) { return(false); } Shaders.Add(shader.Name, shader); return(true); }
public bool TryAddMesh(Mesh mesh) { if ((mesh == null) || string.IsNullOrEmpty(mesh.Name) || Meshes.ContainsKey(mesh.Name)) { return(false); } if (string.IsNullOrEmpty(mesh.Shader) || !Shaders.ContainsKey(mesh.Shader)) { return(false); } if (!mesh.IsTrianglesCorrect()) { return(false); } Meshes.Add(mesh.Name, mesh); return(true); }
public void LoadModels() { DirectoryInfo Folder = new DirectoryInfo(ModelLocation); if (Folder.Exists) { FileInfo[] ConfigFiles = Folder.GetFiles(); foreach (FileInfo CurrentFile in ConfigFiles) { if (CurrentFile.Extension.Equals(".obj")) { string Name = CurrentFile.Name.Remove(CurrentFile.Name.Length - 4, 4); GeometryModel NewModel = ModelUtil.ImportOBJModel(CurrentFile.FullName); string[] ModelMaterialData = GetModelMaterialData(Name); if (ModelMaterialData.Length != 0) { for (int i = 0; i < ModelMaterialData.Length; i++) { if (ModelMaterialData[i].Length == 0 || ModelMaterialData[i].StartsWith("//") || ModelMaterialData[i].StartsWith("#")) { continue; } string Key = ModelMaterialData[i].Split(new char[] { ':' })[0].Trim(); string Value = ModelMaterialData[i].Split(new char[] { ':' })[1].Trim(); if (Key.ToLower().StartsWith("shader")) { if (Shaders.ContainsKey(Value)) { NewModel.Shader = Shaders[Value].Clone(); } } if (Key.ToLower().StartsWith("depthshader")) { if (Shaders.ContainsKey(Value)) { NewModel.DepthShader = Shaders[Value].Clone(); } } else { if (Textures.ContainsKey(Value)) { NewModel.AddTexture(Key, Value); } } } if (NewModel.Shader == null || NewModel.DepthShader == null) { continue; } //Debug.WriteLine(Name); NewModel.Name = Name; Models.Add(Name, NewModel); } } } } }