Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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));
            }
        }
Esempio n. 3
0
 public Material(ProgramPipeline pipeline)
 {
     Pipeline = pipeline;
     Textures = new Dictionary <string, Texture>();
 }
Esempio n. 4
0
 internal void CreatePipeline()
 {
     m_pipeline = new ProgramPipeline();
 }