Beispiel #1
0
        public Shader(string resourcePath)
        {
            _programId = GL.CreateProgram();

            var exists = false;

            foreach (var entry in ShaderTypes)
            {
                var path = resourcePath + entry.Key;
                if (ResourceReader.Exists(path))
                {
                    AttachShader(entry.Value, ResourceReader.ReadString(path));
                    exists = true;
                }
            }

            if (!exists)
            {
                Logger.Error($"Shader \"{resourcePath}\" was not found!");
                return;
            }

            GL.LinkProgram(_programId);
            var infoLog = GL.GetProgramInfoLog(_programId);

            if (!string.IsNullOrEmpty(infoLog))
            {
                Logger.Error($"There was an error linking shader \"{resourcePath}\": {infoLog}");
            }
        }