Exemplo n.º 1
0
        private bool compileShader(string source, ShaderMode shaderType)
        {
            if (string.IsNullOrEmpty(source))
            {
                return(true);
            }

            int shader = _graphics.CreateShader(shaderType);

            _graphics.ShaderSource(shader, source);
            _graphics.CompileShader(shader);
            string info      = _graphics.GetShaderInfoLog(shader);
            int    errorCode = _graphics.GetShaderCompilationErrorCode(shader);

            if (errorCode != 1)
            {
                Debug.WriteLine($@"Failed to compile {shaderType}.{Environment.NewLine}Error code: {errorCode}.{Environment.NewLine}
                    Error message(s): {info ?? "null"}.{Environment.NewLine}Shader Source: {source}{Environment.NewLine}");
                _graphics.DeleteShader(shader);
                _program = 0;
                return(false);
            }

            _graphics.AttachShader(_program, shader);
            _graphics.DeleteShader(shader);
            return(true);
        }