public Material(Stream vertexShaderStream, Stream fragmentShaderStream, Stream geometryShaderStream = null) { m_pipeline = new ProgramPipeline(); void AddShader(Stream stream, ShaderType type) { string source = new StreamReader(stream).ReadToEnd(); var program = new ShaderProgram(type, source); if (!program || !program.Linked) { Logger.Log(program.InfoLog); Host.Quit(1); } AssignShader(program); } AddShader(vertexShaderStream, ShaderType.Vertex); AddShader(fragmentShaderStream, ShaderType.Fragment); if (geometryShaderStream != null) { AddShader(geometryShaderStream, ShaderType.Geometry); } }
private static void ConfigureMaterial(EntityManager entityManager, Entity entity) { ProgramPipeline programPipeline = ProgramRegistry.Instance.Load("Resources/Shaders/PackedVertex.glsl", "Resources/Shaders/DefaultFragment.glsl"); if (entity.TryComponent(out Material? material)) { if (material.Pipeline.Handle != programPipeline.Handle) { material.Pipeline = programPipeline; } } else { entityManager.RegisterComponent(entity, new Material(programPipeline)); } }
public Material(ProgramPipeline pipeline) { Pipeline = pipeline; Textures = new Dictionary <string, Texture>(); }
internal void CreatePipeline() { m_pipeline = new ProgramPipeline(); }